Skip to content

Commit b28c8be

Browse files
committed
Add new Terraform bug to TerraforomApplyWithRetry
Note that this bug assumes the terraform template’s “aws_eip” resource is called “nat”. This is actually preferable since other aws_eip resources may not be subject to this race condition.
1 parent 821586a commit b28c8be

2 files changed

Lines changed: 5 additions & 0 deletions

File tree

terraform/apply.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@ func ApplyAndGetOutputWithRetry(terraformPath string, vars map[string]string, lo
4242
if strings.Contains(output, TF_ERROR_DIFFS_DIDNT_MATCH_DURING_APPLY) {
4343
logger.Printf("Terraform apply failed with the error '%s'. %s\n", TF_ERROR_DIFFS_DIDNT_MATCH_DURING_APPLY, TF_ERROR_DIFFS_DIDNT_MATCH_DURING_APPLY_MSG)
4444
return ApplyAndGetOutput(terraformPath, vars, logger)
45+
else if strings.Contains(output, TF_ERROR_EIP_DOES_NOT_HAVE_ATTRIBUTE_ID) {
46+
logger.Printf("Terraform apply failed with the error '%s'. %s\n", TF_ERROR_EIP_DOES_NOT_HAVE_ATTRIBUTE_ID, TF_ERROR_EIP_DOES_NOT_HAVE_ATTRIBUTE_ID_MSG)
47+
return ApplyAndGetOutput(terraformPath, vars, logger)
4548
} else {
4649
return output, err
4750
}

terraform/constants.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,5 @@ package terraform
44
const TF_ERROR_DIFFS_DIDNT_MATCH_DURING_APPLY = "diffs didn't match during apply"
55
const TF_ERROR_DIFFS_DIDNT_MATCH_DURING_APPLY_MSG = "This usually indicates a minor Terraform timing bug (https://github.com/hashicorp/terraform/issues/5200) that goes away when you reapply. Retrying terraform apply."
66

7+
const TF_ERROR_EIP_DOES_NOT_HAVE_ATTRIBUTE_ID = "Resource 'aws_eip.nat' does not have attribute 'id' for variable 'aws_eip.nat.*.id'"
8+
const TF_ERROR_EIP_DOES_NOT_HAVE_ATTRIBUTE_ID_MSG = "This is a known AWS API eventual consistency issue. See https://github.com/hashicorp/terraform/issues/5335."

0 commit comments

Comments
 (0)