Solve - The policy must Contain a valid Version String

avatar

Borislav Hadzhiev

Tue Sep 28 20212 min read

banner

Photo by Jeffrey Lee

Solve - The policy must Contain a valid Version String #

To solve the AWS Error "The policy must Contain a valid Version String" we have to set the version element of the IAM policy to 2012-10-17. The version element defines the version of the policy language, that AWS uses to interpret the contents of your IAM policy.

For example, the following IAM policy sets the Version element to the latest version of the policy language - 2012-10-17.

example-iam-policy.json
{ "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": [ "s3:Get*" ], "Resource": "*" } ] }
Note that you should specify the Version element in the first row of the IAM policy.

There are only 2 possible values for the Version element in an IAM policy:

  1. 2012-10-17 - the latest version of the policy language, which should always be used when creating policies. It enables us to use policy variables, which are not implemented in the previous version

  2. 2008-10-17 - an earlier version of the policy language. You should never use this version when creating IAM policies, because it doesn't support all the features the newer version supports

Note that the Version element is not the version of the policy, rather it's the version of the policy language that AWS uses to interpret the IAM policy.

The version of the policy is created automatically by IAM every time you update a customer managed policy.

When you change a managed policy the old policy does not get overridden, rather a new version of the policy is created.

If you want to view the versions of a managed policy:

  1. open the IAM console
  2. click on policies and click on the name of the policy
  3. click on the Policy versions tab

policy versions

All of the previous versions of your IAM policy are preserved. To view any of them you can expand the specific version.

Further Reading #

Join my newsletter

I'll send you 1 email a week with links to all of the articles I've written that week

Buy Me A Coffee