Dattatray
Dattatray

Reputation: 1875

AWS Serverless Framework : MalformedPolicyDocument Error while creating IAM Role and Policy

I am trying to create an IAM role and a policy through a serverless template.

When I try to deploy this, I am getting an error -

An error occurred: SQSConnectPolicy - Syntax errors in policy. (Service: AmazonIdentityManagement; Status Code: 400; Error Code: MalformedPolicyDocument

Here is the snippet of my serverless.yml file

SQSConnectRole:
      Type: 'AWS::IAM::Role'
      Properties:
        RoleName: SqSConnectRole
        AssumeRolePolicyDocument:
          Version: '2012-10-17'
          Statement:
            - Action:
              - 'sts:AssumeRole'
              Effect: Allow
              Principal:
                Service:
                  - iot.amazonaws.com
        Path: /service-role/

    SQSConnectPolicy:
      Type: 'AWS::IAM::Policy'
      Properties:
        PolicyName: SqSConnectPolicy
        Roles:
          - !Ref SQSConnectRole
        PolicyDocument:
          Version: 2012-10-17
          Statement:
            - Effect: Allow
              Action: 'sqs:SendMessage'
              Resources:
                - arn:aws:sqs:${self:provider.region}:#{AWS::AccountId}:connectDeviceSQSDemo

Is this valid to create the policy and the role in the same Serverless.yml file?

Do I need to add dependencies? Any inputs to the above problem?

Upvotes: 0

Views: 1072

Answers (1)

Joey Kilpatrick
Joey Kilpatrick

Reputation: 1602

There is a typo in your IAM policy. The word Resources should be changed to Resource.

Upvotes: 3

Related Questions