0.9.11
variable "configs" {
description = "Key/value pairs to create in the SSM Parameter Store"
type = "map"
}
variable "prefix" {
description = "Prefix to apply to all key names"
}
variable "kms_key_id" {
description = "ID of KMS key to use to encrypt values"
}
resource "aws_ssm_parameter" "configs" {
count = "${length(keys(var.configs))}"
name = "/${var.prefix}/${element(keys(var.configs),count.index)}"
type = "SecureString"
value = "${element(values(var.configs),count.index)}"
key_id = "${var.kms_key_id}"
}
https://gist.github.com/OliverCole/a1c5a804723765f8666f29eb337d9c53#file-terraform_debug_part2-log-pgp
Applied.
1 error(s) occurred:
* module.parameters.aws_ssm_parameter.configs[6]: 1 error(s) occurred:
* aws_ssm_parameter.configs.6: [ERROR] Error creating SSM parameter: TooManyUpdates:
status code: 400, request id: b6413f77-6342-11e7-8973-73b31b7eb4d4
Subsequent apply works fine.
terraform applyIs this a bug due to too many sequential updates to the same SSM parameter; not a rate-limit from the API?
This is super annoying. If you do a 2nd apply it may complete but if you have enough params it could take several applies. This seems to happen anytime you change the size of the map you are using also which re-arranges the list terraform generates to loop over causing it to delete/recreate all the params.
You get this error when you attempt to create/modify the same SSM parameter multiple times at once.
The SSM parameters don't support concurrent updates.
This usually happens when you have more than one definition for the same parameter in Terraform. It's easy to duplicate definitions when you have many of them. Be careful to avoid duplicates and you'll be free from this error.
As a workaround just run terraform apply a second time and if needed more often. It will each time update some parameters eventually getting through all of them.
If you have many parameters adding or removing one in a list can cause Terraform to update all subsequent parameters in the list. To avoid this, use for_each in favor of count. Then removing one parameter really just updates one resource without touching the other parameters (for a detailed explanation see e.g. http://jaydba.blogspot.com/2020/03/terraform-count-vs-foreach.html).