-
Notifications
You must be signed in to change notification settings - Fork 9.2k
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_cloudwatch_log_stream resource produced new value for was present but now absent #11611
Comments
References: * hashicorp#11611 The AWS logs service has eventual consistency considerations. The `aws_cloudwatch_log_stream` resource immediately tries to read a stream after creation. If the stream is not found, the logs service returns a 200 OK with an empty list of streams. Since no streams are present, the `aws_cloudwatch_log_stream` resource removes the created resource from state, leading to a "produced an unexpected new value for was present, but now absent" error. With the changes in this commit, the empty list of streams in the response for the newly created resource will result in a NotFoundError being returned and a retry of the read request. A subsequent retry should hopefully be successful, leading to the state being preserved. Output from acceptance testing: ``` make testacc TEST=./aws TESTARGS='-run=TestAccAWSCloudWatchLogStream_' ... --- PASS: TestAccAWSCloudWatchLogStream_disappears_LogGroup (16.77s) --- PASS: TestAccAWSCloudWatchLogStream_disappears (19.55s) --- PASS: TestAccAWSCloudWatchLogStream_basic (19.91s) ```
References: * #11611 The AWS logs service has eventual consistency considerations. The `aws_cloudwatch_log_stream` resource immediately tries to read a stream after creation. If the stream is not found, the logs service returns a 200 OK with an empty list of streams. Since no streams are present, the `aws_cloudwatch_log_stream` resource removes the created resource from state, leading to a "produced an unexpected new value for was present, but now absent" error. With the changes in this commit, the empty list of streams in the response for the newly created resource will result in a NotFoundError being returned and a retry of the read request. A subsequent retry should hopefully be successful, leading to the state being preserved. Output from acceptance testing: ``` make testacc TEST=./aws TESTARGS='-run=TestAccAWSCloudWatchLogStream_' ... --- PASS: TestAccAWSCloudWatchLogStream_disappears_LogGroup (16.77s) --- PASS: TestAccAWSCloudWatchLogStream_disappears (19.55s) --- PASS: TestAccAWSCloudWatchLogStream_basic (19.91s) ```
The fix for this has been merged and will release with version 2.48.0 of the Terraform AWS Provider, tomorrow. Thanks to @camlow325 for the implementation. 👍 |
This has been released in version 2.48.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 for triage. Thanks! |
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! |
Community Note
Terraform Version
Affected Resource(s)
Terraform Configuration Files
Debug Output
Here's a snippet of the debug log when the error occurs. The problem appears to occur when AWS returns a 200 OK with an empty list of
logStreams
for the stream which has just been created. This may be due to an eventual consistency issue that could be overcome by retrying theDescribeLogStreams
call some number of times until the resource is available.Panic Output
Expected Behavior
The log stream resource should be created without any errors and the
terraform apply
should succeed.Actual Behavior
Most of the time, the expected behavior occurs. Intermittently, though, the log stream resource is created in AWS but the
terraform apply
fails with the following error:Subsequent
terraform apply
attempts fail with the following error:Steps to Reproduce
terraform apply
Important Factoids
References
aws_appautoscaling_policy
resource instead of anaws_cloudwatch_log_stream
one.The text was updated successfully, but these errors were encountered: