2017-12-21 9 views
0

Ich versuche, SNS-Abonnement zu erstellen, aber ich bekomme Vorlage Validierung Fehler.Cloudformation SNS Vorlage Validierungsfehler

'MySNSTopic' ist die logische ID des Cloudformationsstapels, die als testnstopic bezeichnet wird.

Ist das korrekt? Kann mir jemand erklären, welchen Wert ich sollte hier für 'Ref'

geben
"TopicArn" : { 
     "Ref": "MySNSTopic" 
     } 

Template Validierungsfehler:

Template format error: Unresolved resource dependencies [MySNSTopic] in the Resources block of the template 

Code:

{ 
"Resources": { 
"MySubscription" : { 
    "Type" : "AWS::SNS::Subscription", 
    "Properties" : { 
    "Endpoint" : "[email protected]", 
    "Protocol" : "email", 
    "TopicArn" : { 
    "Ref": "MySNSTopic" 
    } 
    } 
} 
} 
} 

Antwort

1

Um die Eigenschaften in den verschiedenen Stapeln zu verwenden, müssen Sie exportiere die Werte explizit an dem einen Ende und importiere sie in den anderen Stapel.

In Ihrem Fall würden Sie propably brauchen so etwas wie folgt aus:

Stack: SNS-Test

{ 
    "Resources": { 
     "MySNSTopic": { 
      "Type": "AWS::SNS::Topic" 
     } 
    }, 
    "Outputs": { 
     "MySNSTopicOutput": { 
      "Description": "SNS topic arn", 
      "Value": { 
       "Ref": "MySNSTopic" 
      }, 
      "Export": { 
       "Name": { 
        "Fn::Sub": "${AWS::StackName}-MySNSTopicExport" 
       } 
      } 
     } 
    } 
} 

Stack: SNS-Abonnement

{ 
    "Resources": { 
    "MySubscription": { 
     "Type": "AWS::SNS::Subscription", 
     "Properties": { 
     "Endpoint": "[email protected]", 
     "Protocol": "email", 
     "TopicArn": { 
      "Fn::ImportValue" : "sns-test-MySNSTopicExport" 
     } 
     } 
    } 
    } 
} 
Verwandte Themen