AWS cloudformation error: Template validation error: Template error: resource NotificationsTopic does not...












2















I am trying to create an AWS cloudformation stack using a yaml template.
The goal is to create a sns topic for some notifications.
I want to output the topic arn, to be able to subscribe multiple functions to that topic by just specifying the topic arn.



However I am getting an error when I try to create the stack from the aws console:



"Template validation error: Template error: resource NotificationsTopic does not support attribute type Arn in Fn::GetAtt"



I have done exactly the same for s3 buckets, dynamodb tables, and all working good, but for some reason, with SNS topic I cannot get the ARN.



I want to avoid hardcoding the topic arn in all functions that are subscribed. Because if one day the the ARN topic changes, I'll need to change all functions, instead I want to import the topic arn in all functions and use it. This way I will have to modify nothing if for any reason I have a new arn topic in the future.



This is the template:



    Parameters:
stage:
Type: String
Default: dev
AllowedValues:
- dev
- int
- uat
- prod

Resources:
NotificationsTopic:
Type: AWS::SNS::Topic
Properties:
DisplayName: !Sub 'notifications-${stage}'
Subscription:
- SNS Subscription
TopicName: !Sub 'notifications-${stage}'
Outputs:
NotificationsTopicArn:
Description: The notifications topic Arn.
Value: !GetAtt NotificationsTopic.Arn
Export:
Name: !Sub '${AWS::StackName}-NotificationsTopicArn'
NotificationsTopicName:
Description: Notifications topic name.
Value: !Sub 'notifications-${stage}'
Export:
Name: !Sub '${AWS::StackName}-NotificationsTopicName'









share|improve this question



























    2















    I am trying to create an AWS cloudformation stack using a yaml template.
    The goal is to create a sns topic for some notifications.
    I want to output the topic arn, to be able to subscribe multiple functions to that topic by just specifying the topic arn.



    However I am getting an error when I try to create the stack from the aws console:



    "Template validation error: Template error: resource NotificationsTopic does not support attribute type Arn in Fn::GetAtt"



    I have done exactly the same for s3 buckets, dynamodb tables, and all working good, but for some reason, with SNS topic I cannot get the ARN.



    I want to avoid hardcoding the topic arn in all functions that are subscribed. Because if one day the the ARN topic changes, I'll need to change all functions, instead I want to import the topic arn in all functions and use it. This way I will have to modify nothing if for any reason I have a new arn topic in the future.



    This is the template:



        Parameters:
    stage:
    Type: String
    Default: dev
    AllowedValues:
    - dev
    - int
    - uat
    - prod

    Resources:
    NotificationsTopic:
    Type: AWS::SNS::Topic
    Properties:
    DisplayName: !Sub 'notifications-${stage}'
    Subscription:
    - SNS Subscription
    TopicName: !Sub 'notifications-${stage}'
    Outputs:
    NotificationsTopicArn:
    Description: The notifications topic Arn.
    Value: !GetAtt NotificationsTopic.Arn
    Export:
    Name: !Sub '${AWS::StackName}-NotificationsTopicArn'
    NotificationsTopicName:
    Description: Notifications topic name.
    Value: !Sub 'notifications-${stage}'
    Export:
    Name: !Sub '${AWS::StackName}-NotificationsTopicName'









    share|improve this question

























      2












      2








      2








      I am trying to create an AWS cloudformation stack using a yaml template.
      The goal is to create a sns topic for some notifications.
      I want to output the topic arn, to be able to subscribe multiple functions to that topic by just specifying the topic arn.



      However I am getting an error when I try to create the stack from the aws console:



      "Template validation error: Template error: resource NotificationsTopic does not support attribute type Arn in Fn::GetAtt"



      I have done exactly the same for s3 buckets, dynamodb tables, and all working good, but for some reason, with SNS topic I cannot get the ARN.



      I want to avoid hardcoding the topic arn in all functions that are subscribed. Because if one day the the ARN topic changes, I'll need to change all functions, instead I want to import the topic arn in all functions and use it. This way I will have to modify nothing if for any reason I have a new arn topic in the future.



      This is the template:



          Parameters:
      stage:
      Type: String
      Default: dev
      AllowedValues:
      - dev
      - int
      - uat
      - prod

      Resources:
      NotificationsTopic:
      Type: AWS::SNS::Topic
      Properties:
      DisplayName: !Sub 'notifications-${stage}'
      Subscription:
      - SNS Subscription
      TopicName: !Sub 'notifications-${stage}'
      Outputs:
      NotificationsTopicArn:
      Description: The notifications topic Arn.
      Value: !GetAtt NotificationsTopic.Arn
      Export:
      Name: !Sub '${AWS::StackName}-NotificationsTopicArn'
      NotificationsTopicName:
      Description: Notifications topic name.
      Value: !Sub 'notifications-${stage}'
      Export:
      Name: !Sub '${AWS::StackName}-NotificationsTopicName'









      share|improve this question














      I am trying to create an AWS cloudformation stack using a yaml template.
      The goal is to create a sns topic for some notifications.
      I want to output the topic arn, to be able to subscribe multiple functions to that topic by just specifying the topic arn.



      However I am getting an error when I try to create the stack from the aws console:



      "Template validation error: Template error: resource NotificationsTopic does not support attribute type Arn in Fn::GetAtt"



      I have done exactly the same for s3 buckets, dynamodb tables, and all working good, but for some reason, with SNS topic I cannot get the ARN.



      I want to avoid hardcoding the topic arn in all functions that are subscribed. Because if one day the the ARN topic changes, I'll need to change all functions, instead I want to import the topic arn in all functions and use it. This way I will have to modify nothing if for any reason I have a new arn topic in the future.



      This is the template:



          Parameters:
      stage:
      Type: String
      Default: dev
      AllowedValues:
      - dev
      - int
      - uat
      - prod

      Resources:
      NotificationsTopic:
      Type: AWS::SNS::Topic
      Properties:
      DisplayName: !Sub 'notifications-${stage}'
      Subscription:
      - SNS Subscription
      TopicName: !Sub 'notifications-${stage}'
      Outputs:
      NotificationsTopicArn:
      Description: The notifications topic Arn.
      Value: !GetAtt NotificationsTopic.Arn
      Export:
      Name: !Sub '${AWS::StackName}-NotificationsTopicArn'
      NotificationsTopicName:
      Description: Notifications topic name.
      Value: !Sub 'notifications-${stage}'
      Export:
      Name: !Sub '${AWS::StackName}-NotificationsTopicName'






      amazon-web-services amazon-cloudformation amazon-sns aws-serverless






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 24 '18 at 11:04









      fgonzalezfgonzalez

      98011635




      98011635
























          1 Answer
          1






          active

          oldest

          votes


















          3














          Not all resources are the same. Always check the documentation for the particular resource. It has the "Return Values" section and you can easily verify that SNS topic has ARN as a Ref value, so you don't have to use GetAtt function



          https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-sns-topic.html






          share|improve this answer























            Your Answer






            StackExchange.ifUsing("editor", function () {
            StackExchange.using("externalEditor", function () {
            StackExchange.using("snippets", function () {
            StackExchange.snippets.init();
            });
            });
            }, "code-snippets");

            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "1"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53457474%2faws-cloudformation-error-template-validation-error-template-error-resource-no%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            3














            Not all resources are the same. Always check the documentation for the particular resource. It has the "Return Values" section and you can easily verify that SNS topic has ARN as a Ref value, so you don't have to use GetAtt function



            https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-sns-topic.html






            share|improve this answer




























              3














              Not all resources are the same. Always check the documentation for the particular resource. It has the "Return Values" section and you can easily verify that SNS topic has ARN as a Ref value, so you don't have to use GetAtt function



              https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-sns-topic.html






              share|improve this answer


























                3












                3








                3







                Not all resources are the same. Always check the documentation for the particular resource. It has the "Return Values" section and you can easily verify that SNS topic has ARN as a Ref value, so you don't have to use GetAtt function



                https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-sns-topic.html






                share|improve this answer













                Not all resources are the same. Always check the documentation for the particular resource. It has the "Return Values" section and you can easily verify that SNS topic has ARN as a Ref value, so you don't have to use GetAtt function



                https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-properties-sns-topic.html







                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Nov 24 '18 at 11:17









                petrchpetrch

                32626




                32626
































                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53457474%2faws-cloudformation-error-template-validation-error-template-error-resource-no%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    404 Error Contact Form 7 ajax form submitting

                    How to know if a Active Directory user can login interactively

                    Refactoring coordinates for Minecraft Pi buildings written in Python