Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AWS Policy must contain valid version string

I am getting error "This policy contains the following error: The policy must contain a valid version string For more information about the IAM policy grammar" even i included version in my policy when trying to create a new policy in AWS. My policy is

{   "Version": "2015-06-19",   "Statement": [     {       "Effect": "Allow",       "Action": "s3:*",       "Resource": [         "arn:aws:s3:::repo.com",         "arn:aws:s3:::repo.com/*"       ]     }   ] } 
like image 988
Raghavendra Avatar asked Dec 22 '16 20:12

Raghavendra


People also ask

What is AWS policy version?

The Version policy element is used within a policy and defines the version of the policy language. A policy version, on the other hand, is created when you make changes to a customer managed policy in IAM. The changed policy doesn't overwrite the existing policy.

What is version in S3 bucket policy?

Versioning in Amazon S3 is a means of keeping multiple variants of an object in the same bucket. You can use the S3 Versioning feature to preserve, retrieve, and restore every version of every object stored in your buckets.

How do I write a policy in AWS?

To create your own IAM policySign in to the AWS Management Console and open the IAM console at https://console.aws.amazon.com/iam/ . Choose Policies, and then choose Create Policy. If a Get Started button appears, choose it, and then choose Create Policy. Next to Create Your Own Policy, choose Select.


2 Answers

It seems like Version is not the version of the policy that I am going to create but a set version number by AWS.

As stated by AWS documentation, version can be:

( version_block = "Version" : ("2008-10-17" | "2012-10-17") 

So, I changed it to 2012-10-17 and the policy is accepted.

like image 130
Raghavendra Avatar answered Sep 19 '22 07:09

Raghavendra


According to https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_elements.html#Version:

“The Version element must appear before the Statement element. The only allowed values are these:

  • 2012-10-17. This is the current version of the policy language, and you should use this version number for all policies.
  • 2008-10-17. This was an earlier version of the policy language. You might see this version on existing policies. Do not use this version for any new policies or any existing policies that you are updating.”
like image 32
Dave Land Avatar answered Sep 20 '22 07:09

Dave Land