0
インスタンスを起動または終了するときに通知を取得するために、SNSトピックを作成し、そのトピックをASGで参照しようとしています。ここで私が使用しています対流圏コードのセクションです:私は、トピックのARNを引き出してASGでNotificationConfigurationsの「TopicARN」の値として与えているAWS SNSトピックを作成し、ASSで対流圏を使用して参照してください
email_topic = self.template.add_resource(Topic(
'ec2_lauch_termination',
Subscription=[
Subscription(
Endpoint=Ref(alarm_email),
Protocol="email"
),
],
))
self.template.add_output(Output(
"TopicArn",
Value=GetAtt(email_topic, "Arn"),
Description="ARN of email topic",
))
for i in range(0, self.subnet_count):
asg_name = "autoScalingGroup" + str(i)
asg = self.template.add_resource(AutoScalingGroup(
asg_name,
DesiredCapacity=Ref(self.desired_capacity),
HealthCheckType="EC2",
LaunchConfigurationName=Ref(launch_config),
MinSize=Ref(self.min_size),
MaxSize=Ref(self.max_size),
VPCZoneIdentifier=[Select(i, Ref(self.instance_subnets))],
Tags=[
Tag("Name", Join("-", [Ref(self.resource_name), Ref(self.env_tag), Ref(self.vpc_short_name), "pdx"]), True),
Tag("Name", "XXXX", True),
Tag("Service", Ref(self.service_tag), True),
Tag("Environment", Ref(self.env_tag), True),
Tag("Address", Ref(self.address_tag), True)
],
NotificationConfigurations=[
NotificationConfigurations(
TopicARN=GetAtt(email_topic, "Arn"),
NotificationTypes=[
'autoscaling:EC2_INSTANCE_LAUNCH',
'autoscaling:EC2_INSTANCE_LAUNCH_ERROR',
'autoscaling:EC2_INSTANCE_TERMINATE',
'autoscaling:EC2_INSTANCE_TERMINATE_ERROR',
],
),
],
))
は、しかし、このコードは、出力aをしませんCFテンプレート。ここに何もないか、これを達成する良い方法はありますか?
あなたの助けを前もって感謝してください!
ありがとうございます!