-
Notifications
You must be signed in to change notification settings - Fork 397
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added support for InputTransformer attribute of cloudwatchevent_rule (#…
…623) Added support for InputTransformer attribute of cloudwatchevent_rule SUMMARY EventBridge has the InputTransformer attribute on target to allow providing custom input to a target based on certain event data. This PR adds this functionality and includes an example usage. ISSUE TYPE Feature Pull Request COMPONENT NAME aws.cloudwatchevent_rule ADDITIONAL INFORMATION ... "targets": [ { "arn": "arn:aws:sns:us-east-1:123456789012:MySNSTopic", "id": "MySNSTopic", "input_transformer": { "input_paths_map": { "instance": "$.detail.instance-id", "state": "$.detail.state" }, "input_template": "\"<instance> is in state <state>\"" } } ] Reviewed-by: Markus Bergholz <[email protected]> Reviewed-by: Alina Buzachis <None> Reviewed-by: Avishay Bar <[email protected]> Reviewed-by: Jill R <None> Reviewed-by: Mark Chappell <None>
- Loading branch information
Showing
5 changed files
with
124 additions
and
7 deletions.
There are no files selected for viewing
2 changes: 2 additions & 0 deletions
2
changelogs/fragments/623-cloudwatchevents_rule-support_input_transformer.yml
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,2 @@ | ||
minor_changes: | ||
- cloudwatchevent_rule - Added ``input_paths_map`` and ``input_template`` parameters to support ``input_transformer`` on CloudWatch event rule (https://github.com/ansible-collections/community.aws/pull/623). |
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
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 @@ | ||
cloud/aws |
9 changes: 9 additions & 0 deletions
9
tests/integration/targets/cloudwatchevent_rule/defaults/main.yml
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,9 @@ | ||
--- | ||
name_pattern: "cloudwatch_event_rule" | ||
unique_id: "{{ tiny_prefix }}" | ||
|
||
test_event_names: | ||
- "{{ name_pattern }}-{{ unique_id }}-1" | ||
- "{{ name_pattern }}-{{ unique_id }}-2" | ||
|
||
input_transformer_event_name: "{{ name_pattern }}-{{ unique_id }}-3" |
70 changes: 70 additions & 0 deletions
70
tests/integration/targets/cloudwatchevent_rule/tasks/main.yml
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,70 @@ | ||
- module_defaults: | ||
group/aws: | ||
aws_access_key: "{{ aws_access_key }}" | ||
aws_secret_key: "{{ aws_secret_key }}" | ||
security_token: "{{ security_token | default(omit) }}" | ||
region: "{{ aws_region }}" | ||
|
||
block: | ||
- name: Create SNS topic | ||
sns_topic: | ||
name: "TestSNSTopic" | ||
state: present | ||
display_name: "Test SNS Topic" | ||
register: sns_topic_output | ||
|
||
- name: Create classic cloudwatch event rules | ||
cloudwatchevent_rule: | ||
name: "{{ item }}" | ||
description: "Rule for {{ item }}" | ||
state: present | ||
schedule_expression: "cron(0 20 * * ? *)" | ||
targets: | ||
- id: "{{ sns_topic_output.sns_topic.name }}" | ||
arn: "{{ sns_topic_output.sns_topic.topic_arn }}" | ||
register: event_rules_classic_output | ||
loop: "{{ test_event_names }}" | ||
|
||
- name: Create cloudwatch event rule with input transformer | ||
cloudwatchevent_rule: | ||
name: "{{ input_transformer_event_name }}" | ||
description: "Event rule with input transformer configuration" | ||
state: present | ||
event_pattern: '{"source":["aws.ec2"],"detail-type":["EC2 Instance State-change Notification"],"detail":{"state":["pending"]}}' | ||
targets: | ||
- id: "{{ sns_topic_output.sns_topic.name }}" | ||
arn: "{{ sns_topic_output.sns_topic.topic_arn }}" | ||
input_paths_map: | ||
instance: "$.detail.instance-id" | ||
state: "$.detail.state" | ||
input_template: "<instance> is in state <state>" | ||
register: event_rule_input_transformer_output | ||
|
||
- name: Assert that classic event rules were created | ||
assert: | ||
that: | ||
- event_rules_classic_output.changed | ||
- event_rules_classic_output.msg == "All items completed" | ||
|
||
- name: Assert that input transformer event rule was created | ||
assert: | ||
that: | ||
- event_rule_input_transformer_output.changed | ||
|
||
always: | ||
|
||
- name: Delete classic CloudWatch event rules | ||
cloudwatchevent_rule: | ||
name: "{{ item }}" | ||
state: absent | ||
loop: "{{ test_event_names }}" | ||
|
||
- name: Delete input transformer CloudWatch event rules | ||
cloudwatchevent_rule: | ||
name: "{{ input_transformer_event_name }}" | ||
state: absent | ||
|
||
- name: Delete SNS topic | ||
sns_topic: | ||
name: "TestSNSTopic" | ||
state: absent |