Configuring AWS metric alarm using newly created scaling policy ARN

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_result

  • name: Debug result of scaling policy creation
    debug: var=sp_result

  • name: 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?

What version of Ansible are you running? The above PR was merged into devel and will be included in 1.7, however it is not yet available in 1.6.x.

D’oh, looks like I was still on 1.6.6. Using the devel branch now and it works, thanks!