Closed pbzdyl closed 2 years ago
@pbzdyl Thanks for raising this issue. How long is Terraform waiting for during resource creation before you get this error?
Hi @ewbankkit!
aws_synthetics_canary.mycanary: Still creating... [2m0s elapsed]
Error: error waiting for Synthetics Canary (mycanary) create: unexpected state 'ERROR', wanted target 'READY'. last error: CREATE_FAILED: The role defined for the function cannot be assumed by Lambda. (Service: AWSLambda; Status Code: 400; Error Code: InvalidParameterValueException; Request ID: 608c687b-6322-407e-97c3-4763456dfb82; Proxy: null)
I noticed that AWS creates the canary but it goes into the ERROR state. Shouldn't Terraform in this case delete the faulty canary and try to create it again?
We see similar errors in CI:
=== RUN TestAccSyntheticsCanary_basic
=== PAUSE TestAccSyntheticsCanary_basic
=== CONT TestAccSyntheticsCanary_basic
canary_test.go:27: Step 1/3 error: Error running apply: exit status 1
Error: error waiting for Synthetics Canary (tf-acc-test-2abpyxia) create: unexpected state 'ERROR', wanted target 'READY'. last error: CREATE_FAILED: The role defined for the function cannot be assumed by Lambda. (Service: AWSLambda; Status Code: 400; Error Code: InvalidParameterValueException; Request ID: baeae60d-b055-41da-bcee-0b78a8dc51af; Proxy: null)
on terraform_plugin_test.tf line 92, in resource "aws_synthetics_canary" "test":
92: resource "aws_synthetics_canary" "test" {
--- FAIL: TestAccSyntheticsCanary_basic (140.12s)
We need to investigate upping the 2m wait time for IAM role propagation.
This functionality has been released in v3.65.0 of the Terraform AWS Provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.
For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you!
I noticed it waits for 4 minutes while creating the canary, but I still got this bug. My workaround is to make it wait for 5 minutes:
resource "time_sleep" "wait_5_minutes" {
depends_on = [resource.aws_iam_role.main]
create_duration = "5m"
}
and in the canary:
depends_on = [time_sleep.wait_5_minutes]
Still running into this on the latest AWS provider hashicorp/aws v3.71.0
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 have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.
Community Note
Terraform CLI and Terraform AWS Provider Version
Terraform v0.14.7 Terraform AWS Provider 3.63.0
Affected Resource(s)
Terraform Configuration Files
Expected Behavior
aws_synthetics_canary
created successfully.Actual Behavior
terraform apply
fails with:Then I have to manually delete Synthetics Canary resource in AWS (as it is left in an Error state) and run
terraform plan && terraform apply
again to get the canary created.References
I found https://github.com/hashicorp/terraform-provider-aws/issues/18101 but it seems it doesn't work/help with my issue.