sbstjn / serverless-sqs-alarms-plugin

Serverless wrapper to setup CloudWatch Alarms for SQS
https://www.npmjs.com/package/serverless-sqs-alarms-plugin
MIT License
36 stars 22 forks source link

use partition pseudo variable for compatibility with gov-cloud #15

Open jeremygiberson-at-privoro opened 4 years ago

jeremygiberson-at-privoro commented 4 years ago

When deploying into AWS GovCloud, the ARN uses a different partition value. I believe this is also true for china regions as well. When trying to create alarm resources, cloudformation update will fail with one of the event errors being:

Invalid partition aws specified. Only aws-us-gov is supported. (Service: AmazonCloudWatch; Status Code: 400; Error Code: ValidationError; Request ID: 50120a93-12b8-40cb-bd3b-65266f0491f9; Proxy: null)

In order to accommodate deployments to these special regions you should use the AWS::Partition cloud formation pseudo parameters instead. The appropriate value will be filled in.

Before the change:

"AlarmActions": [
          {
            "Fn::Join": [
              "",
              [
                "arn:aws:sns:us-gov-east-1:",
                {
                  "Ref": "AWS::AccountId"
                },
                ":undefined"
              ]
            ]
          }
        ],

After the change

"AlarmActions": [
          {
            "Fn::Join": [
              "",
              [
                "arn:", 
               {
                  "Ref": "AWS::Partition"
                },
                ,":sns:us-gov-east-1:",
                {
                  "Ref": "AWS::AccountId"
                },
                ":undefined"
              ]
            ]
          }
        ],