Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to export SNS topic to be used in different stacks in Cloudformation

In one Cloudformation template, I create an SNS topic and export it. Note that you cannot export an SNS topic's Arn because that attribute is not available to GetAtt on docs.

BaseStack

Outputs:
  AlarmSNSTopic: 
    Description: Arn for SNS topic related to alarms
    Export:
      Name: AlarmSNSTopic
    Value: { "Fn::GetAtt": ["MyAlarmSNSTopic", "TopicName"] }

Then in a different template, I try to reference that export with something like:

Functional Stack 1

InputQueueNoMessages:
  Type: AWS::CloudWatch::Alarm
  Properties:
    AlarmDescription: Some Alarm
  ...
  AlarmActions:
    Fn::ImportValue: AlarmSNSTopic

When I do, Cloudformation tells me that it expects an ARN, not the topic name.

Invalid arn syntax: Blah-AlarmSNSTopic-random

Is this possible? Am I missing something?

like image 977
zachd1_618 Avatar asked Jan 29 '23 14:01

zachd1_618


1 Answers

AWS::CloudWatch::Alarm requires an ARN for AlarmActions, but you exported the topic name. The value of your output should be the ARN.

Outputs:
  AlarmSNSTopic: 
    Description: Arn for SNS topic related to alarms
    Export:
      Name: AlarmSNSTopic
    Value: !Ref MyAlarmSNSTopic
like image 178
kichik Avatar answered Apr 28 '23 13:04

kichik