Last active
October 11, 2018 19:25
-
-
Save carlessanagustin/6b8032e900aeb430cb092fad8e1871d5 to your computer and use it in GitHub Desktop.
ANSIBLE: Change AWS EC2 Security Group configuration.
This file contains hidden or 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
#!/usr/local/bin/ansible-playbook -v | |
--- | |
- hosts: localhost | |
gather_facts: False | |
connection: local | |
vars: | |
rule_list: | |
- { proto: tcp, from_port: 80, to_port: up, cidr_ip: 10.0.0.1/32 } | |
- { proto: tcp, from_port: 443, to_port: 443, cidr_ip: 10.0.0.1/32 } | |
ec2_group_region: eu-west-1 | |
ec2_group_vpc: 'vpc-XXXXXXX' | |
ec2_group_description: 'This is a description' | |
ec2_group_name: security_group_name | |
vars_files: | |
- vars/aws_config.yml | |
tasks: | |
- name: Change security group | |
ec2_group: | |
name: '{{ ec2_group_name }}' | |
description: '{{ ec2_group_description }}' | |
vpc_id: '{{ ec2_group_vpc }}' | |
aws_access_key: '{{ access_key }}' | |
aws_secret_key: '{{ secret_key }}' | |
region: '{{ ec2_group_region }}' | |
rules: '{{ rule_list }}' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Thanks for posting this. Am I correct in assuming that the key to this working is setting the
gather_facts
tofalse
? I'm trying to update thecidr_ip
of one of my SG rules, but I keep getting the error: " The specified rule does not exist in this security group"