From 38a5033b487c094bc114c81fe34e23b5aa44b847 Mon Sep 17 00:00:00 2001 From: opapy Date: Wed, 30 Aug 2017 05:13:12 +0900 Subject: [PATCH] support ecs task resource for cloudwatchevent_rule (#28495) * add support ecs * add role_arn parameters --- .../cloud/amazon/cloudwatchevent_rule.py | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/lib/ansible/modules/cloud/amazon/cloudwatchevent_rule.py b/lib/ansible/modules/cloud/amazon/cloudwatchevent_rule.py index 0b06c7fc27..cc2ae97f37 100644 --- a/lib/ansible/modules/cloud/amazon/cloudwatchevent_rule.py +++ b/lib/ansible/modules/cloud/amazon/cloudwatchevent_rule.py @@ -63,14 +63,18 @@ options: targets: description: - "A dictionary array of targets to add to or update for the rule, in the - form C({ id: [string], arn: [string], input: [valid JSON string], input_path: [valid JSONPath string] }). + form C({ id: [string], arn: [string], role_arn: [string], input: [valid JSON string], + input_path: [valid JSONPath string], ecs_parameters: {task_definition_arn: [string], task_count: [int]}}). I(id) [required] is the unique target assignment ID. I(arn) (required) - is the Amazon Resource Name associated with the target. I(input) + is the Amazon Resource Name associated with the target. I(role_arn) (optional) is The Amazon Resource Name + of the IAM role to be used for this target when the rule is triggered. I(input) (optional) is a JSON object that will override the event data when passed to the target. I(input_path) (optional) is a JSONPath string (e.g. C($.detail)) that specifies the part of the event data to be passed to the target. If neither I(input) nor I(input_path) is - specified, then the entire event is passed to the target in JSON form." + specified, then the entire event is passed to the target in JSON form. + I(task_definition_arn) [optional] is ecs task definition arn. + I(task_count) [optional] is ecs task count." required: false ''' @@ -234,6 +238,15 @@ class CloudWatchEventRule(object): target_request['Input'] = target['input'] if 'input_path' in target: target_request['InputPath'] = target['input_path'] + if 'role_arn' in target: + target_request['RoleArn'] = target['role_arn'] + if 'ecs_parameters' in target: + target_request['EcsParameters'] = {} + ecs_parameters = target['ecs_parameters'] + if 'task_definition_arn' in target['ecs_parameters']: + target_request['EcsParameters']['TaskDefinitionArn'] = ecs_parameters['task_definition_arn'] + if 'task_count' in target['ecs_parameters']: + target_request['EcsParameters']['TaskCount'] = ecs_parameters['task_count'] targets_request.append(target_request) return targets_request