Skip to content
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

Add an option to forcibly delete EventBridge Rules #34905

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion internal/service/events/rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,10 @@ func ResourceRule() *schema.Resource {
"state",
},
},
"force": {
Type: schema.TypeBool,
Optional: true,
},
"name": {
Type: schema.TypeString,
Optional: true,
Expand Down Expand Up @@ -278,7 +282,8 @@ func resourceRuleDelete(ctx context.Context, d *schema.ResourceData, meta interf
}

input := &eventbridge.DeleteRuleInput{
Name: aws.String(ruleName),
Name: aws.String(ruleName),
Force: d.Get("force").(*bool),
}
if eventBusName != "" {
input.EventBusName = aws.String(eventBusName)
Expand Down
2 changes: 2 additions & 0 deletions internal/service/events/rule_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -594,6 +594,7 @@ func TestAccEventsRule_partnerEventBus(t *testing.T) {
resource.TestCheckResourceAttr(resourceName, "event_bus_name", busName),
acctest.CheckResourceAttrEquivalentJSON(resourceName, "event_pattern", "{\"source\":[\"aws.ec2\"]}"),
resource.TestCheckResourceAttr(resourceName, "is_enabled", "true"),
resource.TestCheckResourceAttr(resourceName, "force", "false"),
resource.TestCheckResourceAttr(resourceName, "state", "ENABLED"),
resource.TestCheckResourceAttr(resourceName, "name", rName),
resource.TestCheckResourceAttr(resourceName, "role_arn", ""),
Expand Down Expand Up @@ -632,6 +633,7 @@ func TestAccEventsRule_eventBusARN(t *testing.T) {
resource.TestCheckResourceAttrPair(resourceName, "event_bus_name", "aws_cloudwatch_event_bus.test", "arn"),
acctest.CheckResourceAttrEquivalentJSON(resourceName, "event_pattern", "{\"source\":[\"aws.ec2\"]}"),
resource.TestCheckResourceAttr(resourceName, "is_enabled", "true"),
resource.TestCheckResourceAttr(resourceName, "force", "true"),
resource.TestCheckResourceAttr(resourceName, "state", "ENABLED"),
resource.TestCheckResourceAttr(resourceName, "name", rName),
resource.TestCheckResourceAttr(resourceName, "role_arn", ""),
Expand Down