[Feature] Add force_destroy argument to aws_cloudwatch_log_group resource #44680
+119
−3
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Adds the
force_destroyargument to theaws_cloudwatch_log_groupresource to enable reliable deletion of log groups with retention policies.When
force_destroy = true, the resource will:ResourceAlreadyExistsExceptionerrors on immediate re-creationThis enhancement addresses issues in CI/CD pipelines and ephemeral environments where log groups need to be reliably deleted and recreated.
Closes
Closes #44676
New and Affected Resources
aws_cloudwatch_log_groupOutput from Acceptance Testing
Note: Full acceptance tests require AWS credentials. Manual testing results provided below.
Manual Testing Results
Schema Recognition Test
Before Implementation:
After Implementation:
Resource Lifecycle Test
force_destroy = trueforce_destroy = trueResourceAlreadyExistsExceptionBackward Compatibility Test
Default behavior unchanged when
force_destroyis not specified (defaults tofalse).Features
New Argument:
force_destroybooltruefalseBehavior Matrix
force_destroy = false(default)force_destroy = trueResourceAlreadyExistsExceptionExample Usage
Basic Usage
With Retention Policy
CI/CD Pipeline Usage
Implementation Details
Schema Changes
Enhanced Deletion Logic
force_destroy = true, removes retention policies before deletionwaitLogGroupDeleted()to ensure complete deletionResourceNotFoundExceptionduring deletionforce_destroy = trueKey Code Changes
Files Changed
Testing Strategy
Acceptance Tests
TestAccLogsLogGroup_forceDestroy: Verifies force_destroy attribute functionalityManual Testing Coverage
Related Patterns
This implementation follows the same pattern as other AWS resources with
force_destroyfunctionality:aws_s3_bucketaws_iam_roleaws_kms_keyPerformance Considerations
force_destroy = false)Backward Compatibility
falsemaintains existing behaviorforce_destroy = trueNotes for Reviewers
force_destroyconventions in the codebaseAdditional Context
Problem Solved
Use Cases