EDIT: this question is probably outdated. Consider this comment and this answer.
AWS CloudFormation offers some variables like AWS::AccountId
and AWS::Region
, but you can't use them in the serverless.yml file like ${AWS::AccountId}
. Those are not supported.
@jens answer is right. You must use the CloudFormation syntax. In the example below, I provide another way to use CloudFormation.
service: testing-aws-account-id
provider:
name: aws
runtime: nodejs4.3
region: us-east-1
iamRoleStatements:
- Effect: "Allow"
Action:
- "iot:Publish"
Resource: 'Fn::Join: ["", [ "aws:iot:", { "Ref": "AWS::Region" }, ":", { Ref: "AWS::AccountId" }, ":topic/foo" ]]'
functions:
publishIot:
handler: handler.publishIot
The line:
Resource: 'Fn::Join: ["", [ "aws:iot:", { "Ref": "AWS::Region" }, ":", { Ref: "AWS::AccountId" }, ":topic/foo" ]]'
is the same of hard-coding the region and account id:
Resource: "arn:aws:iot:us-east-1:1234567890:topic/foo"