0
votes

I need to specify sns topic as a target using cloud formation template.

JobFailedAlert is the name of the sns topic.

I am have this template rule.json and I am getting the error

Error:

Template validation error: Template error: instance of Fn::GetAtt references undefined resource SNSTopic

Template:

    {
"Resources": {
  "Rule": {
  "Type" : "AWS::Events::Rule",
  "Properties" : {
    "Description" : "create a sns alert when a batch job changes state to failed",
    "EventPattern" : {
  "detail-type": [
    "Batch Job State Change"
  ],
  "source": [
    "aws.batch"
  ],
  "detail": {
    "jobQueue": [
      "arn:aws:batch:us-east-1:************:job-queue/testbatchjobqueue"
    ],
    "status": [
      "FAILED"
    ]
  }
},
    "Name" : "alertonfailedbatchjobs2",
    "State" : "Enabled",
    "Targets": [
  {
    "Arn": { "Ref": "SNS Topic" },
    "Id": "JobFailedAlert"
  }
  }
}
}
}
1
Please show the part of your template where the SNS topic got defined as well. - Dunedan

1 Answers

1
votes

It may be that the rule is being created before the SNS topic. Try making sure that the SNS topic is created first by using DependsOn, such as:

"Rule": {
    DependsOn: TheSNSTopic
    ...
}