-
Notifications
You must be signed in to change notification settings - Fork 9.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
aws_ecr_lifecycle_policy creation does not allow variable assignment to countNumber parameter #3002
Comments
Hi @proj4spes! Does it work if you modify your policy to be (note removal of quotes): "countNumber": ${var.number} |
Thanks , anyway I believed that "$t..." were the only way to interpolate and the string to int would be automatically done ...(as in other cases ..) OK it runs as it would,, |
The lines between the We can likely improve the documentation here a little bit to explain this better in: https://www.terraform.io/docs/configuration/syntax.html |
Closing as this appears to be resolved. |
I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues. If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks! |
aws_ecr_lifecycle_policy does not allow variable assignment to countNumber parameter.
here it is the code
variable "number" {
description = "a number"
default = 10
}
resource "aws_ecr_repository" "foo" {
name = "bar"
}
resource "aws_ecr_lifecycle_policy" "foopolicy" {
repository = "${aws_ecr_repository.foo.name}"
policy = <<EOF
{
"rules": [
{
"rulePriority": 1,
"description": "Expire images older than 14 days",
"selection": {
"tagStatus": "untagged",
"countType": "sinceImagePushed",
"countUnit": "days",
"countNumber": "${var.number}"
},
"action": {
"type": "expire"
}
}
]
}
EOF
}
THIS is THE RESULT
1 error(s) occurred:
aws_ecr_lifecycle_policy.foopolicy: 1 error(s) occurred:
aws_ecr_lifecycle_policy.foopolicy: InvalidParameterException: Invalid parameter at 'LifecyclePolicyText' failed to satisfy constraint: 'Lifecycle policy valiation failure: instance type (string) does not match any allowed primitive type (allowed: ["integer"])
'
status code: 400, request id: 5042a1bc-fa93-11e7-b3cc-c9977d1470fa
and here there is the trace showing that CountNumber is treated as a string
policy: "" => "{\n "rules": [\n {\n "rulePriority": 1,\n "description": "Expire images older than 14 days",\n "selection": {\n "tagStatus": "untagged",\n "countType": "sinceImagePushed",\n "countUnit": "days",\n "countNumber": "10"\n },\n "action": {\n "type": "expire"\n }\n }\n ]\n}\n"
registry_id: "" => ""
repository: "" => "bar"
The text was updated successfully, but these errors were encountered: