mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Add delete_on_termination to all EC2 root volumes (#44818)
Not terminating volumes on instance deletion causes unwanted costs
This commit is contained in:
parent
3c6c7bae9d
commit
0c22c0cefb
7 changed files with 33 additions and 2 deletions
|
@ -12,6 +12,9 @@
|
|||
image_id: "{{ ec2_ami_image[aws_region] }}"
|
||||
vpc_subnet_id: "{{ testing_subnet_b.subnet.id }}"
|
||||
volumes:
|
||||
- device_name: /dev/sda1
|
||||
ebs:
|
||||
delete_on_termination: true
|
||||
- device_name: /dev/sdb
|
||||
ebs:
|
||||
volume_size: 20
|
||||
|
|
|
@ -18,6 +18,10 @@
|
|||
cpu_options:
|
||||
core_count: 1
|
||||
threads_per_core: 1
|
||||
volumes:
|
||||
- device_name: /dev/sda1
|
||||
ebs:
|
||||
delete_on_termination: true
|
||||
<<: *aws_connection_info
|
||||
register: instance_creation
|
||||
|
||||
|
@ -38,6 +42,10 @@
|
|||
TestId: "{{ resource_prefix }}"
|
||||
vpc_subnet_id: "{{ testing_subnet_a.subnet.id }}"
|
||||
instance_type: c4.large
|
||||
volumes:
|
||||
- device_name: /dev/sda1
|
||||
ebs:
|
||||
delete_on_termination: true
|
||||
cpu_options:
|
||||
core_count: 1
|
||||
threads_per_core: 2
|
||||
|
|
|
@ -14,6 +14,10 @@
|
|||
TestId: "{{ resource_prefix }}"
|
||||
security_groups: "{{ sg.group_id }}"
|
||||
instance_type: t2.micro
|
||||
volumes:
|
||||
- device_name: /dev/sda1
|
||||
ebs:
|
||||
delete_on_termination: true
|
||||
<<: *aws_connection_info
|
||||
register: in_default_vpc
|
||||
- name: Terminate instance
|
||||
|
|
|
@ -37,6 +37,10 @@
|
|||
availability_zone: '{{ aws_region }}b'
|
||||
tags:
|
||||
TestId: "{{ resource_prefix }}"
|
||||
volumes:
|
||||
- device_name: /dev/sda1
|
||||
ebs:
|
||||
delete_on_termination: true
|
||||
instance_type: t2.micro
|
||||
<<: *aws_connection_info
|
||||
register: in_test_vpc
|
||||
|
|
|
@ -32,11 +32,15 @@
|
|||
|
||||
- name: Make instance with an instance_role
|
||||
ec2_instance:
|
||||
name: "{{ resource_prefix }}-test-default-vpc"
|
||||
name: "{{ resource_prefix }}-test-instance-role"
|
||||
image_id: "{{ ec2_ami_image[aws_region] }}"
|
||||
security_groups: "{{ sg.group_id }}"
|
||||
instance_type: t2.micro
|
||||
instance_role: "{{ resource_prefix }}-test-policy"
|
||||
volumes:
|
||||
- device_name: /dev/sda1
|
||||
ebs:
|
||||
delete_on_termination: true
|
||||
<<: *aws_connection_info
|
||||
register: instance_with_role
|
||||
|
||||
|
@ -46,7 +50,7 @@
|
|||
|
||||
- name: Update instance with new instance_role
|
||||
ec2_instance:
|
||||
name: "{{ resource_prefix }}-test-default-vpc"
|
||||
name: "{{ resource_prefix }}-test-instance-role"
|
||||
image_id: "{{ ec2_ami_image[aws_region] }}"
|
||||
security_groups: "{{ sg.group_id }}"
|
||||
instance_type: t2.micro
|
||||
|
|
|
@ -22,6 +22,10 @@
|
|||
source_dest_check: false
|
||||
vpc_subnet_id: "{{ testing_subnet_b.subnet.id }}"
|
||||
instance_type: t2.micro
|
||||
volumes:
|
||||
- device_name: /dev/sda1
|
||||
ebs:
|
||||
delete_on_termination: true
|
||||
<<: *aws_connection_info
|
||||
register: in_test_vpc
|
||||
|
||||
|
|
|
@ -16,6 +16,10 @@
|
|||
vpc_subnet_id: "{{ testing_subnet_b.subnet.id }}"
|
||||
termination_protection: true
|
||||
instance_type: t2.micro
|
||||
volumes:
|
||||
- device_name: /dev/sda1
|
||||
ebs:
|
||||
delete_on_termination: true
|
||||
<<: *aws_connection_info
|
||||
register: in_test_vpc
|
||||
- name: Try to terminate the instance
|
||||
|
|
Loading…
Reference in a new issue