I am trying to create IAM Role in AWS, but while I am creating I am facing error
"We encountered the following errors while processing your request: Problem in attaching permission to role. Role will be created without permission. The policy failed legacy parsing "
{"Version": "2012-10-17", "Statement": [
{
"Effect": "Allow",
"Action": [
"logs:CreateLogGroup",
"logs:CreateLogStream",
"logs:PutLogEvents"
],
"Resource": "arn:aws:logs:*:*:*"
},
{
"Action": [
"sqs:SendMessage",
"sqs:GetQueueUrl"
],
"Effect": "Allow",
"Resource": "arn:aws:sqs:ap-northeast-1:SOME_ID_HERE:test-messages"
}]}
I got this error, and couldn't figure it out. A colleague and I poured over it, and then we spotted that I had left a substitution variable without the Fn::Sub
, e.g.
"Resource": "arn:aws:logs::${AWS::AccountId}:*
will cause this error, and of course should be
"Resource": { "Fn::Sub": "arn:aws:logs::${AWS::AccountId}:*" }
BTW, in my experience, I agree with E.J. Brennan above, you cannot use a wildcard for region, instead leave it blank as I did there.
If it fails for s3, ensure that you are using the correct arn format:
Correct one is 3 ::: arn:aws:s3:::AccountABucketName
"Resource": "arn:aws:s3:::AccountABucketName"
Wrong one 2 :: arn:aws:s3::AccountABucketName
"Resource": "arn:aws:s3::AccountABucketName"
Count the number of colons between s3
and AccountABucketName
If you are using serverless
you can indicate that you want variables substitution by prefixing the resource with !Sub
:
Resource:
- !Sub arn:aws:dynamodb:*:${AWS::AccountId}:table/${self:provider.environment.DYNAMODB_TABLE}
No plugin required (if serverless version is recent).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With