Snippets
Created by
Tim Kelley
elastic ip module issues with AWS region
(elastic ip anonymized)
I'm trying to associate an eip to an instance with the eip execution module. It works fine in us-east-1, but not in us-west-2. The ip in question [4.10.23.1] is in fact in us-west-2 and is currently associated to that minion.
Here is the template, should work in any region
{% import 'global/settings.sls' as global with context %}
{% if global.eip is defined %}
# we have to use the execution module for this
# as there is no state module for eip's
ec2.associate_eip_address:
module.run:
- name: boto_ec2.associate_eip_address
- instance_id: {{ global.instance_id }}
- public_ip: {{ global.eip }}
- kwargs: {
public_ip: {{ global.eip }},
allow_reassociation: 'true',
region: {{ global.region }},
instance_id: {{ global.instance_id }}
}
{% endif %}
this renders correctly on the minion and sets the region:
US-WEST-2-minion # salt-call cp.get_template salt://ec2/elastic-ip.sls /dev/stdout
# we have to use the execution module for this
# as there is no state module for eip's
ec2.associate_eip_address:
module.run:
- name: boto_ec2.associate_eip_address
- instance_id: i-08572e62c97063af7
- public_ip: 4.10.23.1
- kwargs: {
public_ip: 4.10.23.1,
allow_reassociation: 'true',
region: us-west-2,
instance_id: i-08572e62c97063af7
}
local:
/dev/stdout
yet when running the sls, I get this message, which is what I believe I'd get if I'd set the region wrong. FYI, this works fine in us-east-1 (with us-east-1 elastic ips).
US-WEST-2-minion # salt-call -l info state.apply ec2.elastic-ip (snipped out irrelevant lines)
[INFO ] Executing state module.run for boto_ec2.associate_eip_address
[ERROR ] EC2ResponseError: 400 Bad Request
<?xml version="1.0" encoding="UTF-8"?>
<Response><Errors><Error><Code>AuthFailure</Code><Message>The address '4.10.23.1' does not belong to you.</Message></Error></Errors><RequestID>c754cba8-6bbb-4903-bd5f-d98fd8850261</RequestID></Response>
[ERROR ] {'ret': False}
[INFO ] Completed state [boto_ec2.associate_eip_address] at time 13:16:08.429428 duration_in_ms=444.563
Comments (1)
You can clone a snippet to your computer for local editing. Learn more.
The elastic ip in question is already associated wth this minion and functional btw