Serverlessを使っていて以下のエラー。
エラー
Serverless Error ---------------------------------------
An error occurred: MicroServiceAdminGroupPolicy - The policy failed legacy parsing (Service: AmazonIdentityManagement; Status Code: 400; Error Code: MalformedPolicyDocument; Request ID: xxx-xxx).
Get Support --------------------------------------------
Docs: docs.serverless.com
Bugs: github.com/serverless/serverless/issues
Issues: forum.serverless.com
Your Environment Information ---------------------------
Operating System: darwin
Node Version: 12.4.0
Framework Version: 1.63.0
Plugin Version: 3.3.0
SDK Version: 2.3.0
Components Core Version: 1.1.2
Components CLI Version: 1.4.0
テンプレートの内容
MicroServiceAdminGroupPolicy:
Type: AWS::IAM::ManagedPolicy
Properties:
Description: "foobar"
Groups:
- !Ref MicroServiceAdminGroup
PolicyDocument:
Version: '2012-10-17'
Statement:
# DynamoDB
- Effect: Allow
Action:
- dynamodb:*
Resource:
- "arn:aws:dynamodb:#{AWS::Region}:#{AWS::AccountId}:table/${self:service}-*"
原因
↓こいつらが原因。
#{AWS::Region}
Serverless Pseudo Parametersの記法だが、プラグインを入れ忘れていた。プラグインを入れることで解決。
npm install serverless-pseudo-parameters --save-dev
serverless.yml
plugins:
- serverless-pseudo-parameters