amazon-web-servicesterraformterraform-aws-modules

Defining new policy with Terraform on AWS, but gets error in Version


I'm trying to create a new policy in the AWS by Terraform.
But I'm getting errors when I want to put Version equal to today's date, something like "Version": "2022-03-06".
Why is this happening? (It worked fine with this date: "Version": "2012-12-17").
main.tf:

resource "aws_iam_policy" "adminUsers" {
  name = "AdminUsers"
  policy = file("admin-policy.json")
}

admin-policy.json

{
  "Version": "2022-03-06",
  "Statement": [
    {
      "Effect": "Allow",
      "Action": "*",
      "Resource": "*"
    }
  ]
}

Solution

  • https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_elements_version.html

    You can check in the URL above. It's like the version of the policy and at this time, there are 2 versions: 2012-10-17 and 2008-10-17.

    To note the version of Policy, you can use Sid instead