From d1ce13b482981c7bd4036556d2ec6dc977a65d05 Mon Sep 17 00:00:00 2001 From: Marcelo Costa Date: Sun, 20 Feb 2022 22:44:27 -0600 Subject: [PATCH 1/3] rename cloudwatchevent_rule module to eventbridge_rule --- .../{cloudwatchevent_rule.py => eventbridge_rule.py} | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) rename plugins/modules/{cloudwatchevent_rule.py => eventbridge_rule.py} (99%) diff --git a/plugins/modules/cloudwatchevent_rule.py b/plugins/modules/eventbridge_rule.py similarity index 99% rename from plugins/modules/cloudwatchevent_rule.py rename to plugins/modules/eventbridge_rule.py index d38db416864..641e5694ba9 100644 --- a/plugins/modules/cloudwatchevent_rule.py +++ b/plugins/modules/eventbridge_rule.py @@ -8,7 +8,7 @@ DOCUMENTATION = r''' --- -module: cloudwatchevent_rule +module: eventbridge_rule version_added: 1.0.0 short_description: Manage CloudWatch Event rules and targets description: @@ -105,7 +105,7 @@ ''' EXAMPLES = r''' -- community.aws.cloudwatchevent_rule: +- community.aws.eventbridge_rule: name: MyCronTask schedule_expression: "cron(0 20 * * ? *)" description: Run my scheduled task @@ -113,7 +113,7 @@ - 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 @@ -123,7 +123,7 @@ 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 ''' From e0af71410a5f4e1e89284080c390aae054e01df0 Mon Sep 17 00:00:00 2001 From: Marcelo Costa Date: Sun, 20 Feb 2022 22:48:09 -0600 Subject: [PATCH 2/3] replace CloudWatch with EventBridge --- plugins/modules/eventbridge_rule.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/plugins/modules/eventbridge_rule.py b/plugins/modules/eventbridge_rule.py index 641e5694ba9..624ab839588 100644 --- a/plugins/modules/eventbridge_rule.py +++ b/plugins/modules/eventbridge_rule.py @@ -10,9 +10,9 @@ --- 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 @@ -130,7 +130,7 @@ RETURN = r''' rule: - description: CloudWatch Event rule data. + description: EventBridge Event rule data. returned: success type: dict sample: @@ -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' }]" @@ -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 @@ -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): @@ -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() From 18c961fb9d6e9371d5a818eb45d2a03b72c39ff8 Mon Sep 17 00:00:00 2001 From: Marcelo Costa Date: Sun, 20 Feb 2022 22:58:22 -0600 Subject: [PATCH 3/3] forgot the meta/runtime.yml reference --- meta/runtime.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/meta/runtime.yml b/meta/runtime.yml index ab5bb4e0bb8..71d189f892f 100644 --- a/meta/runtime.yml +++ b/meta/runtime.yml @@ -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 @@ -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