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

rename cloudwatchevent_rule module to eventbridge_rule #943

Closed
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion meta/runtime.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ action_groups:
- cloudfront_invalidation
- cloudfront_origin_access_identity
- cloudtrail
- cloudwatchevent_rule
- cloudwatchlogs_log_group
- cloudwatchlogs_log_group_info
- cloudwatchlogs_log_group_metric_filter
Expand Down Expand Up @@ -123,6 +122,7 @@ action_groups:
- elb_target_group
- elb_target_group_info
- elb_target_info
- eventbridge_rule
- execute_lambda
- iam_access_key
- iam_access_key_info
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@

DOCUMENTATION = r'''
---
module: cloudwatchevent_rule
module: eventbridge_rule
version_added: 1.0.0
short_description: Manage CloudWatch Event rules and targets
short_description: Manage EventBridge Event rules and targets
description:
- This module creates and manages CloudWatch event rules and targets.
- This module creates and manages EventBridge event rules and targets.
extends_documentation_fragment:
- amazon.aws.aws
- amazon.aws.ec2
Expand Down Expand Up @@ -105,15 +105,15 @@
'''

EXAMPLES = r'''
- community.aws.cloudwatchevent_rule:
- community.aws.eventbridge_rule:
name: MyCronTask
schedule_expression: "cron(0 20 * * ? *)"
description: Run my scheduled task
targets:
- id: MyTargetId
arn: arn:aws:lambda:us-east-1:123456789012:function:MyFunction

- community.aws.cloudwatchevent_rule:
- community.aws.eventbridge_rule:
name: MyDisabledCronTask
schedule_expression: "rate(5 minutes)"
description: Run my disabled scheduled task
Expand All @@ -123,14 +123,14 @@
arn: arn:aws:lambda:us-east-1:123456789012:function:MyFunction
input: '{"foo": "bar"}'

- community.aws.cloudwatchevent_rule:
- community.aws.eventbridge_rule:
name: MyCronTask
state: absent
'''

RETURN = r'''
rule:
description: CloudWatch Event rule data.
description: EventBridge Event rule data.
returned: success
type: dict
sample:
Expand All @@ -140,7 +140,7 @@
schedule_expression: 'cron(0 20 * * ? *)'
state: 'ENABLED'
targets:
description: CloudWatch Event target(s) assigned to the rule.
description: EventBridge Event target(s) assigned to the rule.
returned: success
type: list
sample: "[{ 'arn': 'arn:aws:lambda:us-east-1:123456789012:function:MyFunction', 'id': 'MyTargetId' }]"
Expand All @@ -157,7 +157,7 @@
from ansible_collections.amazon.aws.plugins.module_utils.core import is_boto3_error_code


class CloudWatchEventRule(object):
class EventBridgeEventRule(object):
def __init__(self, module, name, client, schedule_expression=None,
event_pattern=None, description=None, role_arn=None):
self.name = name
Expand Down Expand Up @@ -303,7 +303,7 @@ def _snakify(self, dict):
return camel_dict_to_snake_dict(dict)


class CloudWatchEventRuleManager(object):
class EventBridgeEventRuleManager(object):
RULE_FIELDS = ['name', 'event_pattern', 'schedule_expression', 'description', 'role_arn']

def __init__(self, rule, targets):
Expand Down Expand Up @@ -428,14 +428,14 @@ def main():
module = AnsibleAWSModule(argument_spec=argument_spec)

rule_data = dict(
[(rf, module.params.get(rf)) for rf in CloudWatchEventRuleManager.RULE_FIELDS]
[(rf, module.params.get(rf)) for rf in EventBridgeEventRuleManager.RULE_FIELDS]
)
targets = module.params.get('targets')
state = module.params.get('state')
client = module.client('events')

cwe_rule = CloudWatchEventRule(module, client=client, **rule_data)
cwe_rule_manager = CloudWatchEventRuleManager(cwe_rule, targets)
cwe_rule = EventBridgeEventRule(module, client=client, **rule_data)
cwe_rule_manager = EventBridgeEventRuleManager(cwe_rule, targets)

if state == 'present':
cwe_rule_manager.ensure_present()
Expand Down