-
Notifications
You must be signed in to change notification settings - Fork 9.6k
smarterr CloudWatch Integration: Declarative, Config-Driven Error Handling #43121
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
Conversation
Community GuidelinesThis comment is added to every new Pull Request to provide quick reference to how the Terraform AWS Provider is maintained. Please review the information below, and thank you for contributing to the community that keeps the provider thriving! 🚀 Voting for Prioritization
Pull Request Authors
|
|
Yes, excellent idea. Also, I got the |
Hi @YakDriver, nice work! 👍🏽 Question from my side: while reading it the suggestion was given that the original AWS API error message is not (completely) shown anymore. I understand that, but at the same time that gave me (as someone who knows a bit in general what is going on under the hood) insights on what the exact issue might be. Can you elaborate a bit on that? Is it just me interpreting it in a (wrong) way or are is the plan indeed to shield details from end users? I really love the continuous improvements coming our way! ❤️ |
Thank you for your interest! Let me try to clarify and then let us know if you have feedback. More information and more consistent information will be output to logs. For end-user visible errors, more relevant and more consistent information will be output with some irrelevant information stripped. All stripped information will still be in the logs. Some information is shifted around. This aims to aligns us with best practices in the industry and Terraform's own standards. Here's a mock-up example to show the differences. Before
AfterUser-facing (brief error summary, removal of
Log (includes
|
Thanks, that looks good! Filtering makes sense for the mentioned items, readability wise it's definitely an improvement. LGTM 🙃 |
Recent changes:
% make smoke
make: Sane Smoke Tests (x tests of Top y resources)
make: Like 'sanity' except full output and stops soon after 1st error
make: NOTE: NOT an exhaustive set of tests! Finds big problems only.
2025/06/30 12:55:09 Creating Terraform AWS Provider (SDKv2-style)...
2025/06/30 12:55:09 Initializing Terraform AWS Provider (SDKv2-style)...
=== RUN TestAccIAMInstanceProfile_tags
=== PAUSE TestAccIAMInstanceProfile_tags
=== RUN TestAccIAMInstanceProfile_basic
=== PAUSE TestAccIAMInstanceProfile_basic
=== RUN TestAccIAMPolicyDocumentDataSource_basic
=== PAUSE TestAccIAMPolicyDocumentDataSource_basic
=== RUN TestAccIAMPolicyDocumentDataSource_sourceConflicting
=== PAUSE TestAccIAMPolicyDocumentDataSource_sourceConflicting
=== RUN TestAccIAMPolicy_tags
=== PAUSE TestAccIAMPolicy_tags
=== RUN TestAccIAMPolicy_basic
=== PAUSE TestAccIAMPolicy_basic
=== RUN TestAccIAMPolicy_policy
=== PAUSE TestAccIAMPolicy_policy
=== RUN TestAccIAMRolePolicyAttachment_basic
=== PAUSE TestAccIAMRolePolicyAttachment_basic
=== RUN TestAccIAMRolePolicyAttachment_disappears
=== PAUSE TestAccIAMRolePolicyAttachment_disappears
=== RUN TestAccIAMRolePolicyAttachment_Disappears_role
=== PAUSE TestAccIAMRolePolicyAttachment_Disappears_role
=== RUN TestAccIAMRolePolicy_basic
=== PAUSE TestAccIAMRolePolicy_basic
=== RUN TestAccIAMRolePolicy_unknownsInPolicy
=== PAUSE TestAccIAMRolePolicy_unknownsInPolicy
=== RUN TestAccIAMRole_basic
=== PAUSE TestAccIAMRole_basic
=== RUN TestAccIAMRole_namePrefix
=== PAUSE TestAccIAMRole_namePrefix
=== RUN TestAccIAMRole_disappears
=== PAUSE TestAccIAMRole_disappears
=== RUN TestAccIAMRole_InlinePolicy_basic
=== PAUSE TestAccIAMRole_InlinePolicy_basic
=== CONT TestAccIAMInstanceProfile_tags
=== CONT TestAccIAMRolePolicyAttachment_disappears
=== CONT TestAccIAMRole_basic
=== CONT TestAccIAMRole_InlinePolicy_basic
=== CONT TestAccIAMRolePolicy_basic
=== CONT TestAccIAMInstanceProfile_basic
=== CONT TestAccIAMRolePolicy_unknownsInPolicy
=== CONT TestAccIAMRolePolicyAttachment_Disappears_role
=== CONT TestAccIAMRole_disappears
=== CONT TestAccIAMPolicy_tags
=== CONT TestAccIAMPolicyDocumentDataSource_basic
=== CONT TestAccIAMRolePolicyAttachment_basic
=== CONT TestAccIAMPolicy_policy
=== CONT TestAccIAMPolicyDocumentDataSource_sourceConflicting
=== CONT TestAccIAMPolicy_basic
=== CONT TestAccIAMRole_namePrefix
--- PASS: TestAccIAMPolicyDocumentDataSource_basic (14.41s)
--- PASS: TestAccIAMPolicyDocumentDataSource_sourceConflicting (14.44s)
--- PASS: TestAccIAMRolePolicyAttachment_Disappears_role (19.10s)
--- PASS: TestAccIAMRole_disappears (19.24s)
--- PASS: TestAccIAMRolePolicyAttachment_disappears (19.79s)
--- PASS: TestAccIAMPolicy_basic (20.81s)
--- PASS: TestAccIAMRole_namePrefix (21.20s)
--- PASS: TestAccIAMRole_basic (21.26s)
--- PASS: TestAccIAMRolePolicy_basic (21.41s)
--- PASS: TestAccIAMRolePolicy_unknownsInPolicy (22.47s)
--- PASS: TestAccIAMInstanceProfile_basic (26.06s)
--- PASS: TestAccIAMPolicy_policy (29.49s)
--- PASS: TestAccIAMRolePolicyAttachment_basic (30.47s)
--- PASS: TestAccIAMRole_InlinePolicy_basic (37.20s)
--- PASS: TestAccIAMPolicy_tags (57.09s)
--- PASS: TestAccIAMInstanceProfile_tags (78.65s)
PASS
ok github.com/hashicorp/terraform-provider-aws/internal/service/iam 83.629s
2025/06/30 12:56:53 Creating Terraform AWS Provider (SDKv2-style)...
2025/06/30 12:56:53 Initializing Terraform AWS Provider (SDKv2-style)...
=== RUN TestAccLogsGroup_basic
=== PAUSE TestAccLogsGroup_basic
=== RUN TestAccLogsGroup_multiple
=== PAUSE TestAccLogsGroup_multiple
=== CONT TestAccLogsGroup_basic
=== CONT TestAccLogsGroup_multiple
--- PASS: TestAccLogsGroup_multiple (13.77s)
--- PASS: TestAccLogsGroup_basic (17.16s)
PASS
ok github.com/hashicorp/terraform-provider-aws/internal/service/logs 22.143s
2025/06/30 12:57:10 Creating Terraform AWS Provider (SDKv2-style)...
2025/06/30 12:57:10 Initializing Terraform AWS Provider (SDKv2-style)...
=== RUN TestAccVPCDataSource_basic
=== PAUSE TestAccVPCDataSource_basic
=== RUN TestAccVPCRouteTableAssociation_Subnet_basic
=== PAUSE TestAccVPCRouteTableAssociation_Subnet_basic
=== RUN TestAccVPCRouteTable_basic
=== PAUSE TestAccVPCRouteTable_basic
=== RUN TestAccVPCSecurityGroupRule_race
=== PAUSE TestAccVPCSecurityGroupRule_race
=== RUN TestAccVPCSecurityGroupRule_protocolChange
=== PAUSE TestAccVPCSecurityGroupRule_protocolChange
=== RUN TestAccVPCSecurityGroup_basic
=== PAUSE TestAccVPCSecurityGroup_basic
=== RUN TestAccVPCSecurityGroup_egressMode
=== PAUSE TestAccVPCSecurityGroup_egressMode
=== RUN TestAccVPCSecurityGroup_vpcAllEgress
=== PAUSE TestAccVPCSecurityGroup_vpcAllEgress
=== RUN TestAccVPCSubnet_basic
=== PAUSE TestAccVPCSubnet_basic
=== RUN TestAccVPC_tenancy
=== PAUSE TestAccVPC_tenancy
=== CONT TestAccVPCDataSource_basic
=== CONT TestAccVPCSecurityGroup_basic
=== CONT TestAccVPCRouteTable_basic
=== CONT TestAccVPCRouteTableAssociation_Subnet_basic
=== CONT TestAccVPC_tenancy
=== CONT TestAccVPCSecurityGroup_vpcAllEgress
=== CONT TestAccVPCSecurityGroupRule_race
=== CONT TestAccVPCSecurityGroupRule_protocolChange
=== CONT TestAccVPCSecurityGroup_egressMode
=== CONT TestAccVPCSubnet_basic
--- PASS: TestAccVPCSubnet_basic (21.09s)
--- PASS: TestAccVPCRouteTable_basic (21.11s)
--- PASS: TestAccVPCSecurityGroup_basic (23.03s)
--- PASS: TestAccVPCSecurityGroup_vpcAllEgress (24.28s)
--- PASS: TestAccVPCRouteTableAssociation_Subnet_basic (24.71s)
--- PASS: TestAccVPCDataSource_basic (29.48s)
--- PASS: TestAccVPCSecurityGroup_egressMode (43.93s)
--- PASS: TestAccVPC_tenancy (48.30s)
--- PASS: TestAccVPCSecurityGroupRule_protocolChange (52.29s)
--- PASS: TestAccVPCSecurityGroupRule_race (167.83s)
PASS
ok github.com/hashicorp/terraform-provider-aws/internal/service/ec2 183.244s
2025/06/30 12:57:00 Creating Terraform AWS Provider (SDKv2-style)...
2025/06/30 12:57:00 Initializing Terraform AWS Provider (SDKv2-style)...
=== RUN TestAccECSService_basic
=== PAUSE TestAccECSService_basic
=== RUN TestAccECSTaskDefinition_basic
=== PAUSE TestAccECSTaskDefinition_basic
=== CONT TestAccECSService_basic
=== CONT TestAccECSTaskDefinition_basic
--- PASS: TestAccECSTaskDefinition_basic (24.87s)
--- PASS: TestAccECSService_basic (73.92s)
PASS
ok github.com/hashicorp/terraform-provider-aws/internal/service/ecs 78.916s
2025/06/30 12:57:04 Creating Terraform AWS Provider (SDKv2-style)...
2025/06/30 12:57:04 Initializing Terraform AWS Provider (SDKv2-style)...
=== RUN TestAccELBV2TargetGroup_basic
=== PAUSE TestAccELBV2TargetGroup_basic
=== CONT TestAccELBV2TargetGroup_basic
--- PASS: TestAccELBV2TargetGroup_basic (21.74s)
PASS
ok github.com/hashicorp/terraform-provider-aws/internal/service/elbv2 30.151s
2025/06/30 12:57:07 Creating Terraform AWS Provider (SDKv2-style)...
2025/06/30 12:57:07 Initializing Terraform AWS Provider (SDKv2-style)...
=== RUN TestAccKMSKey_basic
=== PAUSE TestAccKMSKey_basic
=== CONT TestAccKMSKey_basic
--- PASS: TestAccKMSKey_basic (29.53s)
PASS
ok github.com/hashicorp/terraform-provider-aws/internal/service/kms 41.304s
2025/06/30 13:00:19 Creating Terraform AWS Provider (SDKv2-style)...
2025/06/30 13:00:19 Initializing Terraform AWS Provider (SDKv2-style)...
=== RUN TestAccLambdaFunction_basic
=== PAUSE TestAccLambdaFunction_basic
=== RUN TestAccLambdaPermission_basic
=== PAUSE TestAccLambdaPermission_basic
=== CONT TestAccLambdaFunction_basic
=== CONT TestAccLambdaPermission_basic
--- PASS: TestAccLambdaPermission_basic (31.78s)
--- PASS: TestAccLambdaFunction_basic (41.95s)
PASS
ok github.com/hashicorp/terraform-provider-aws/internal/service/lambda 47.026s
2025/06/30 13:00:22 Creating Terraform AWS Provider (SDKv2-style)...
2025/06/30 13:00:22 Initializing Terraform AWS Provider (SDKv2-style)...
=== RUN TestAccMetaPartitionDataSource_basic
=== PAUSE TestAccMetaPartitionDataSource_basic
=== RUN TestAccMetaRegionDataSource_basic
=== PAUSE TestAccMetaRegionDataSource_basic
=== RUN TestAccMetaRegionDataSource_endpoint
=== PAUSE TestAccMetaRegionDataSource_endpoint
=== CONT TestAccMetaPartitionDataSource_basic
=== CONT TestAccMetaRegionDataSource_endpoint
=== CONT TestAccMetaRegionDataSource_basic
--- PASS: TestAccMetaPartitionDataSource_basic (11.72s)
--- PASS: TestAccMetaRegionDataSource_endpoint (11.78s)
--- PASS: TestAccMetaRegionDataSource_basic (12.34s)
PASS
ok github.com/hashicorp/terraform-provider-aws/internal/service/meta 20.337s
2025/06/30 13:00:25 Creating Terraform AWS Provider (SDKv2-style)...
2025/06/30 13:00:25 Initializing Terraform AWS Provider (SDKv2-style)...
=== RUN TestAccRoute53Record_basic
=== PAUSE TestAccRoute53Record_basic
=== RUN TestAccRoute53Record_Latency_basic
=== PAUSE TestAccRoute53Record_Latency_basic
=== RUN TestAccRoute53ZoneDataSource_name
=== PAUSE TestAccRoute53ZoneDataSource_name
=== CONT TestAccRoute53Record_basic
=== CONT TestAccRoute53ZoneDataSource_name
=== CONT TestAccRoute53Record_Latency_basic
--- PASS: TestAccRoute53ZoneDataSource_name (73.76s)
--- PASS: TestAccRoute53Record_basic (138.62s)
--- PASS: TestAccRoute53Record_Latency_basic (140.88s)
PASS
ok github.com/hashicorp/terraform-provider-aws/internal/service/route53 151.685s
2025/06/30 13:00:29 Creating Terraform AWS Provider (SDKv2-style)...
2025/06/30 13:00:29 Initializing Terraform AWS Provider (SDKv2-style)...
=== RUN TestAccS3BucketACL_updateACL
=== PAUSE TestAccS3BucketACL_updateACL
=== RUN TestAccS3BucketPolicy_basic
=== PAUSE TestAccS3BucketPolicy_basic
=== RUN TestAccS3BucketPublicAccessBlock_basic
=== PAUSE TestAccS3BucketPublicAccessBlock_basic
=== RUN TestAccS3Bucket_Basic_basic
=== PAUSE TestAccS3Bucket_Basic_basic
=== RUN TestAccS3Bucket_Security_corsUpdate
=== PAUSE TestAccS3Bucket_Security_corsUpdate
=== RUN TestAccS3Object_basic
=== PAUSE TestAccS3Object_basic
=== CONT TestAccS3Bucket_Security_corsUpdate
=== CONT TestAccS3BucketPublicAccessBlock_basic
=== CONT TestAccS3Object_basic
=== CONT TestAccS3Bucket_Basic_basic
=== CONT TestAccS3BucketPolicy_basic
=== CONT TestAccS3BucketACL_updateACL
--- PASS: TestAccS3BucketPolicy_basic (22.29s)
--- PASS: TestAccS3Bucket_Basic_basic (23.00s)
--- PASS: TestAccS3BucketPublicAccessBlock_basic (23.29s)
--- PASS: TestAccS3Object_basic (24.50s)
--- PASS: TestAccS3BucketACL_updateACL (35.49s)
--- PASS: TestAccS3Bucket_Security_corsUpdate (37.67s)
PASS
ok github.com/hashicorp/terraform-provider-aws/internal/service/s3 49.511s
2025/06/30 13:00:32 Creating Terraform AWS Provider (SDKv2-style)...
2025/06/30 13:00:32 Initializing Terraform AWS Provider (SDKv2-style)...
=== RUN TestAccSSMParameterEphemeral_basic
=== PAUSE TestAccSSMParameterEphemeral_basic
=== CONT TestAccSSMParameterEphemeral_basic
--- PASS: TestAccSSMParameterEphemeral_basic (14.93s)
PASS
ok github.com/hashicorp/terraform-provider-aws/internal/service/ssm 30.133s
2025/06/30 13:00:36 Creating Terraform AWS Provider (SDKv2-style)...
2025/06/30 13:00:36 Initializing Terraform AWS Provider (SDKv2-style)...
=== RUN TestAccSecretsManagerSecret_basic
=== PAUSE TestAccSecretsManagerSecret_basic
=== CONT TestAccSecretsManagerSecret_basic
--- PASS: TestAccSecretsManagerSecret_basic (16.02s)
PASS
ok github.com/hashicorp/terraform-provider-aws/internal/service/secretsmanager 34.599s
2025/06/30 13:00:39 Creating Terraform AWS Provider (SDKv2-style)...
2025/06/30 13:00:39 Initializing Terraform AWS Provider (SDKv2-style)...
=== RUN TestAccSTSCallerIdentityDataSource_basic
=== PAUSE TestAccSTSCallerIdentityDataSource_basic
=== CONT TestAccSTSCallerIdentityDataSource_basic
--- PASS: TestAccSTSCallerIdentityDataSource_basic (8.66s)
PASS
ok github.com/hashicorp/terraform-provider-aws/internal/service/sts 30.545s |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 🚀
Warning This Issue has been closed, meaning that any additional comments are much easier for the maintainers to miss. Please assume that the maintainers will not see them. Ongoing conversations amongst community members are welcome, however, the issue will be locked after 30 days. Moving conversations to another venue, such as the AWS Provider forum, is recommended. If you have additional concerns, please open a new issue, referencing this one where needed. |
This functionality has been released in v6.4.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! |
Rollback Plan
If a change needs to be reverted, we will publish an updated version of the library.
Changes to Security Controls
Are there any changes to security controls (access controls, encryption, logging) in this pull request? If so, explain.
Description
This PR begins integration of smarterr into the Terraform AWS Provider, starting with CloudWatch, establishing a new foundation for standardized, maintainable, and user-focused error diagnostics.
Why smarterr?
Our current error handling is spread across ~15,000 call sites, many of which manually format error messages. This leads to:
With
smarterr
, we move toward a config-driven model where error formatting—summary, detail, and logs—is handled centrally and declaratively.PR To Do
What this enables
User experience
This is a template-driven error formatted by smarterr. And we can change it as needs change by just updating declarative config.
Integration Pattern
The integration pattern uses the
smerr
package (a thin wrapper around smarterr) for idiomatic use in this codebase. Example SDK-style usage:And wrapped errors in helpers:
What’s in this PR
Note: smarterr is mostly focused on diag.Diagnostics generation. However, it also wraps Go errors to gather information. Wrapping errors with
smarterr.NewError
is fully safe and transparent—*smarterr.Error
implementserror
andUnwrap()
, so tools likeerrors.Is
anderrors.As
continue to work as expected, while smarterr-aware functions (e.g.smerr.Append
) can extract structured context when needed.smarterr
as a module dependencysmerr
wrapper for resource/service context injectiontags_gen.go
across servicesNext Steps
🔗 For more details on the
smarterr
project, see smarterr.This integration lays the groundwork for long-term improvements to developer ergonomics and user diagnostics.
Relations
Closes #0000
References
Output from Acceptance Testing