Terraform v0.11.11
Initial Configuration
provider "aws" {
region = "us-east-2"
}
resource "aws_ssm_document" "my_test_ssm_doc" {
name = "My_Test_SSM_Doc_11111"
document_type = "Command"
document_format = "JSON"
content = "${file("mydoc.json")}"
}
resource "aws_ssm_association" "my_test_ssm_assoc" {
name = "${aws_ssm_document.my_test_ssm_doc.name}"
schedule_expression = "rate(1 day)"
targets {
key = "InstanceIds"
values = ["i-0f460c650dc13674d"]
}
depends_on = ["aws_ssm_document.my_test_ssm_doc"]
}
Updated Configuration
provider "aws" {
region = "us-east-2"
}
resource "aws_ssm_document" "my_test_ssm_doc" {
name = "My_Test_SSM_Doc_22222"
document_type = "Command"
document_format = "JSON"
content = "${file("mydoc.json")}"
}
resource "aws_ssm_association" "my_test_ssm_assoc" {
name = "${aws_ssm_document.my_test_ssm_doc.name}"
schedule_expression = "rate(1 day)"
targets {
key = "InstanceIds"
values = ["i-0f460c650dc13674d"]
}
depends_on = ["aws_ssm_document.my_test_ssm_doc"]
}
Changing the name used for the aws_ssm_document resource should result into a resource replacement (destroy, add) as opposed to an update.
Plan
An execution plan has been generated and is shown below.
Resource actions are indicated with the following symbols:
~ update in-place
-/+ destroy and then create replacement
Terraform will perform the following actions:
-/+ aws_ssm_association.my_test_ssm_assoc (new resource required)
id: "6e3bb30f-3b69-4164-8545-02de400d1385" => <computed> (forces new resource)
association_id: "6e3bb30f-3b69-4164-8545-02de400d1385" => <computed>
document_version: "$DEFAULT" => <computed>
name: "My_Test_SSM_Doc_111111" => "My_Test_SSM_Doc_222222" (forces new resource)
parameters.%: "0" => <computed>
schedule_expression: "rate(1 day)" => "rate(1 day)"
targets.#: "1" => "1"
targets.0.key: "InstanceIds" => "InstanceIds"
targets.0.values.#: "1" => "1"
targets.0.values.0: "i-0f460c650dc13674d" => "i-0f460c650dc13674d"
~ aws_ssm_document.my_test_ssm_doc
name: "My_Test_SSM_Doc_111111" => "My_Test_SSM_Doc_222222"
Plan: 1 to add, 1 to change, 1 to destroy.
Error on Apply
Error: Error applying plan:
1 error(s) occurred:
* aws_ssm_association.my_test_ssm_assoc: 1 error(s) occurred:
* aws_ssm_association.my_test_ssm_assoc: Error creating SSM association: InvalidDocument: Document with name My_Test_SSM_Doc_222222 does not exist.
status code: 400, request id: b7828b79-711d-40bb-8b23-8bebf84e00c2
Terraform does not automatically rollback in the face of errors.
Instead, your Terraform state file has been partially updated with
any resources that successfully completed. Please address the error
above and apply again to incrementally change your infrastructure.
name for aws_ssm_document resource to a SSM document name that has not been previously used in the AWS account before (e.g. "Updated Configuration" above)aws_ssm_document name is updated to a name which has not been used before.Is there any news on this bug?
I am encountering the very same issue.
Any work-arounds would also be helpful.
Most helpful comment
Is there any news on this bug?
I am encountering the very same issue.
Any work-arounds would also be helpful.