Anonymous
Anonymous

Reputation: 153

Invalid policy role due to malformed Json? AWS

I am following this tutorial: https://bernhardwenzel.com/articles/using-clojure-with-aws-lambda/

the json for the policy is as shown:

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "",
      "Effect": "Allow",
      "Principal": {
        "Service": "lambda.amazonaws.com"
      },
      "Action": "sts:AssumeRole"
    }
  ]
}

but when I run

aws iam create-role \
--role-name basic_lambda_role \
--assume-role-policy-document fileb://resources/trust_relationship.json

I get

An error occurred (MalformedPolicyDocument) when calling the CreateRole operation: This policy contains invalid Json

Not sure what the problem is here. I tried fixing the file path or removing the b but I can't seem to figure it out.

Upvotes: 2

Views: 318

Answers (1)

Marcin
Marcin

Reputation: 238131

Your policy is fine.

I think the error comes from fileb which should be used for binary data, such as UserData in ec2.

The following form should be used (use file, not fileb):

aws iam create-role \
   --role-name basic_lambda_role \
   --assume-role-policy-document file://resources/trust_relationship.json

Upvotes: 0

Related Questions