You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ansible/cloud/amazon
Ryan Brown f1c2739163 Handle termination_protection parameter when restarting instances (#5076)
* Restart EC2 instances with multiple network interfaces

A previous bug, #3234, caused instances with multiple ENI's to fail when being
started or stopped because sourceDestCheck is a per-interface attribute, but we
use the boto global access to it (which only works when there's a single ENI).

This patch handles a variant of that bug that only surfaced when restarting an
instance, and catches the same type of exception.

* Default termination_protection to None instead of False

AWS defaults the value of termination_protection to False, so we don't
need to explicitly send `False` when the user hasn't specified a
termination protection level. Before this patch, the below pair of tasks
would:

1. Create an instance (enabling termination_protection)
2. Restart that instance (disabling termination_protection)

Now, the default None value would prevent the restart task from
disabling termination_protection.

```
- name: make an EC2 instance
  ec2:
    vpc_subnet_id: {{ subnet  }}
    instance_type: t2.micro
    termination_protection: yes
    exact_count: 1
    count_tag:
       Name: TestInstance
    instance_tags:
       Name: TestInstance
    group_id: {{ group }}
    image: ami-7172b611
    wait: yes
- name: restart a protected EC2 instance
  ec2:
    vpc_subnet_id: {{ subnet  }}
    state: restarted
    instance_tags:
       Name: TestInstance
    group_id: {{ group }}
    image: ami-7172b611
    wait: yes
```
8 years ago
..
__init__.py
_ec2_ami_search.py
cloudformation.py
ec2.py
ec2_ami.py
ec2_ami_find.py
ec2_asg.py
ec2_eip.py
ec2_elb.py
ec2_elb_lb.py
ec2_facts.py
ec2_group.py
ec2_key.py
ec2_lc.py
ec2_metric_alarm.py
ec2_scaling_policy.py
ec2_snapshot.py
ec2_tag.py
ec2_vol.py
ec2_vpc.py
ec2_vpc_net.py
elasticache.py
elasticache_subnet_group.py
iam.py
iam_cert.py
iam_policy.py
rds.py
rds_param_group.py
rds_subnet_group.py
route53.py
s3.py