functionalone/serverless-iam-roles-per-function

Configuration error: at 'provider.iam.role.statements.1.Action.0': must be string

hari5udhan opened this issue · 1 comments

provider:
name: aws
runtime: nodejs12.x
stage: dev
region: ap-south-1
iam:
role:
statements:
- Effect: Allow
Action:
- excute-api:Invoke
Resource: arn:aws:execute-api:::*
- Effect: Allow
Action:
- dynamodb: UpdateItem
- dynamodb: PutItem
Resource: arn:aws*****************

Console Error is
Error:
Configuration error:
at 'provider.iam.role.statements.1.Action.0': must be string
at 'provider.iam.role.statements.1.Action.1': must be string

Learn more about configuration validation here: http://slss.io/configuration-validation

IAM actions are on the form service:action. In your example however, you have a space after the colon, making this into an object per the YAML specification. If converting your YAML to JSON, you would see that it has become:

"action": [{"dynamodb": "UpdateItem"}, {"dynamodb": "PutItem"}]

instead of

"action": ["dynamodb:UpdateItem", "dynamodb:PutItem"]

Removing the space should do the trick.

Action:
  - dynamodb:UpdateItem
  - dynamodb:PutItem

Sometimes it's also wise to quote strings containing special characters in YAML.