AWSのRDSイベントサブスクリプションをCloudFormationで設定する
複数のAWSアカウントにRDSのイベントサブスクリプションを設定しました。
当初は面倒だったので手動で設定していたのですが、手動のほうが面倒ということに気付いたため、CloudFormationで作成するようにしました。
当初は面倒だったので手動で設定していたのですが、手動のほうが面倒ということに気付いたため、CloudFormationで作成するようにしました。
設定内容
ソースタイプ
設定できるすべて:インスタンス、セキュリティグループ、パラメータグループ、スナップショット、クラスター、クラスタースナップショット、カスタムエンジンバージョン
イベントカテゴリ
「すべてのイベントカテゴリ」
設定できるすべて:インスタンス、セキュリティグループ、パラメータグループ、スナップショット、クラスター、クラスタースナップショット、カスタムエンジンバージョン
イベントカテゴリ
「すべてのイベントカテゴリ」
CloudFormationテンプレート
AWSTemplateFormatVersion: '2010-09-09'
Description: "Create RDS Event Subscription"
# ------------------------------------------------------------#
# Input Parameters
# ------------------------------------------------------------#
Parameters:
SNSTopic:
Description: Please type the SNS Topic ARN.
Type: String
Resources:
# ------------------------------------------------------------#
# RDS EventSubscription
# https://docs.aws.amazon.com/ja_jp/AWSCloudFormation/latest/UserGuide/aws-resource-rds-eventsubscription.html
# SourceType: db-instance | db-cluster | db-parameter-group | db-security-group | db-snapshot | db-cluster-snapshot
# ------------------------------------------------------------#
RDSEventSubscriptionInstance:
Type: "AWS::RDS::EventSubscription"
Properties:
Enabled: true
SnsTopicArn: !Ref SNSTopic
SourceType: "db-instance"
RDSEventSubscriptionCluster:
Type: "AWS::RDS::EventSubscription"
Properties:
Enabled: true
SnsTopicArn: !Ref SNSTopic
SourceType: "db-cluster"
RDSEventSubscriptionParameterGroup:
Type: "AWS::RDS::EventSubscription"
Properties:
Enabled: true
SnsTopicArn: !Ref SNSTopic
SourceType: "db-parameter-group"
RDSEventSubscriptionSecurityGroup:
Type: "AWS::RDS::EventSubscription"
Properties:
Enabled: true
SnsTopicArn: !Ref SNSTopic
SourceType: "db-security-group"
RDSEventSubscriptionSnapshot:
Type: "AWS::RDS::EventSubscription"
Properties:
Enabled: true
SnsTopicArn: !Ref SNSTopic
SourceType: "db-snapshot"
RDSEventSubscriptionClusterSnapshot:
Type: "AWS::RDS::EventSubscription"
Properties:
Enabled: true
SnsTopicArn: !Ref SNSTopic
SourceType: "db-cluster-snapshot"
GitHubにもコミット済み
https://github.com/e2kaneko/aws-cloud-formation-rds-event-subscription
https://github.com/e2kaneko/aws-cloud-formation-rds-event-subscription
結果
作成できました




