-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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 eventbus to cloudwatch event rule #15727
Merged
Merged
Changes from 12 commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
ed8644b
Add event_bus_name attribute to aws_cloudwatch_event_rule
alexanderkalach bee1dbe
Merge branch 'master' into add-eventbus-to-cloudwatch-event-rule
gdavison e6bb2d3
Clean up tests
gdavison ea702fd
Properly handle `name` and `name_prefix`
gdavison 85fed3b
Adds `AtLeastOneOf` validation to `schedule_expression` and `event_pa…
gdavison cbce7fe
Cleanup
gdavison 155045e
Add test for removing tags
gdavison 87fe45e
Handles custom event buses
gdavison eb058e1
Uses IAM propagation timeout
gdavison 32b2eea
Tagging on PUT only works when creating a rule
gdavison 0a37185
Merge branch 'master' into add-eventbus-to-cloudwatch-event-rule
gdavison 4331fb1
Adds test for import without BusName
gdavison 5a389ea
Removes check for schedule_expression in non-default bus
gdavison 38e5f77
Fixes terraform formatting
gdavison File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package finder | ||
|
||
import ( | ||
"github.com/aws/aws-sdk-go/aws" | ||
events "github.com/aws/aws-sdk-go/service/cloudwatchevents" | ||
tfevents "github.com/terraform-providers/terraform-provider-aws/aws/internal/service/cloudwatchevents" | ||
) | ||
|
||
func Rule(conn *events.CloudWatchEvents, eventBusName, ruleName string) (*events.DescribeRuleOutput, error) { | ||
input := events.DescribeRuleInput{ | ||
Name: aws.String(ruleName), | ||
} | ||
if eventBusName != "" { | ||
input.EventBusName = aws.String(eventBusName) | ||
} | ||
|
||
return conn.DescribeRule(&input) | ||
|
||
} | ||
|
||
func RuleByID(conn *events.CloudWatchEvents, ruleID string) (*events.DescribeRuleOutput, error) { | ||
busName, ruleName, err := tfevents.RuleParseID(ruleID) | ||
if err != nil { | ||
return nil, err | ||
} | ||
|
||
return Rule(conn, busName, ruleName) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
package cloudwatchevents | ||
|
||
import ( | ||
"fmt" | ||
"strings" | ||
) | ||
|
||
const DefaultEventBusName = "default" | ||
|
||
const ruleIDSeparator = "/" | ||
|
||
func RuleCreateID(eventBusName, ruleName string) string { | ||
if eventBusName == "" || eventBusName == DefaultEventBusName { | ||
return ruleName | ||
} | ||
return eventBusName + ruleIDSeparator + ruleName | ||
} | ||
|
||
func RuleParseID(id string) (string, string, error) { | ||
parts := strings.Split(id, ruleIDSeparator) | ||
if len(parts) == 1 && parts[0] != "" { | ||
return DefaultEventBusName, parts[0], nil | ||
} | ||
if len(parts) == 2 && parts[0] != "" && parts[1] != "" { | ||
return parts[0], parts[1], nil | ||
} | ||
|
||
return "", "", fmt.Errorf("unexpected format for ID (%q), expected <event-bus-name>"+ruleIDSeparator+"<rule-name> or <rule-name>", id) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
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.
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.
Nit: Is the API error not clear in this case?
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.
This is short-circuiting the API call. I would have set it as a
ValidateFunc
if they supported cross-attribute validation