Hi guys, I’m still pretty new to Ansible and was wondering if you could answer a question I have.
I’m trying to create an AWS scaling policy and attach a metric alarm to it. From what I understand, the ec2_metric_alarm module needs the ARN of the scaling policy so that it can associate itself with it. However, I can’t seem to get the ARN after creating a new scaling policy from the ec2_scaling_policy module’s output. Currently I’m trying to register the result of the ec2_scaling policy module. For example, my playbook looks something like this:
name: Create scaling policy and associate it with autoscaling group
ec2_scaling_policy:
state: present
region: us-east-1
name: “test-scaleup-policy”
adjustment_type: “ChangeInCapacity”
asg_name: “test-asg”
scaling_adjustment: 1
min_adjustment_step: 1
cooldown: 300
register: sp_resultname: Debug result of scaling policy creation
debug: var=sp_resultname: Create metric alarm and associate it with autoscaling policy
action:
module: ec2_metric_alarm
state: present
alarm_actions: [“{{ sp_result.arn }}”]
etc…
The debug module prints this:
TASK: [Debug] *****************************************************************
ok: [localhost] => {
“sg_result”: {
“changed”: false,
“invocation”: {
“module_args”: “”,
“module_name”: “ec2_scaling_policy”
}}}
According to this merged pull request, the ARN should be included in the data the module returns. Am I trying to capturing this information in the wrong way, e.g. using register when I should be using something else? Otherwise, is there something else I should be doing?