diff --git a/tests/integration/targets/ec2_transit_gateway_vpc_attachment/aliases b/tests/integration/targets/ec2_transit_gateway_vpc_attachment/aliases new file mode 100644 index 00000000000..fb58dd5786f --- /dev/null +++ b/tests/integration/targets/ec2_transit_gateway_vpc_attachment/aliases @@ -0,0 +1,3 @@ +cloud/aws + +# ec2_transit_gateway_vpc_attachment_info diff --git a/tests/integration/targets/ec2_transit_gateway_vpc_attachment/defaults/main.yml b/tests/integration/targets/ec2_transit_gateway_vpc_attachment/defaults/main.yml new file mode 100644 index 00000000000..c9727746555 --- /dev/null +++ b/tests/integration/targets/ec2_transit_gateway_vpc_attachment/defaults/main.yml @@ -0,0 +1,26 @@ +_resource_prefix: 'AnsibleTest' +#_resource_prefix: 'AnsibleTest-{{ tiny_prefix }}-TGW-Attach' +cidr_prefix: '10.{{ 255 | random(seed=_resource_prefix) }}' +tgw_name: '{{ _resource_prefix }}' +tgw_name_2: '{{ _resource_prefix }}-2' +vpc_name_a: '{{ _resource_prefix }}-1' +vpc_name_b: '{{ _resource_prefix }}-2' +vpc_cidr_a: '{{ cidr_prefix }}.1.0/24' +vpc_cidr_b: '{{ cidr_prefix }}.2.0/24' + +subnet_cidr_a_1: '{{ cidr_prefix }}.1.0/26' +subnet_cidr_a_2: '{{ cidr_prefix }}.1.64/26' +subnet_cidr_a_3: '{{ cidr_prefix }}.1.128/26' +subnet_cidr_a_1a: '{{ cidr_prefix }}.1.192/26' +subnet_cidr_b_1: '{{ cidr_prefix }}.2.0/26' +subnet_cidr_b_2: '{{ cidr_prefix }}.2.64/26' + +subnet_name_a_1: '{{ _resource_prefix }}-a-1' +subnet_name_a_1a: '{{ _resource_prefix }}-a-1a' +subnet_name_a_2: '{{ _resource_prefix }}-a-2' +subnet_name_a_3: '{{ _resource_prefix }}-a-3' +subnet_name_b_1: '{{ _resource_prefix }}-b-1' +subnet_name_b_2: '{{ _resource_prefix }}-b-2' + +attachment_name: '{{ _resource_prefix }}' +attachment_name_complex: '{{ _resource_prefix }}-complex' diff --git a/tests/integration/targets/ec2_transit_gateway_vpc_attachment/meta/main.yml b/tests/integration/targets/ec2_transit_gateway_vpc_attachment/meta/main.yml new file mode 100644 index 00000000000..aef5ca0ee57 --- /dev/null +++ b/tests/integration/targets/ec2_transit_gateway_vpc_attachment/meta/main.yml @@ -0,0 +1,2 @@ +dependencies: + - role: setup_ec2_facts diff --git a/tests/integration/targets/ec2_transit_gateway_vpc_attachment/tasks/cleanup.yml b/tests/integration/targets/ec2_transit_gateway_vpc_attachment/tasks/cleanup.yml new file mode 100644 index 00000000000..e59723bdc30 --- /dev/null +++ b/tests/integration/targets/ec2_transit_gateway_vpc_attachment/tasks/cleanup.yml @@ -0,0 +1,64 @@ +--- +- name: 'Describe all attachments on our VPC' + ec2_transit_gateway_vpc_attachment_info: + filters: + transit-gateway-id: '{{ tgw_id }}' + register: info + ignore_errors: True + +- name: 'Start deletion of all attachments' + ec2_transit_gateway_vpc_attachment: + state: absent + id: '{{ item.transit_gateway_attachment_id }}' + wait: False + loop: '{{ info.attachments }}' + ignore_errors: True + +- name: 'Wait for deletion of all attachments' + ec2_transit_gateway_vpc_attachment: + state: absent + id: '{{ item.transit_gateway_attachment_id }}' + wait: True + loop: '{{ info.attachments }}' + ignore_errors: True + +- name: 'Delete subnets' + ec2_vpc_subnet: + state: absent + cidr: '{{ item.cidr }}' + vpc_id: '{{ item.vpc_id }}' + loop: + - cidr: '{{ subnet_cidr_a_1 }}' + vpc_id: '{{ vpc_id_a }}' + - cidr: '{{ subnet_cidr_a_2 }}' + vpc_id: '{{ vpc_id_a }}' + - cidr: '{{ subnet_cidr_a_3 }}' + vpc_id: '{{ vpc_id_a }}' + - cidr: '{{ subnet_cidr_b_1 }}' + vpc_id: '{{ vpc_id_b }}' + - cidr: '{{ subnet_cidr_b_2 }}' + vpc_id: '{{ vpc_id_b }}' + - cidr: '{{ subnet_cidr_a_1a }}' + vpc_id: '{{ vpc_id_a }}' + ignore_errors: True + +- name: 'Create VPCs to attach to TGW' + ec2_vpc_net: + state: absent + cidr_block: '{{ item.cidr }}' + name: '{{ item.name }}' + loop: + - cidr: '{{ vpc_cidr_a }}' + name: '{{ vpc_name_a }}' + - cidr: '{{ vpc_cidr_b }}' + name: '{{ vpc_name_b }}' + ignore_errors: True + +- name: 'Create Transit Gateways' + ec2_transit_gateway: + state: absent + transit_gateway_id: '{{ item.tgw_id }}' + loop: + - tgw_id: '{{ tgw_id }}' + - tgw_id: '{{ tgw_id_2 }}' + ignore_errors: True diff --git a/tests/integration/targets/ec2_transit_gateway_vpc_attachment/tasks/complex.yml b/tests/integration/targets/ec2_transit_gateway_vpc_attachment/tasks/complex.yml new file mode 100644 index 00000000000..eda3ab2ace4 --- /dev/null +++ b/tests/integration/targets/ec2_transit_gateway_vpc_attachment/tasks/complex.yml @@ -0,0 +1,443 @@ +--- +# Tests the setting of most parameters at the same time +# +# Note: Does not delete the attachment, so that there's a second VPC attached to +# the TGW when we run our _info tests in simple.yml +# +# ============================================================================= +# Creation + +- block: + - name: '(CHECK_MODE) Create an attachment - complex parameters' + check_mode: True + ec2_transit_gateway_vpc_attachment: + name: '{{ attachment_name_complex }}' + transit_gateway: '{{ tgw_id }}' + subnets: + - '{{ subnet_id_b_1 }}' + - '{{ subnet_id_b_2 }}' + tags: + tagA: 'example Value' + Tag_B: 'second value' + appliance_mode_support: True + ipv6_support: True + register: complex_attach + + - assert: + that: + - complex_attach is changed + - '"attachments" in complex_attach' + - complex_attach.attachments | length == 1 + - '"options" in attachment' + - '"subnet_ids" in attachment' + - '"tags" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - attachment.options.appliance_mode_support == "enable" + - attachment.options.ipv6_support == "enable" + - attachment.subnet_ids | length == 2 + - subnet_id_b_1 in attachment.subnet_ids + - subnet_id_b_2 in attachment.subnet_ids + - attachment.tags | length == 3 + - '"Name" in attachment.tags' + - '"tagA" in attachment.tags' + - '"Tag_B" in attachment.tags' + - attachment.tags.Name == attachment_name_complex + - attachment.tags.tagA == "example Value" + - attachment.tags.Tag_B == "second value" + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_b + vars: + attachment: '{{ complex_attach.attachments[0] }}' + + - name: 'Create an attachment - complex parameters' + ec2_transit_gateway_vpc_attachment: + name: '{{ attachment_name_complex }}' + transit_gateway: '{{ tgw_id }}' + subnets: + - '{{ subnet_id_b_1 }}' + - '{{ subnet_id_b_2 }}' + tags: + tagA: 'example Value' + Tag_B: 'second value' + appliance_mode_support: True + ipv6_support: True + register: complex_attach + + - assert: + that: + - complex_attach is changed + - '"attachments" in complex_attach' + - complex_attach.attachments | length == 1 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length == 2 + - subnet_id_b_1 in attachment.subnet_ids + - subnet_id_b_2 in attachment.subnet_ids + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_b + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - attachment.options.appliance_mode_support == 'enable' + - attachment.options.dns_support == 'enable' + - attachment.options.ipv6_support == 'enable' + - attachment.transit_gateway_attachment_id.startswith('tgw-attach-') + - attachment.state == 'available' + - attachment.tags | length == 3 + - '"Name" in attachment.tags' + - '"tagA" in attachment.tags' + - '"Tag_B" in attachment.tags' + - attachment.tags.Name == attachment_name_complex + - attachment.tags.tagA == "example Value" + - attachment.tags.Tag_B == "second value" + - attachment.vpc_owner_id == vpc_owner_b + vars: + attachment: '{{ complex_attach.attachments[0] }}' + + - name: Save Attachment ID + set_fact: + complex_attachment_id: '{{ complex_attach.attachments[0].transit_gateway_attachment_id }}' + + - name: '(CHECK_MODE) Create an attachment - complex parameters -- IDEMPOTENCY' + check_mode: True + ec2_transit_gateway_vpc_attachment: + name: '{{ attachment_name_complex }}' + transit_gateway: '{{ tgw_id }}' + subnets: + - '{{ subnet_id_b_1 }}' + - '{{ subnet_id_b_2 }}' + tags: + tagA: 'example Value' + Tag_B: 'second value' + appliance_mode_support: True + ipv6_support: True + register: complex_attach + + - assert: + that: + - complex_attach is not changed + - '"attachments" in complex_attach' + - complex_attach.attachments | length == 1 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length == 2 + - subnet_id_b_1 in attachment.subnet_ids + - subnet_id_b_2 in attachment.subnet_ids + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_b + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - attachment.options.appliance_mode_support == 'enable' + - attachment.options.dns_support == 'enable' + - attachment.options.ipv6_support == 'enable' + - attachment.transit_gateway_attachment_id == complex_attachment_id + - attachment.state == 'available' + - attachment.tags | length == 3 + - '"Name" in attachment.tags' + - '"tagA" in attachment.tags' + - '"Tag_B" in attachment.tags' + - attachment.tags.Name == attachment_name_complex + - attachment.tags.tagA == "example Value" + - attachment.tags.Tag_B == "second value" + - attachment.vpc_owner_id == vpc_owner_b + vars: + attachment: '{{ complex_attach.attachments[0] }}' + + - name: 'Create an attachment - complex parameters -- IDEMPOTENCY' + ec2_transit_gateway_vpc_attachment: + name: '{{ attachment_name_complex }}' + transit_gateway: '{{ tgw_id }}' + subnets: + - '{{ subnet_id_b_1 }}' + - '{{ subnet_id_b_2 }}' + tags: + tagA: 'example Value' + Tag_B: 'second value' + appliance_mode_support: True + ipv6_support: True + register: complex_attach + + - assert: + that: + - complex_attach is not changed + - '"attachments" in complex_attach' + - complex_attach.attachments | length == 1 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length == 2 + - subnet_id_b_1 in attachment.subnet_ids + - subnet_id_b_2 in attachment.subnet_ids + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_b + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - attachment.options.appliance_mode_support == 'enable' + - attachment.options.dns_support == 'enable' + - attachment.options.ipv6_support == 'enable' + - attachment.transit_gateway_attachment_id == complex_attachment_id + - attachment.state == 'available' + - attachment.tags | length == 3 + - '"Name" in attachment.tags' + - '"tagA" in attachment.tags' + - '"Tag_B" in attachment.tags' + - attachment.tags.Name == attachment_name_complex + - attachment.tags.tagA == "example Value" + - attachment.tags.Tag_B == "second value" + - attachment.vpc_owner_id == vpc_owner_b + vars: + attachment: '{{ complex_attach.attachments[0] }}' + +# ============================================================================= +# Update + + - name: '(CHECK_MODE) Update an attachment - complex parameters' + check_mode: True + ec2_transit_gateway_vpc_attachment: + name: '{{ attachment_name_complex }}' + transit_gateway: '{{ tgw_id }}' + subnets: + - '{{ subnet_id_b_1 }}' + purge_subnets: True + tags: + tagC: '3' + Tag_D: 'Hello again dear world' + purge_tags: False + dns_support: False + ipv6_support: False + register: complex_attach + + - assert: + that: + - complex_attach is changed + - '"attachments" in complex_attach' + - complex_attach.attachments | length == 1 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length == 1 + - subnet_id_b_1 in attachment.subnet_ids + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_b + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - attachment.options.appliance_mode_support == 'enable' + - attachment.options.dns_support == 'disable' + - attachment.options.ipv6_support == 'disable' + - attachment.transit_gateway_attachment_id == complex_attachment_id + - attachment.state == 'available' + - attachment.tags | length == 5 + - '"Name" in attachment.tags' + - '"tagA" in attachment.tags' + - '"Tag_B" in attachment.tags' + - '"tagC" in attachment.tags' + - '"Tag_D" in attachment.tags' + - attachment.tags.Name == attachment_name_complex + - attachment.tags.tagA == "example Value" + - attachment.tags.Tag_B == "second value" + - attachment.tags.tagC == "3" + - attachment.tags.Tag_D == "Hello again dear world" + - attachment.vpc_owner_id == vpc_owner_b + vars: + attachment: '{{ complex_attach.attachments[0] }}' + + - name: 'Update an attachment - complex parameters' + ec2_transit_gateway_vpc_attachment: + name: '{{ attachment_name_complex }}' + transit_gateway: '{{ tgw_id }}' + subnets: + - '{{ subnet_id_b_1 }}' + purge_subnets: True + tags: + tagC: '3' + Tag_D: 'Hello again dear world' + purge_tags: False + dns_support: False + ipv6_support: False + register: complex_attach + + - assert: + that: + - complex_attach is changed + - '"attachments" in complex_attach' + - complex_attach.attachments | length == 1 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length == 1 + - subnet_id_b_1 in attachment.subnet_ids + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_b + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - attachment.options.appliance_mode_support == 'enable' + - attachment.options.dns_support == 'disable' + - attachment.options.ipv6_support == 'disable' + - attachment.transit_gateway_attachment_id == complex_attachment_id + - attachment.state == 'available' + - attachment.tags | length == 5 + - '"Name" in attachment.tags' + - '"tagA" in attachment.tags' + - '"Tag_B" in attachment.tags' + - '"tagC" in attachment.tags' + - '"Tag_D" in attachment.tags' + - attachment.tags.Name == attachment_name_complex + - attachment.tags.tagA == "example Value" + - attachment.tags.Tag_B == "second value" + - attachment.tags.tagC == "3" + - attachment.tags.Tag_D == "Hello again dear world" + - attachment.vpc_owner_id == vpc_owner_b + vars: + attachment: '{{ complex_attach.attachments[0] }}' + + - name: '(CHECK_MODE) Update an attachment - complex parameters -- IDEMPOTENCY' + check_mode: True + ec2_transit_gateway_vpc_attachment: + name: '{{ attachment_name_complex }}' + transit_gateway: '{{ tgw_id }}' + subnets: + - '{{ subnet_id_b_1 }}' + purge_subnets: True + tags: + tagC: '3' + Tag_D: 'Hello again dear world' + purge_tags: False + dns_support: False + ipv6_support: False + register: complex_attach + + - assert: + that: + - complex_attach is not changed + - '"attachments" in complex_attach' + - complex_attach.attachments | length == 1 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length == 1 + - subnet_id_b_1 in attachment.subnet_ids + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_b + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - attachment.options.appliance_mode_support == 'enable' + - attachment.options.dns_support == 'disable' + - attachment.options.ipv6_support == 'disable' + - attachment.transit_gateway_attachment_id == complex_attachment_id + - attachment.state == 'available' + - attachment.tags | length == 5 + - '"Name" in attachment.tags' + - '"tagA" in attachment.tags' + - '"Tag_B" in attachment.tags' + - '"tagC" in attachment.tags' + - '"Tag_D" in attachment.tags' + - attachment.tags.Name == attachment_name_complex + - attachment.tags.tagA == "example Value" + - attachment.tags.Tag_B == "second value" + - attachment.tags.tagC == "3" + - attachment.tags.Tag_D == "Hello again dear world" + - attachment.vpc_owner_id == vpc_owner_b + vars: + attachment: '{{ complex_attach.attachments[0] }}' + + - name: 'Update an attachment - complex parameters -- IDEMPOTENCY' + ec2_transit_gateway_vpc_attachment: + name: '{{ attachment_name_complex }}' + transit_gateway: '{{ tgw_id }}' + subnets: + - '{{ subnet_id_b_1 }}' + purge_subnets: True + tags: + tagC: '3' + Tag_D: 'Hello again dear world' + purge_tags: False + dns_support: False + ipv6_support: False + register: complex_attach + + - assert: + that: + - complex_attach is not changed + - '"attachments" in complex_attach' + - complex_attach.attachments | length == 1 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length == 1 + - subnet_id_b_1 in attachment.subnet_ids + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_b + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - attachment.options.appliance_mode_support == 'enable' + - attachment.options.dns_support == 'disable' + - attachment.options.ipv6_support == 'disable' + - attachment.transit_gateway_attachment_id == complex_attachment_id + - attachment.state == 'available' + - attachment.tags | length == 5 + - '"Name" in attachment.tags' + - '"tagA" in attachment.tags' + - '"Tag_B" in attachment.tags' + - '"tagC" in attachment.tags' + - '"Tag_D" in attachment.tags' + - attachment.tags.Name == attachment_name_complex + - attachment.tags.tagA == "example Value" + - attachment.tags.Tag_B == "second value" + - attachment.tags.tagC == "3" + - attachment.tags.Tag_D == "Hello again dear world" + - attachment.vpc_owner_id == vpc_owner_b + vars: + attachment: '{{ complex_attach.attachments[0] }}' diff --git a/tests/integration/targets/ec2_transit_gateway_vpc_attachment/tasks/main.yml b/tests/integration/targets/ec2_transit_gateway_vpc_attachment/tasks/main.yml new file mode 100644 index 00000000000..8694b829e7b --- /dev/null +++ b/tests/integration/targets/ec2_transit_gateway_vpc_attachment/tasks/main.yml @@ -0,0 +1,24 @@ +--- +- name: 'ec2_transit_gateway_vpc_attachment integration tests' + collections: + - amazon.aws + module_defaults: + group/aws: + aws_access_key: '{{ aws_access_key }}' + aws_secret_key: '{{ aws_secret_key }}' + security_token: '{{ security_token | default(omit) }}' + region: '{{ aws_region }}' + + block: + # Prepares various resources + - include_tasks: 'setup.yml' + + # Tests create / update on parameters simulatniously + - include_tasks: 'complex.yml' + + # Tests create / update / delete on individual parameters + - include_tasks: 'simple.yml' + + always: + # Cleanup after ourselves + - include_tasks: 'cleanup.yml' diff --git a/tests/integration/targets/ec2_transit_gateway_vpc_attachment/tasks/setup.yml b/tests/integration/targets/ec2_transit_gateway_vpc_attachment/tasks/setup.yml new file mode 100644 index 00000000000..86d5aa51b5f --- /dev/null +++ b/tests/integration/targets/ec2_transit_gateway_vpc_attachment/tasks/setup.yml @@ -0,0 +1,101 @@ +--- +- name: 'Pick 2 AZs available for use' + set_fact: + subnet_az_a_1: '{{ ec2_availability_zone_names[0] }}' + subnet_az_a_1a: '{{ ec2_availability_zone_names[0] }}' + subnet_az_a_2: '{{ ec2_availability_zone_names[1] }}' + subnet_az_a_3: '{{ ec2_availability_zone_names[2] }}' + subnet_az_b_1: '{{ ec2_availability_zone_names[0] }}' + subnet_az_b_2: '{{ ec2_availability_zone_names[1] }}' + +- name: 'Create Transit Gateways' + ec2_transit_gateway: + description: '{{ item.description }}' + tags: + Name: '{{ item.name }}' + loop: + - description: 'Transit Gateway for testing ec2_transit_gateway_attachment' + name: '{{ tgw_name }}' + - description: 'Second Transit Gateway for testing ec2_transit_gateway_attachment' + name: '{{ tgw_name_2 }}' + register: create_tgws + +- name: 'Create VPCs to attach to TGW' + ec2_vpc_net: + cidr_block: '{{ item.cidr }}' + name: '{{ item.name }}' + ipv6_cidr: True + loop: + - cidr: '{{ vpc_cidr_a }}' + name: '{{ vpc_name_a }}' + - cidr: '{{ vpc_cidr_b }}' + name: '{{ vpc_name_b }}' + register: create_vpcs + +- set_fact: + tgw_id: '{{ create_tgws.results[0].transit_gateway.transit_gateway_id }}' + tgw_id_2: '{{ create_tgws.results[1].transit_gateway.transit_gateway_id }}' + vpc_id_a: '{{ vpc_a.id }}' + vpc_id_b: '{{ vpc_b.id }}' + vpc_owner_a: '{{ vpc_a.owner_id }}' + vpc_owner_b: '{{ vpc_b.owner_id }}' + subnet_ipv6_a_1: '{{ vpc_ipv6_a | replace("0::/56","0::/64") }}' + subnet_ipv6_a_2: '{{ vpc_ipv6_a | replace("0::/56","1::/64") }}' + subnet_ipv6_a_3: '{{ vpc_ipv6_a | replace("0::/56","2::/64") }}' + subnet_ipv6_a_1a: '{{ vpc_ipv6_a | replace("0::/56","3::/64") }}' + subnet_ipv6_b_1: '{{ vpc_ipv6_b | replace("0::/56","0::/64") }}' + subnet_ipv6_b_2: '{{ vpc_ipv6_b | replace("0::/56","1::/64") }}' + vars: + vpc_a: '{{ create_vpcs.results[0].vpc }}' + vpc_b: '{{ create_vpcs.results[1].vpc }}' + vpc_ipv6_a: '{{ vpc_a.ipv6_cidr_block_association_set[0].ipv6_cidr_block }}' + vpc_ipv6_b: '{{ vpc_b.ipv6_cidr_block_association_set[0].ipv6_cidr_block }}' + +- name: 'Create subnets' + ec2_vpc_subnet: + az: '{{ item.az }}' + cidr: '{{ item.cidr }}' + ipv6_cidr: '{{ item.ipv6_cidr }}' + tags: + Name: '{{ item.name }}' + vpc_id: '{{ item.vpc_id }}' + loop: + - az: '{{ subnet_az_a_1 }}' + cidr: '{{ subnet_cidr_a_1 }}' + ipv6_cidr: '{{ subnet_ipv6_a_1 }}' + vpc_id: '{{ vpc_id_a }}' + name: '{{ subnet_name_a_1 }}' + - az: '{{ subnet_az_a_2 }}' + cidr: '{{ subnet_cidr_a_2 }}' + ipv6_cidr: '{{ subnet_ipv6_a_2 }}' + vpc_id: '{{ vpc_id_a }}' + name: '{{ subnet_name_a_2 }}' + - az: '{{ subnet_az_a_3 }}' + cidr: '{{ subnet_cidr_a_3 }}' + ipv6_cidr: '{{ subnet_ipv6_a_3 }}' + vpc_id: '{{ vpc_id_a }}' + name: '{{ subnet_name_a_3 }}' + - az: '{{ subnet_az_b_1 }}' + cidr: '{{ subnet_cidr_b_1 }}' + ipv6_cidr: '{{ subnet_ipv6_b_1 }}' + vpc_id: '{{ vpc_id_b }}' + name: '{{ subnet_name_b_1 }}' + - az: '{{ subnet_az_b_2 }}' + cidr: '{{ subnet_cidr_b_2 }}' + ipv6_cidr: '{{ subnet_ipv6_b_2 }}' + vpc_id: '{{ vpc_id_b }}' + name: '{{ subnet_name_b_2 }}' + - az: '{{ subnet_az_a_1a }}' + cidr: '{{ subnet_cidr_a_1a }}' + ipv6_cidr: '{{ subnet_ipv6_a_1a }}' + vpc_id: '{{ vpc_id_a }}' + name: '{{ subnet_name_a_1a }}' + register: create_subnets + +- set_fact: + subnet_id_a_1: '{{ create_subnets.results[0].subnet.id }}' + subnet_id_a_2: '{{ create_subnets.results[1].subnet.id }}' + subnet_id_a_3: '{{ create_subnets.results[2].subnet.id }}' + subnet_id_b_1: '{{ create_subnets.results[3].subnet.id }}' + subnet_id_b_2: '{{ create_subnets.results[4].subnet.id }}' + subnet_id_a_1a: '{{ create_subnets.results[5].subnet.id }}' diff --git a/tests/integration/targets/ec2_transit_gateway_vpc_attachment/tasks/simple.yml b/tests/integration/targets/ec2_transit_gateway_vpc_attachment/tasks/simple.yml new file mode 100644 index 00000000000..0085813a322 --- /dev/null +++ b/tests/integration/targets/ec2_transit_gateway_vpc_attachment/tasks/simple.yml @@ -0,0 +1,3611 @@ +--- +# ============================================================================= +# Creation +- block: + - name: '(CHECK_MODE) Create an attachment - minimal parameters' + check_mode: True + ec2_transit_gateway_vpc_attachment: + transit_gateway: '{{ tgw_id }}' + subnets: + - '{{ subnet_id_a_1 }}' + register: simple_attach + + - assert: + that: + - simple_attach is changed + - '"attachments" in simple_attach' + - simple_attach.attachments | length == 1 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length == 1 + - subnet_id_a_1 in attachment.subnet_ids + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_a + vars: + attachment: '{{ simple_attach.attachments[0] }}' + + - name: 'Create an attachment - minimal parameters' + ec2_transit_gateway_vpc_attachment: + transit_gateway: '{{ tgw_id }}' + subnets: + - '{{ subnet_id_a_1 }}' + register: simple_attach + + - assert: + that: + - simple_attach is changed + - '"attachments" in simple_attach' + - simple_attach.attachments | length == 1 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length == 1 + - subnet_id_a_1 in attachment.subnet_ids + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_a + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - attachment.options.appliance_mode_support == 'disable' + - attachment.options.dns_support == 'enable' + - attachment.options.ipv6_support == 'disable' + - attachment.transit_gateway_attachment_id.startswith('tgw-attach-') + - attachment.state == 'available' + - attachment.tags | length == 0 + - attachment.vpc_owner_id == vpc_owner_a + vars: + attachment: '{{ simple_attach.attachments[0] }}' + + - name: Save Attachment ID + set_fact: + simple_attachment_id: '{{ simple_attach.attachments[0].transit_gateway_attachment_id }}' + + - name: '(CHECK_MODE) Create an attachment - minimal parameters -- IDEMPOTENCY' + check_mode: True + ec2_transit_gateway_vpc_attachment: + transit_gateway: '{{ tgw_id }}' + subnets: + - '{{ subnet_id_a_1 }}' + register: simple_attach + + - assert: + that: + - simple_attach is not changed + - '"attachments" in simple_attach' + - simple_attach.attachments | length == 1 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length == 1 + - subnet_id_a_1 in attachment.subnet_ids + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_a + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - attachment.options.appliance_mode_support == 'disable' + - attachment.options.dns_support == 'enable' + - attachment.options.ipv6_support == 'disable' + - attachment.state == 'available' + - attachment.transit_gateway_attachment_id == simple_attachment_id + - attachment.tags | length == 0 + - attachment.vpc_owner_id == vpc_owner_a + vars: + attachment: '{{ simple_attach.attachments[0] }}' + + - name: 'Create an attachment - minimal parameters -- IDEMPOTENCY' + ec2_transit_gateway_vpc_attachment: + transit_gateway: '{{ tgw_id }}' + subnets: + - '{{ subnet_id_a_1 }}' + register: simple_attach + + - assert: + that: + - simple_attach is not changed + - '"attachments" in simple_attach' + - simple_attach.attachments | length == 1 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length == 1 + - subnet_id_a_1 in attachment.subnet_ids + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_a + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - attachment.options.appliance_mode_support == 'disable' + - attachment.options.dns_support == 'enable' + - attachment.options.ipv6_support == 'disable' + - attachment.state == 'available' + - attachment.transit_gateway_attachment_id == simple_attachment_id + - attachment.tags | length == 0 + - attachment.vpc_owner_id == vpc_owner_a + vars: + attachment: '{{ simple_attach.attachments[0] }}' + +# ===== + + - name: '(CHECK_MODE) By Id - minimal parameters -- IDEMPOTENCY' + check_mode: True + ec2_transit_gateway_vpc_attachment: + id: '{{ simple_attachment_id }}' + subnets: + - '{{ subnet_id_a_1 }}' + register: simple_attach + + - assert: + that: + - simple_attach is not changed + - '"attachments" in simple_attach' + - simple_attach.attachments | length == 1 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length == 1 + - subnet_id_a_1 in attachment.subnet_ids + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_a + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - attachment.options.appliance_mode_support == 'disable' + - attachment.options.dns_support == 'enable' + - attachment.options.ipv6_support == 'disable' + - attachment.state == 'available' + - attachment.transit_gateway_attachment_id == simple_attachment_id + - attachment.tags | length == 0 + - attachment.vpc_owner_id == vpc_owner_a + vars: + attachment: '{{ simple_attach.attachments[0] }}' + + - name: 'By Id - minimal parameters -- IDEMPOTENCY' + ec2_transit_gateway_vpc_attachment: + id: '{{ simple_attachment_id }}' + subnets: + - '{{ subnet_id_a_1 }}' + register: simple_attach + + - assert: + that: + - simple_attach is not changed + - '"attachments" in simple_attach' + - simple_attach.attachments | length == 1 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length == 1 + - subnet_id_a_1 in attachment.subnet_ids + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_a + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - attachment.options.appliance_mode_support == 'disable' + - attachment.options.dns_support == 'enable' + - attachment.options.ipv6_support == 'disable' + - attachment.state == 'available' + - attachment.transit_gateway_attachment_id == simple_attachment_id + - attachment.tags | length == 0 + - attachment.vpc_owner_id == vpc_owner_a + vars: + attachment: '{{ simple_attach.attachments[0] }}' + +# ============================================================================= +# Set a name + + - name: '(CHECK_MODE) Set name' + check_mode: True + ec2_transit_gateway_vpc_attachment: + id: '{{ simple_attachment_id }}' + name: '{{ attachment_name }}' + register: simple_attach + + - assert: + that: + - simple_attach is changed + - '"attachments" in simple_attach' + - simple_attach.attachments | length == 1 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length == 1 + - subnet_id_a_1 in attachment.subnet_ids + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_a + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - attachment.options.appliance_mode_support == 'disable' + - attachment.options.dns_support == 'enable' + - attachment.options.ipv6_support == 'disable' + - attachment.state == 'available' + - attachment.transit_gateway_attachment_id == simple_attachment_id + - attachment.tags | length == 1 + - '"Name" in attachment.tags' + - attachment.tags.Name == attachment_name + - attachment.vpc_owner_id == vpc_owner_a + vars: + attachment: '{{ simple_attach.attachments[0] }}' + + - name: 'Set name' + ec2_transit_gateway_vpc_attachment: + id: '{{ simple_attachment_id }}' + name: '{{ attachment_name }}' + register: simple_attach + + - assert: + that: + - simple_attach is changed + - '"attachments" in simple_attach' + - simple_attach.attachments | length == 1 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length == 1 + - subnet_id_a_1 in attachment.subnet_ids + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_a + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - attachment.options.appliance_mode_support == 'disable' + - attachment.options.dns_support == 'enable' + - attachment.options.ipv6_support == 'disable' + - attachment.state == 'available' + - attachment.transit_gateway_attachment_id == simple_attachment_id + - attachment.tags | length == 1 + - '"Name" in attachment.tags' + - attachment.tags.Name == attachment_name + - attachment.vpc_owner_id == vpc_owner_a + vars: + attachment: '{{ simple_attach.attachments[0] }}' + + - name: '(CHECK_MODE) Set name -- IDEMPOTENCY' + check_mode: True + ec2_transit_gateway_vpc_attachment: + id: '{{ simple_attachment_id }}' + name: '{{ attachment_name }}' + register: simple_attach + + - assert: + that: + - simple_attach is not changed + - '"attachments" in simple_attach' + - simple_attach.attachments | length == 1 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length == 1 + - subnet_id_a_1 in attachment.subnet_ids + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_a + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - attachment.options.appliance_mode_support == 'disable' + - attachment.options.dns_support == 'enable' + - attachment.options.ipv6_support == 'disable' + - attachment.state == 'available' + - attachment.transit_gateway_attachment_id == simple_attachment_id + - attachment.tags | length == 1 + - '"Name" in attachment.tags' + - attachment.tags.Name == attachment_name + - attachment.vpc_owner_id == vpc_owner_a + vars: + attachment: '{{ simple_attach.attachments[0] }}' + + - name: 'Set name -- IDEMPOTENCY' + ec2_transit_gateway_vpc_attachment: + id: '{{ simple_attachment_id }}' + name: '{{ attachment_name }}' + register: simple_attach + + - assert: + that: + - simple_attach is not changed + - '"attachments" in simple_attach' + - simple_attach.attachments | length == 1 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length == 1 + - subnet_id_a_1 in attachment.subnet_ids + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_a + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - attachment.options.appliance_mode_support == 'disable' + - attachment.options.dns_support == 'enable' + - attachment.options.ipv6_support == 'disable' + - attachment.state == 'available' + - attachment.transit_gateway_attachment_id == simple_attachment_id + - attachment.tags | length == 1 + - '"Name" in attachment.tags' + - attachment.tags.Name == attachment_name + - attachment.vpc_owner_id == vpc_owner_a + vars: + attachment: '{{ simple_attach.attachments[0] }}' + +# ===== + + - name: '(CHECK_MODE) By Name - minimal parameters -- IDEMPOTENCY' + check_mode: True + ec2_transit_gateway_vpc_attachment: + name: '{{ attachment_name }}' + subnets: + - '{{ subnet_id_a_1 }}' + register: simple_attach + + - assert: + that: + - simple_attach is not changed + - '"attachments" in simple_attach' + - simple_attach.attachments | length == 1 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length == 1 + - subnet_id_a_1 in attachment.subnet_ids + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_a + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - attachment.options.appliance_mode_support == 'disable' + - attachment.options.dns_support == 'enable' + - attachment.options.ipv6_support == 'disable' + - attachment.state == 'available' + - attachment.transit_gateway_attachment_id == simple_attachment_id + - attachment.tags | length == 1 + - '"Name" in attachment.tags' + - attachment.tags.Name == attachment_name + - attachment.vpc_owner_id == vpc_owner_a + vars: + attachment: '{{ simple_attach.attachments[0] }}' + + - name: 'By Name - minimal parameters -- IDEMPOTENCY' + ec2_transit_gateway_vpc_attachment: + name: '{{ attachment_name }}' + subnets: + - '{{ subnet_id_a_1 }}' + register: simple_attach + + - assert: + that: + - simple_attach is not changed + - '"attachments" in simple_attach' + - simple_attach.attachments | length == 1 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length == 1 + - subnet_id_a_1 in attachment.subnet_ids + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_a + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - attachment.options.appliance_mode_support == 'disable' + - attachment.options.dns_support == 'enable' + - attachment.options.ipv6_support == 'disable' + - attachment.state == 'available' + - attachment.transit_gateway_attachment_id == simple_attachment_id + - attachment.tags | length == 1 + - '"Name" in attachment.tags' + - attachment.tags.Name == attachment_name + - attachment.vpc_owner_id == vpc_owner_a + vars: + attachment: '{{ simple_attach.attachments[0] }}' + +# ============================================================================= +# Describe + + - name: 'Describe all attachments' + ec2_transit_gateway_vpc_attachment_info: + register: info + + - assert: + that: + - info is not changed + - '"attachments" in info' + - info.attachments | length >= 2 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length >= 1 + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - '"Name" in attachment.tags' + vars: + attachment: '{{ info.attachments[0] }}' + + - name: 'Describe attachments on a specific VPC' + ec2_transit_gateway_vpc_attachment_info: + filters: + transit-gateway-id: '{{ tgw_id }}' + register: info + + - assert: + that: + - info is not changed + - '"attachments" in info' + - info.attachments | length == 2 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length >= 1 + - attachment.transit_gateway_id == tgw_id + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - '"Name" in attachment.tags' + vars: + attachment: '{{ info.attachments[0] }}' + + - name: 'Describe attachment with a specific name' + ec2_transit_gateway_vpc_attachment_info: + name: '{{ attachment_name }}' + register: info + + - assert: + that: + - info is not changed + - '"attachments" in info' + - info.attachments | length == 1 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length == 1 + - subnet_id_a_1 in attachment.subnet_ids + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_a + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - attachment.options.appliance_mode_support == 'disable' + - attachment.options.dns_support == 'enable' + - attachment.options.ipv6_support == 'disable' + - attachment.state == 'available' + - attachment.transit_gateway_attachment_id == simple_attachment_id + - attachment.tags | length == 1 + - '"Name" in attachment.tags' + - attachment.tags.Name == attachment_name + - attachment.vpc_owner_id == vpc_owner_a + vars: + attachment: '{{ info.attachments[0] }}' + + - name: 'Describe attachment by ID' + ec2_transit_gateway_vpc_attachment_info: + id: '{{ simple_attachment_id }}' + register: info + + - assert: + that: + - info is not changed + - '"attachments" in info' + - info.attachments | length == 1 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length == 1 + - subnet_id_a_1 in attachment.subnet_ids + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_a + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - attachment.options.appliance_mode_support == 'disable' + - attachment.options.dns_support == 'enable' + - attachment.options.ipv6_support == 'disable' + - attachment.state == 'available' + - attachment.transit_gateway_attachment_id == simple_attachment_id + - attachment.tags | length == 1 + - '"Name" in attachment.tags' + - attachment.tags.Name == attachment_name + - attachment.vpc_owner_id == vpc_owner_a + vars: + attachment: '{{ info.attachments[0] }}' + +# ============================================================================= +# Tag attachment + + - name: '(CHECK_MODE) Set tags' + check_mode: True + ec2_transit_gateway_vpc_attachment: + name: '{{ attachment_name }}' + tags: + CamelCase: CamelCaseValue + pascalCase: pascalCaseValue + snake_case: snake_case_value + "Tag with Space": value with space + register: simple_attach + + - assert: + that: + - simple_attach is changed + - '"attachments" in simple_attach' + - simple_attach.attachments | length == 1 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length == 1 + - subnet_id_a_1 in attachment.subnet_ids + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_a + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - attachment.options.appliance_mode_support == 'disable' + - attachment.options.dns_support == 'enable' + - attachment.options.ipv6_support == 'disable' + - attachment.state == 'available' + - attachment.transit_gateway_attachment_id == simple_attachment_id + - attachment.tags | length == 5 + - '"Name" in attachment.tags' + - '"CamelCase" in attachment.tags' + - '"pascalCase" in attachment.tags' + - '"snake_case" in attachment.tags' + - '"Tag with Space" in attachment.tags' + - attachment.tags.Name == attachment_name + - attachment.tags.CamelCase == 'CamelCaseValue' + - attachment.tags.pascalCase == 'pascalCaseValue' + - attachment.tags.snake_case == 'snake_case_value' + - attachment.tags['Tag with Space'] == 'value with space' + - attachment.vpc_owner_id == vpc_owner_a + vars: + attachment: '{{ simple_attach.attachments[0] }}' + + - name: 'Set tags' + ec2_transit_gateway_vpc_attachment: + name: '{{ attachment_name }}' + tags: + CamelCase: CamelCaseValue + pascalCase: pascalCaseValue + snake_case: snake_case_value + "Tag with Space": value with space + register: simple_attach + + - assert: + that: + - simple_attach is changed + - '"attachments" in simple_attach' + - simple_attach.attachments | length == 1 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length == 1 + - subnet_id_a_1 in attachment.subnet_ids + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_a + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - attachment.options.appliance_mode_support == 'disable' + - attachment.options.dns_support == 'enable' + - attachment.options.ipv6_support == 'disable' + - attachment.state == 'available' + - attachment.transit_gateway_attachment_id == simple_attachment_id + - attachment.tags | length == 5 + - '"Name" in attachment.tags' + - '"CamelCase" in attachment.tags' + - '"pascalCase" in attachment.tags' + - '"snake_case" in attachment.tags' + - '"Tag with Space" in attachment.tags' + - attachment.tags.Name == attachment_name + - attachment.tags.CamelCase == 'CamelCaseValue' + - attachment.tags.pascalCase == 'pascalCaseValue' + - attachment.tags.snake_case == 'snake_case_value' + - attachment.tags['Tag with Space'] == 'value with space' + - attachment.vpc_owner_id == vpc_owner_a + vars: + attachment: '{{ simple_attach.attachments[0] }}' + + - name: '(CHECK_MODE) Set tags -- IDEMPOTENCY' + check_mode: True + ec2_transit_gateway_vpc_attachment: + name: '{{ attachment_name }}' + tags: + CamelCase: CamelCaseValue + pascalCase: pascalCaseValue + snake_case: snake_case_value + "Tag with Space": value with space + register: simple_attach + + - assert: + that: + - simple_attach is not changed + - '"attachments" in simple_attach' + - simple_attach.attachments | length == 1 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length == 1 + - subnet_id_a_1 in attachment.subnet_ids + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_a + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - attachment.options.appliance_mode_support == 'disable' + - attachment.options.dns_support == 'enable' + - attachment.options.ipv6_support == 'disable' + - attachment.state == 'available' + - attachment.transit_gateway_attachment_id == simple_attachment_id + - attachment.tags | length == 5 + - '"Name" in attachment.tags' + - '"CamelCase" in attachment.tags' + - '"pascalCase" in attachment.tags' + - '"snake_case" in attachment.tags' + - '"Tag with Space" in attachment.tags' + - attachment.tags.Name == attachment_name + - attachment.tags.CamelCase == 'CamelCaseValue' + - attachment.tags.pascalCase == 'pascalCaseValue' + - attachment.tags.snake_case == 'snake_case_value' + - attachment.tags['Tag with Space'] == 'value with space' + - attachment.vpc_owner_id == vpc_owner_a + vars: + attachment: '{{ simple_attach.attachments[0] }}' + + - name: 'Set tags -- IDEMPOTENCY' + ec2_transit_gateway_vpc_attachment: + name: '{{ attachment_name }}' + tags: + CamelCase: CamelCaseValue + pascalCase: pascalCaseValue + snake_case: snake_case_value + "Tag with Space": value with space + register: simple_attach + + - assert: + that: + - simple_attach is not changed + - '"attachments" in simple_attach' + - simple_attach.attachments | length == 1 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length == 1 + - subnet_id_a_1 in attachment.subnet_ids + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_a + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - attachment.options.appliance_mode_support == 'disable' + - attachment.options.dns_support == 'enable' + - attachment.options.ipv6_support == 'disable' + - attachment.state == 'available' + - attachment.transit_gateway_attachment_id == simple_attachment_id + - attachment.tags | length == 5 + - '"Name" in attachment.tags' + - '"CamelCase" in attachment.tags' + - '"pascalCase" in attachment.tags' + - '"snake_case" in attachment.tags' + - '"Tag with Space" in attachment.tags' + - attachment.tags.Name == attachment_name + - attachment.tags.CamelCase == 'CamelCaseValue' + - attachment.tags.pascalCase == 'pascalCaseValue' + - attachment.tags.snake_case == 'snake_case_value' + - attachment.tags['Tag with Space'] == 'value with space' + - attachment.vpc_owner_id == vpc_owner_a + vars: + attachment: '{{ simple_attach.attachments[0] }}' + + - name: 'Describe attachment with tags set' + ec2_transit_gateway_vpc_attachment_info: + id: '{{ simple_attachment_id }}' + register: info + + - assert: + that: + - info is not changed + - '"attachments" in info' + - info.attachments | length == 1 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length == 1 + - subnet_id_a_1 in attachment.subnet_ids + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_a + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - attachment.options.appliance_mode_support == 'disable' + - attachment.options.dns_support == 'enable' + - attachment.options.ipv6_support == 'disable' + - attachment.state == 'available' + - attachment.transit_gateway_attachment_id == simple_attachment_id + - attachment.tags | length == 5 + - '"Name" in attachment.tags' + - '"CamelCase" in attachment.tags' + - '"pascalCase" in attachment.tags' + - '"snake_case" in attachment.tags' + - '"Tag with Space" in attachment.tags' + - attachment.tags.Name == attachment_name + - attachment.tags.CamelCase == 'CamelCaseValue' + - attachment.tags.pascalCase == 'pascalCaseValue' + - attachment.tags.snake_case == 'snake_case_value' + - attachment.tags['Tag with Space'] == 'value with space' + - attachment.vpc_owner_id == vpc_owner_a + vars: + attachment: '{{ info.attachments[0] }}' + +# ===== + + - name: '(CHECK_MODE) No change to tags with name set -- IDEMPOTENCY' + check_mode: True + ec2_transit_gateway_vpc_attachment: + name: '{{ attachment_name }}' + register: simple_attach + + - assert: + that: + - simple_attach is not changed + - '"attachments" in simple_attach' + - simple_attach.attachments | length == 1 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length == 1 + - subnet_id_a_1 in attachment.subnet_ids + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_a + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - attachment.options.appliance_mode_support == 'disable' + - attachment.options.dns_support == 'enable' + - attachment.options.ipv6_support == 'disable' + - attachment.state == 'available' + - attachment.transit_gateway_attachment_id == simple_attachment_id + - attachment.tags | length == 5 + - '"Name" in attachment.tags' + - '"CamelCase" in attachment.tags' + - '"pascalCase" in attachment.tags' + - '"snake_case" in attachment.tags' + - '"Tag with Space" in attachment.tags' + - attachment.tags.Name == attachment_name + - attachment.tags.CamelCase == 'CamelCaseValue' + - attachment.tags.pascalCase == 'pascalCaseValue' + - attachment.tags.snake_case == 'snake_case_value' + - attachment.tags['Tag with Space'] == 'value with space' + - attachment.vpc_owner_id == vpc_owner_a + vars: + attachment: '{{ simple_attach.attachments[0] }}' + + - name: 'No change to tags with name set -- IDEMPOTENCY' + ec2_transit_gateway_vpc_attachment: + name: '{{ attachment_name }}' + register: simple_attach + + - assert: + that: + - simple_attach is not changed + - '"attachments" in simple_attach' + - simple_attach.attachments | length == 1 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length == 1 + - subnet_id_a_1 in attachment.subnet_ids + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_a + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - attachment.options.appliance_mode_support == 'disable' + - attachment.options.dns_support == 'enable' + - attachment.options.ipv6_support == 'disable' + - attachment.state == 'available' + - attachment.transit_gateway_attachment_id == simple_attachment_id + - attachment.tags | length == 5 + - '"Name" in attachment.tags' + - '"CamelCase" in attachment.tags' + - '"pascalCase" in attachment.tags' + - '"snake_case" in attachment.tags' + - '"Tag with Space" in attachment.tags' + - attachment.tags.Name == attachment_name + - attachment.tags.CamelCase == 'CamelCaseValue' + - attachment.tags.pascalCase == 'pascalCaseValue' + - attachment.tags.snake_case == 'snake_case_value' + - attachment.tags['Tag with Space'] == 'value with space' + - attachment.vpc_owner_id == vpc_owner_a + vars: + attachment: '{{ simple_attach.attachments[0] }}' + +# ===== + + - name: '(CHECK_MODE) Update tags' + check_mode: True + ec2_transit_gateway_vpc_attachment: + name: '{{ attachment_name }}' + purge_tags: False + tags: + snake_case: snake_case_value 2 + "Tag with Space": value with space 2 + register: simple_attach + + - assert: + that: + - simple_attach is changed + - '"attachments" in simple_attach' + - simple_attach.attachments | length == 1 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length == 1 + - subnet_id_a_1 in attachment.subnet_ids + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_a + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - attachment.options.appliance_mode_support == 'disable' + - attachment.options.dns_support == 'enable' + - attachment.options.ipv6_support == 'disable' + - attachment.state == 'available' + - attachment.transit_gateway_attachment_id == simple_attachment_id + - attachment.tags | length == 5 + - '"Name" in attachment.tags' + - '"CamelCase" in attachment.tags' + - '"pascalCase" in attachment.tags' + - '"snake_case" in attachment.tags' + - '"Tag with Space" in attachment.tags' + - attachment.tags.Name == attachment_name + - attachment.tags.CamelCase == 'CamelCaseValue' + - attachment.tags.pascalCase == 'pascalCaseValue' + - attachment.tags.snake_case == 'snake_case_value 2' + - attachment.tags['Tag with Space'] == 'value with space 2' + - attachment.vpc_owner_id == vpc_owner_a + vars: + attachment: '{{ simple_attach.attachments[0] }}' + + - name: 'Update tags' + ec2_transit_gateway_vpc_attachment: + name: '{{ attachment_name }}' + purge_tags: False + tags: + snake_case: snake_case_value 2 + "Tag with Space": value with space 2 + register: simple_attach + + - assert: + that: + - simple_attach is changed + - '"attachments" in simple_attach' + - simple_attach.attachments | length == 1 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length == 1 + - subnet_id_a_1 in attachment.subnet_ids + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_a + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - attachment.options.appliance_mode_support == 'disable' + - attachment.options.dns_support == 'enable' + - attachment.options.ipv6_support == 'disable' + - attachment.state == 'available' + - attachment.transit_gateway_attachment_id == simple_attachment_id + - attachment.tags | length == 5 + - '"Name" in attachment.tags' + - '"CamelCase" in attachment.tags' + - '"pascalCase" in attachment.tags' + - '"snake_case" in attachment.tags' + - '"Tag with Space" in attachment.tags' + - attachment.tags.Name == attachment_name + - attachment.tags.CamelCase == 'CamelCaseValue' + - attachment.tags.pascalCase == 'pascalCaseValue' + - attachment.tags.snake_case == 'snake_case_value 2' + - attachment.tags['Tag with Space'] == 'value with space 2' + - attachment.vpc_owner_id == vpc_owner_a + vars: + attachment: '{{ simple_attach.attachments[0] }}' + + - name: '(CHECK_MODE) Update tags -- IDEMPOTENCY' + check_mode: True + ec2_transit_gateway_vpc_attachment: + name: '{{ attachment_name }}' + purge_tags: False + tags: + snake_case: snake_case_value 2 + "Tag with Space": value with space 2 + register: simple_attach + + - assert: + that: + - simple_attach is not changed + - '"attachments" in simple_attach' + - simple_attach.attachments | length == 1 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length == 1 + - subnet_id_a_1 in attachment.subnet_ids + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_a + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - attachment.options.appliance_mode_support == 'disable' + - attachment.options.dns_support == 'enable' + - attachment.options.ipv6_support == 'disable' + - attachment.state == 'available' + - attachment.transit_gateway_attachment_id == simple_attachment_id + - attachment.tags | length == 5 + - '"Name" in attachment.tags' + - '"CamelCase" in attachment.tags' + - '"pascalCase" in attachment.tags' + - '"snake_case" in attachment.tags' + - '"Tag with Space" in attachment.tags' + - attachment.tags.Name == attachment_name + - attachment.tags.CamelCase == 'CamelCaseValue' + - attachment.tags.pascalCase == 'pascalCaseValue' + - attachment.tags.snake_case == 'snake_case_value 2' + - attachment.tags['Tag with Space'] == 'value with space 2' + - attachment.vpc_owner_id == vpc_owner_a + vars: + attachment: '{{ simple_attach.attachments[0] }}' + + - name: 'Update tags -- IDEMPOTENCY' + ec2_transit_gateway_vpc_attachment: + name: '{{ attachment_name }}' + purge_tags: False + tags: + snake_case: snake_case_value 2 + "Tag with Space": value with space 2 + register: simple_attach + + - assert: + that: + - simple_attach is not changed + - '"attachments" in simple_attach' + - simple_attach.attachments | length == 1 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length == 1 + - subnet_id_a_1 in attachment.subnet_ids + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_a + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - attachment.options.appliance_mode_support == 'disable' + - attachment.options.dns_support == 'enable' + - attachment.options.ipv6_support == 'disable' + - attachment.state == 'available' + - attachment.transit_gateway_attachment_id == simple_attachment_id + - attachment.tags | length == 5 + - '"Name" in attachment.tags' + - '"CamelCase" in attachment.tags' + - '"pascalCase" in attachment.tags' + - '"snake_case" in attachment.tags' + - '"Tag with Space" in attachment.tags' + - attachment.tags.Name == attachment_name + - attachment.tags.CamelCase == 'CamelCaseValue' + - attachment.tags.pascalCase == 'pascalCaseValue' + - attachment.tags.snake_case == 'snake_case_value 2' + - attachment.tags['Tag with Space'] == 'value with space 2' + - attachment.vpc_owner_id == vpc_owner_a + vars: + attachment: '{{ simple_attach.attachments[0] }}' + +# ===== + + - name: '(CHECK_MODE) Remove tags' + check_mode: True + ec2_transit_gateway_vpc_attachment: + name: '{{ attachment_name }}' + tags: + CamelCase: CamelCaseValue + pascalCase: pascalCaseValue + register: simple_attach + + - assert: + that: + - simple_attach is changed + - '"attachments" in simple_attach' + - simple_attach.attachments | length == 1 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length == 1 + - subnet_id_a_1 in attachment.subnet_ids + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_a + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - attachment.options.appliance_mode_support == 'disable' + - attachment.options.dns_support == 'enable' + - attachment.options.ipv6_support == 'disable' + - attachment.state == 'available' + - attachment.transit_gateway_attachment_id == simple_attachment_id + - attachment.tags | length == 3 + - '"Name" in attachment.tags' + - '"CamelCase" in attachment.tags' + - '"pascalCase" in attachment.tags' + - attachment.tags.Name == attachment_name + - attachment.tags.CamelCase == 'CamelCaseValue' + - attachment.tags.pascalCase == 'pascalCaseValue' + - attachment.vpc_owner_id == vpc_owner_a + vars: + attachment: '{{ simple_attach.attachments[0] }}' + + - name: 'Remove tags' + ec2_transit_gateway_vpc_attachment: + name: '{{ attachment_name }}' + tags: + CamelCase: CamelCaseValue + pascalCase: pascalCaseValue + register: simple_attach + + - assert: + that: + - simple_attach is changed + - '"attachments" in simple_attach' + - simple_attach.attachments | length == 1 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length == 1 + - subnet_id_a_1 in attachment.subnet_ids + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_a + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - attachment.options.appliance_mode_support == 'disable' + - attachment.options.dns_support == 'enable' + - attachment.options.ipv6_support == 'disable' + - attachment.state == 'available' + - attachment.transit_gateway_attachment_id == simple_attachment_id + - attachment.tags | length == 3 + - '"Name" in attachment.tags' + - '"CamelCase" in attachment.tags' + - '"pascalCase" in attachment.tags' + - attachment.tags.Name == attachment_name + - attachment.tags.CamelCase == 'CamelCaseValue' + - attachment.tags.pascalCase == 'pascalCaseValue' + - attachment.vpc_owner_id == vpc_owner_a + vars: + attachment: '{{ simple_attach.attachments[0] }}' + + - name: '(CHECK_MODE) Remove tags -- IDEMPOTENCY' + check_mode: True + ec2_transit_gateway_vpc_attachment: + name: '{{ attachment_name }}' + tags: + CamelCase: CamelCaseValue + pascalCase: pascalCaseValue + register: simple_attach + + - assert: + that: + - simple_attach is not changed + - '"attachments" in simple_attach' + - simple_attach.attachments | length == 1 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length == 1 + - subnet_id_a_1 in attachment.subnet_ids + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_a + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - attachment.options.appliance_mode_support == 'disable' + - attachment.options.dns_support == 'enable' + - attachment.options.ipv6_support == 'disable' + - attachment.state == 'available' + - attachment.transit_gateway_attachment_id == simple_attachment_id + - attachment.tags | length == 3 + - '"Name" in attachment.tags' + - '"CamelCase" in attachment.tags' + - '"pascalCase" in attachment.tags' + - attachment.tags.Name == attachment_name + - attachment.tags.CamelCase == 'CamelCaseValue' + - attachment.tags.pascalCase == 'pascalCaseValue' + - attachment.vpc_owner_id == vpc_owner_a + vars: + attachment: '{{ simple_attach.attachments[0] }}' + + - name: 'Remove tags -- IDEMPOTENCY' + ec2_transit_gateway_vpc_attachment: + name: '{{ attachment_name }}' + tags: + CamelCase: CamelCaseValue + pascalCase: pascalCaseValue + register: simple_attach + + - assert: + that: + - simple_attach is not changed + - '"attachments" in simple_attach' + - simple_attach.attachments | length == 1 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length == 1 + - subnet_id_a_1 in attachment.subnet_ids + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_a + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - attachment.options.appliance_mode_support == 'disable' + - attachment.options.dns_support == 'enable' + - attachment.options.ipv6_support == 'disable' + - attachment.state == 'available' + - attachment.transit_gateway_attachment_id == simple_attachment_id + - attachment.tags | length == 3 + - '"Name" in attachment.tags' + - '"CamelCase" in attachment.tags' + - '"pascalCase" in attachment.tags' + - attachment.tags.Name == attachment_name + - attachment.tags.CamelCase == 'CamelCaseValue' + - attachment.tags.pascalCase == 'pascalCaseValue' + - attachment.vpc_owner_id == vpc_owner_a + vars: + attachment: '{{ simple_attach.attachments[0] }}' + +# ===== + + - name: '(CHECK_MODE) Add tags with no purge' + check_mode: True + ec2_transit_gateway_vpc_attachment: + name: '{{ attachment_name }}' + purge_tags: False + tags: + AnotherTag: Another Value + register: simple_attach + + - assert: + that: + - simple_attach is changed + - '"attachments" in simple_attach' + - simple_attach.attachments | length == 1 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length == 1 + - subnet_id_a_1 in attachment.subnet_ids + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_a + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - attachment.options.appliance_mode_support == 'disable' + - attachment.options.dns_support == 'enable' + - attachment.options.ipv6_support == 'disable' + - attachment.state == 'available' + - attachment.transit_gateway_attachment_id == simple_attachment_id + - attachment.tags | length == 4 + - '"Name" in attachment.tags' + - '"CamelCase" in attachment.tags' + - '"pascalCase" in attachment.tags' + - '"AnotherTag" in attachment.tags' + - attachment.tags.Name == attachment_name + - attachment.tags.CamelCase == 'CamelCaseValue' + - attachment.tags.pascalCase == 'pascalCaseValue' + - attachment.tags.AnotherTag == 'Another Value' + - attachment.vpc_owner_id == vpc_owner_a + vars: + attachment: '{{ simple_attach.attachments[0] }}' + + - name: 'Add tags with no purge' + ec2_transit_gateway_vpc_attachment: + name: '{{ attachment_name }}' + purge_tags: False + tags: + AnotherTag: Another Value + register: simple_attach + + - assert: + that: + - simple_attach is changed + - '"attachments" in simple_attach' + - simple_attach.attachments | length == 1 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length == 1 + - subnet_id_a_1 in attachment.subnet_ids + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_a + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - attachment.options.appliance_mode_support == 'disable' + - attachment.options.dns_support == 'enable' + - attachment.options.ipv6_support == 'disable' + - attachment.state == 'available' + - attachment.transit_gateway_attachment_id == simple_attachment_id + - attachment.tags | length == 4 + - '"Name" in attachment.tags' + - '"CamelCase" in attachment.tags' + - '"pascalCase" in attachment.tags' + - '"AnotherTag" in attachment.tags' + - attachment.tags.Name == attachment_name + - attachment.tags.CamelCase == 'CamelCaseValue' + - attachment.tags.pascalCase == 'pascalCaseValue' + - attachment.tags.AnotherTag == 'Another Value' + - attachment.vpc_owner_id == vpc_owner_a + vars: + attachment: '{{ simple_attach.attachments[0] }}' + + - name: '(CHECK_MODE) Add tags with no purge -- IDEMPOTENCY' + check_mode: True + ec2_transit_gateway_vpc_attachment: + name: '{{ attachment_name }}' + purge_tags: False + tags: + AnotherTag: Another Value + register: simple_attach + + - assert: + that: + - simple_attach is not changed + - '"attachments" in simple_attach' + - simple_attach.attachments | length == 1 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length == 1 + - subnet_id_a_1 in attachment.subnet_ids + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_a + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - attachment.options.appliance_mode_support == 'disable' + - attachment.options.dns_support == 'enable' + - attachment.options.ipv6_support == 'disable' + - attachment.state == 'available' + - attachment.transit_gateway_attachment_id == simple_attachment_id + - attachment.tags | length == 4 + - '"Name" in attachment.tags' + - '"CamelCase" in attachment.tags' + - '"pascalCase" in attachment.tags' + - '"AnotherTag" in attachment.tags' + - attachment.tags.Name == attachment_name + - attachment.tags.CamelCase == 'CamelCaseValue' + - attachment.tags.pascalCase == 'pascalCaseValue' + - attachment.tags.AnotherTag == 'Another Value' + - attachment.vpc_owner_id == vpc_owner_a + vars: + attachment: '{{ simple_attach.attachments[0] }}' + + - name: 'Add tags with no purge -- IDEMPOTENCY' + ec2_transit_gateway_vpc_attachment: + name: '{{ attachment_name }}' + purge_tags: False + tags: + AnotherTag: Another Value + register: simple_attach + + - assert: + that: + - simple_attach is not changed + - '"attachments" in simple_attach' + - simple_attach.attachments | length == 1 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length == 1 + - subnet_id_a_1 in attachment.subnet_ids + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_a + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - attachment.options.appliance_mode_support == 'disable' + - attachment.options.dns_support == 'enable' + - attachment.options.ipv6_support == 'disable' + - attachment.state == 'available' + - attachment.transit_gateway_attachment_id == simple_attachment_id + - attachment.tags | length == 4 + - '"Name" in attachment.tags' + - '"CamelCase" in attachment.tags' + - '"pascalCase" in attachment.tags' + - '"AnotherTag" in attachment.tags' + - attachment.tags.Name == attachment_name + - attachment.tags.CamelCase == 'CamelCaseValue' + - attachment.tags.pascalCase == 'pascalCaseValue' + - attachment.tags.AnotherTag == 'Another Value' + - attachment.vpc_owner_id == vpc_owner_a + vars: + attachment: '{{ simple_attach.attachments[0] }}' + +# ===== + + - name: '(CHECK_MODE) Remove all tags with name set' + check_mode: True + ec2_transit_gateway_vpc_attachment: + name: '{{ attachment_name }}' + tags: {} + register: simple_attach + + - assert: + that: + - simple_attach is changed + - '"attachments" in simple_attach' + - simple_attach.attachments | length == 1 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length == 1 + - subnet_id_a_1 in attachment.subnet_ids + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_a + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - attachment.options.appliance_mode_support == 'disable' + - attachment.options.dns_support == 'enable' + - attachment.options.ipv6_support == 'disable' + - attachment.state == 'available' + - attachment.transit_gateway_attachment_id == simple_attachment_id + - attachment.tags | length == 1 + - '"Name" in attachment.tags' + - attachment.tags.Name == attachment_name + - attachment.vpc_owner_id == vpc_owner_a + vars: + attachment: '{{ simple_attach.attachments[0] }}' + + - name: 'Remove all tags with name set' + ec2_transit_gateway_vpc_attachment: + name: '{{ attachment_name }}' + tags: {} + register: simple_attach + + - assert: + that: + - simple_attach is changed + - '"attachments" in simple_attach' + - simple_attach.attachments | length == 1 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length == 1 + - subnet_id_a_1 in attachment.subnet_ids + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_a + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - attachment.options.appliance_mode_support == 'disable' + - attachment.options.dns_support == 'enable' + - attachment.options.ipv6_support == 'disable' + - attachment.state == 'available' + - attachment.transit_gateway_attachment_id == simple_attachment_id + - attachment.tags | length == 1 + - '"Name" in attachment.tags' + - attachment.tags.Name == attachment_name + - attachment.vpc_owner_id == vpc_owner_a + vars: + attachment: '{{ simple_attach.attachments[0] }}' + + - name: '(CHECK_MODE) Remove all tags with name set -- IDEMPOTENCY' + check_mode: True + ec2_transit_gateway_vpc_attachment: + name: '{{ attachment_name }}' + tags: {} + register: simple_attach + + - assert: + that: + - simple_attach is not changed + - '"attachments" in simple_attach' + - simple_attach.attachments | length == 1 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length == 1 + - subnet_id_a_1 in attachment.subnet_ids + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_a + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - attachment.options.appliance_mode_support == 'disable' + - attachment.options.dns_support == 'enable' + - attachment.options.ipv6_support == 'disable' + - attachment.state == 'available' + - attachment.transit_gateway_attachment_id == simple_attachment_id + - attachment.tags | length == 1 + - '"Name" in attachment.tags' + - attachment.tags.Name == attachment_name + - attachment.vpc_owner_id == vpc_owner_a + vars: + attachment: '{{ simple_attach.attachments[0] }}' + + - name: 'Remove all tags with name set -- IDEMPOTENCY' + ec2_transit_gateway_vpc_attachment: + name: '{{ attachment_name }}' + tags: {} + register: simple_attach + + - assert: + that: + - simple_attach is not changed + - '"attachments" in simple_attach' + - simple_attach.attachments | length == 1 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length == 1 + - subnet_id_a_1 in attachment.subnet_ids + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_a + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - attachment.options.appliance_mode_support == 'disable' + - attachment.options.dns_support == 'enable' + - attachment.options.ipv6_support == 'disable' + - attachment.state == 'available' + - attachment.transit_gateway_attachment_id == simple_attachment_id + - attachment.tags | length == 1 + - '"Name" in attachment.tags' + - attachment.tags.Name == attachment_name + - attachment.vpc_owner_id == vpc_owner_a + vars: + attachment: '{{ simple_attach.attachments[0] }}' + +# ===== + + - name: '(CHECK_MODE) Remove all tags including name' + check_mode: True + ec2_transit_gateway_vpc_attachment: + id: '{{ simple_attachment_id }}' + tags: {} + register: simple_attach + + - assert: + that: + - simple_attach is changed + - '"attachments" in simple_attach' + - simple_attach.attachments | length == 1 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length == 1 + - subnet_id_a_1 in attachment.subnet_ids + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_a + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - attachment.options.appliance_mode_support == 'disable' + - attachment.options.dns_support == 'enable' + - attachment.options.ipv6_support == 'disable' + - attachment.state == 'available' + - attachment.transit_gateway_attachment_id == simple_attachment_id + - attachment.tags | length == 0 + - attachment.vpc_owner_id == vpc_owner_a + vars: + attachment: '{{ simple_attach.attachments[0] }}' + + - name: 'Remove all tags including name' + ec2_transit_gateway_vpc_attachment: + id: '{{ simple_attachment_id }}' + tags: {} + register: simple_attach + + - assert: + that: + - simple_attach is changed + - '"attachments" in simple_attach' + - simple_attach.attachments | length == 1 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length == 1 + - subnet_id_a_1 in attachment.subnet_ids + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_a + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - attachment.options.appliance_mode_support == 'disable' + - attachment.options.dns_support == 'enable' + - attachment.options.ipv6_support == 'disable' + - attachment.state == 'available' + - attachment.transit_gateway_attachment_id == simple_attachment_id + - attachment.tags | length == 0 + - attachment.vpc_owner_id == vpc_owner_a + vars: + attachment: '{{ simple_attach.attachments[0] }}' + + - name: '(CHECK_MODE) Remove all tags including name -- IDEMPOTENCY' + check_mode: True + ec2_transit_gateway_vpc_attachment: + id: '{{ simple_attachment_id }}' + tags: {} + register: simple_attach + + - assert: + that: + - simple_attach is not changed + - '"attachments" in simple_attach' + - simple_attach.attachments | length == 1 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length == 1 + - subnet_id_a_1 in attachment.subnet_ids + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_a + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - attachment.options.appliance_mode_support == 'disable' + - attachment.options.dns_support == 'enable' + - attachment.options.ipv6_support == 'disable' + - attachment.state == 'available' + - attachment.transit_gateway_attachment_id == simple_attachment_id + - attachment.tags | length == 0 + - attachment.vpc_owner_id == vpc_owner_a + vars: + attachment: '{{ simple_attach.attachments[0] }}' + + - name: 'Remove all tags including name -- IDEMPOTENCY' + ec2_transit_gateway_vpc_attachment: + id: '{{ simple_attachment_id }}' + tags: {} + register: simple_attach + + - assert: + that: + - simple_attach is not changed + - '"attachments" in simple_attach' + - simple_attach.attachments | length == 1 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length == 1 + - subnet_id_a_1 in attachment.subnet_ids + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_a + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - attachment.options.appliance_mode_support == 'disable' + - attachment.options.dns_support == 'enable' + - attachment.options.ipv6_support == 'disable' + - attachment.state == 'available' + - attachment.transit_gateway_attachment_id == simple_attachment_id + - attachment.tags | length == 0 + - attachment.vpc_owner_id == vpc_owner_a + vars: + attachment: '{{ simple_attach.attachments[0] }}' + +# ============================================================================= +# Options + + - name: '(CHECK_MODE) Set IPv6 support' + check_mode: True + ec2_transit_gateway_vpc_attachment: + id: '{{ simple_attachment_id }}' + ipv6_support: True + register: simple_attach + + - assert: + that: + - simple_attach is changed + - '"attachments" in simple_attach' + - simple_attach.attachments | length == 1 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length == 1 + - subnet_id_a_1 in attachment.subnet_ids + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_a + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - attachment.options.appliance_mode_support == 'disable' + - attachment.options.dns_support == 'enable' + - attachment.options.ipv6_support == 'enable' + - attachment.state == 'available' + - attachment.transit_gateway_attachment_id == simple_attachment_id + - attachment.tags | length == 0 + - attachment.vpc_owner_id == vpc_owner_a + vars: + attachment: '{{ simple_attach.attachments[0] }}' + + - name: 'Set IPv6 support' + ec2_transit_gateway_vpc_attachment: + id: '{{ simple_attachment_id }}' + ipv6_support: True + register: simple_attach + + - assert: + that: + - simple_attach is changed + - '"attachments" in simple_attach' + - simple_attach.attachments | length == 1 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length == 1 + - subnet_id_a_1 in attachment.subnet_ids + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_a + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - attachment.options.appliance_mode_support == 'disable' + - attachment.options.dns_support == 'enable' + - attachment.options.ipv6_support == 'enable' + - attachment.state == 'available' + - attachment.transit_gateway_attachment_id == simple_attachment_id + - attachment.tags | length == 0 + - attachment.vpc_owner_id == vpc_owner_a + vars: + attachment: '{{ simple_attach.attachments[0] }}' + + - name: '(CHECK_MODE) Set IPv6 support -- IDEMPOTENCY' + check_mode: True + ec2_transit_gateway_vpc_attachment: + id: '{{ simple_attachment_id }}' + ipv6_support: True + register: simple_attach + + - assert: + that: + - simple_attach is not changed + - '"attachments" in simple_attach' + - simple_attach.attachments | length == 1 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length == 1 + - subnet_id_a_1 in attachment.subnet_ids + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_a + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - attachment.options.appliance_mode_support == 'disable' + - attachment.options.dns_support == 'enable' + - attachment.options.ipv6_support == 'enable' + - attachment.state == 'available' + - attachment.transit_gateway_attachment_id == simple_attachment_id + - attachment.tags | length == 0 + - attachment.vpc_owner_id == vpc_owner_a + vars: + attachment: '{{ simple_attach.attachments[0] }}' + + - name: 'Set IPv6 support -- IDEMPOTENCY' + ec2_transit_gateway_vpc_attachment: + id: '{{ simple_attachment_id }}' + ipv6_support: True + register: simple_attach + + - assert: + that: + - simple_attach is not changed + - '"attachments" in simple_attach' + - simple_attach.attachments | length == 1 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length == 1 + - subnet_id_a_1 in attachment.subnet_ids + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_a + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - attachment.options.appliance_mode_support == 'disable' + - attachment.options.dns_support == 'enable' + - attachment.options.ipv6_support == 'enable' + - attachment.state == 'available' + - attachment.transit_gateway_attachment_id == simple_attachment_id + - attachment.tags | length == 0 + - attachment.vpc_owner_id == vpc_owner_a + vars: + attachment: '{{ simple_attach.attachments[0] }}' + +# ===== + + - name: '(CHECK_MODE) Set DNS support' + check_mode: True + ec2_transit_gateway_vpc_attachment: + id: '{{ simple_attachment_id }}' + dns_support: False + register: simple_attach + + - assert: + that: + - simple_attach is changed + - '"attachments" in simple_attach' + - simple_attach.attachments | length == 1 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length == 1 + - subnet_id_a_1 in attachment.subnet_ids + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_a + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - attachment.options.appliance_mode_support == 'disable' + - attachment.options.dns_support == 'disable' + - attachment.options.ipv6_support == 'enable' + - attachment.state == 'available' + - attachment.transit_gateway_attachment_id == simple_attachment_id + - attachment.tags | length == 0 + - attachment.vpc_owner_id == vpc_owner_a + vars: + attachment: '{{ simple_attach.attachments[0] }}' + + - name: 'Set DNS support' + ec2_transit_gateway_vpc_attachment: + id: '{{ simple_attachment_id }}' + dns_support: False + register: simple_attach + + - assert: + that: + - simple_attach is changed + - '"attachments" in simple_attach' + - simple_attach.attachments | length == 1 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length == 1 + - subnet_id_a_1 in attachment.subnet_ids + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_a + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - attachment.options.appliance_mode_support == 'disable' + - attachment.options.dns_support == 'disable' + - attachment.options.ipv6_support == 'enable' + - attachment.state == 'available' + - attachment.transit_gateway_attachment_id == simple_attachment_id + - attachment.tags | length == 0 + - attachment.vpc_owner_id == vpc_owner_a + vars: + attachment: '{{ simple_attach.attachments[0] }}' + + - name: '(CHECK_MODE) Set DNS support -- IDEMPOTENCY' + check_mode: True + ec2_transit_gateway_vpc_attachment: + id: '{{ simple_attachment_id }}' + dns_support: False + register: simple_attach + + - assert: + that: + - simple_attach is not changed + - '"attachments" in simple_attach' + - simple_attach.attachments | length == 1 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length == 1 + - subnet_id_a_1 in attachment.subnet_ids + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_a + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - attachment.options.appliance_mode_support == 'disable' + - attachment.options.dns_support == 'disable' + - attachment.options.ipv6_support == 'enable' + - attachment.state == 'available' + - attachment.transit_gateway_attachment_id == simple_attachment_id + - attachment.tags | length == 0 + - attachment.vpc_owner_id == vpc_owner_a + vars: + attachment: '{{ simple_attach.attachments[0] }}' + + - name: 'Set DNS support -- IDEMPOTENCY' + ec2_transit_gateway_vpc_attachment: + id: '{{ simple_attachment_id }}' + dns_support: False + register: simple_attach + + - assert: + that: + - simple_attach is not changed + - '"attachments" in simple_attach' + - simple_attach.attachments | length == 1 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length == 1 + - subnet_id_a_1 in attachment.subnet_ids + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_a + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - attachment.options.appliance_mode_support == 'disable' + - attachment.options.dns_support == 'disable' + - attachment.options.ipv6_support == 'enable' + - attachment.state == 'available' + - attachment.transit_gateway_attachment_id == simple_attachment_id + - attachment.tags | length == 0 + - attachment.vpc_owner_id == vpc_owner_a + vars: + attachment: '{{ simple_attach.attachments[0] }}' + +# ===== + + - name: '(CHECK_MODE) Set Appliance Mode support' + check_mode: True + ec2_transit_gateway_vpc_attachment: + id: '{{ simple_attachment_id }}' + appliance_mode_support: True + register: simple_attach + + - assert: + that: + - simple_attach is changed + - '"attachments" in simple_attach' + - simple_attach.attachments | length == 1 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length == 1 + - subnet_id_a_1 in attachment.subnet_ids + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_a + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - attachment.options.appliance_mode_support == 'enable' + - attachment.options.dns_support == 'disable' + - attachment.options.ipv6_support == 'enable' + - attachment.state == 'available' + - attachment.transit_gateway_attachment_id == simple_attachment_id + - attachment.tags | length == 0 + - attachment.vpc_owner_id == vpc_owner_a + vars: + attachment: '{{ simple_attach.attachments[0] }}' + + - name: 'Set Appliance Mode support' + ec2_transit_gateway_vpc_attachment: + id: '{{ simple_attachment_id }}' + appliance_mode_support: True + register: simple_attach + + - assert: + that: + - simple_attach is changed + - '"attachments" in simple_attach' + - simple_attach.attachments | length == 1 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length == 1 + - subnet_id_a_1 in attachment.subnet_ids + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_a + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - attachment.options.appliance_mode_support == 'enable' + - attachment.options.dns_support == 'disable' + - attachment.options.ipv6_support == 'enable' + - attachment.state == 'available' + - attachment.transit_gateway_attachment_id == simple_attachment_id + - attachment.tags | length == 0 + - attachment.vpc_owner_id == vpc_owner_a + vars: + attachment: '{{ simple_attach.attachments[0] }}' + + - name: '(CHECK_MODE) Set Appliance Mode support -- IDEMPOTENCY' + check_mode: True + ec2_transit_gateway_vpc_attachment: + id: '{{ simple_attachment_id }}' + appliance_mode_support: True + register: simple_attach + + - assert: + that: + - simple_attach is not changed + - '"attachments" in simple_attach' + - simple_attach.attachments | length == 1 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length == 1 + - subnet_id_a_1 in attachment.subnet_ids + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_a + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - attachment.options.appliance_mode_support == 'enable' + - attachment.options.dns_support == 'disable' + - attachment.options.ipv6_support == 'enable' + - attachment.state == 'available' + - attachment.transit_gateway_attachment_id == simple_attachment_id + - attachment.tags | length == 0 + - attachment.vpc_owner_id == vpc_owner_a + vars: + attachment: '{{ simple_attach.attachments[0] }}' + + - name: 'Set Appliance Mode support -- IDEMPOTENCY' + ec2_transit_gateway_vpc_attachment: + id: '{{ simple_attachment_id }}' + appliance_mode_support: True + register: simple_attach + + - assert: + that: + - simple_attach is not changed + - '"attachments" in simple_attach' + - simple_attach.attachments | length == 1 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length == 1 + - subnet_id_a_1 in attachment.subnet_ids + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_a + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - attachment.options.appliance_mode_support == 'enable' + - attachment.options.dns_support == 'disable' + - attachment.options.ipv6_support == 'enable' + - attachment.state == 'available' + - attachment.transit_gateway_attachment_id == simple_attachment_id + - attachment.tags | length == 0 + - attachment.vpc_owner_id == vpc_owner_a + vars: + attachment: '{{ simple_attach.attachments[0] }}' + +# ===== + + - name: '(CHECK_MODE) Update IPv6 support' + check_mode: True + ec2_transit_gateway_vpc_attachment: + id: '{{ simple_attachment_id }}' + ipv6_support: False + register: simple_attach + + - assert: + that: + - simple_attach is changed + - '"attachments" in simple_attach' + - simple_attach.attachments | length == 1 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length == 1 + - subnet_id_a_1 in attachment.subnet_ids + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_a + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - attachment.options.appliance_mode_support == 'enable' + - attachment.options.dns_support == 'disable' + - attachment.options.ipv6_support == 'disable' + - attachment.state == 'available' + - attachment.transit_gateway_attachment_id == simple_attachment_id + - attachment.tags | length == 0 + - attachment.vpc_owner_id == vpc_owner_a + vars: + attachment: '{{ simple_attach.attachments[0] }}' + + - name: 'Update IPv6 support' + ec2_transit_gateway_vpc_attachment: + id: '{{ simple_attachment_id }}' + ipv6_support: False + register: simple_attach + + - assert: + that: + - simple_attach is changed + - '"attachments" in simple_attach' + - simple_attach.attachments | length == 1 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length == 1 + - subnet_id_a_1 in attachment.subnet_ids + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_a + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - attachment.options.appliance_mode_support == 'enable' + - attachment.options.dns_support == 'disable' + - attachment.options.ipv6_support == 'disable' + - attachment.state == 'available' + - attachment.transit_gateway_attachment_id == simple_attachment_id + - attachment.tags | length == 0 + - attachment.vpc_owner_id == vpc_owner_a + vars: + attachment: '{{ simple_attach.attachments[0] }}' + + - name: '(CHECK_MODE) Update IPv6 support -- IDEMPOTENCY' + check_mode: True + ec2_transit_gateway_vpc_attachment: + id: '{{ simple_attachment_id }}' + ipv6_support: False + register: simple_attach + + - assert: + that: + - simple_attach is not changed + - '"attachments" in simple_attach' + - simple_attach.attachments | length == 1 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length == 1 + - subnet_id_a_1 in attachment.subnet_ids + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_a + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - attachment.options.appliance_mode_support == 'enable' + - attachment.options.dns_support == 'disable' + - attachment.options.ipv6_support == 'disable' + - attachment.state == 'available' + - attachment.transit_gateway_attachment_id == simple_attachment_id + - attachment.tags | length == 0 + - attachment.vpc_owner_id == vpc_owner_a + vars: + attachment: '{{ simple_attach.attachments[0] }}' + + - name: 'Update IPv6 support -- IDEMPOTENCY' + ec2_transit_gateway_vpc_attachment: + id: '{{ simple_attachment_id }}' + ipv6_support: False + register: simple_attach + + - assert: + that: + - simple_attach is not changed + - '"attachments" in simple_attach' + - simple_attach.attachments | length == 1 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length == 1 + - subnet_id_a_1 in attachment.subnet_ids + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_a + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - attachment.options.appliance_mode_support == 'enable' + - attachment.options.dns_support == 'disable' + - attachment.options.ipv6_support == 'disable' + - attachment.state == 'available' + - attachment.transit_gateway_attachment_id == simple_attachment_id + - attachment.tags | length == 0 + - attachment.vpc_owner_id == vpc_owner_a + vars: + attachment: '{{ simple_attach.attachments[0] }}' + +# ===== + + - name: '(CHECK_MODE) Update DNS support' + check_mode: True + ec2_transit_gateway_vpc_attachment: + id: '{{ simple_attachment_id }}' + dns_support: True + register: simple_attach + + - assert: + that: + - simple_attach is changed + - '"attachments" in simple_attach' + - simple_attach.attachments | length == 1 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length == 1 + - subnet_id_a_1 in attachment.subnet_ids + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_a + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - attachment.options.appliance_mode_support == 'enable' + - attachment.options.dns_support == 'enable' + - attachment.options.ipv6_support == 'disable' + - attachment.state == 'available' + - attachment.transit_gateway_attachment_id == simple_attachment_id + - attachment.tags | length == 0 + - attachment.vpc_owner_id == vpc_owner_a + vars: + attachment: '{{ simple_attach.attachments[0] }}' + + - name: 'Update DNS support' + ec2_transit_gateway_vpc_attachment: + id: '{{ simple_attachment_id }}' + dns_support: True + register: simple_attach + + - assert: + that: + - simple_attach is changed + - '"attachments" in simple_attach' + - simple_attach.attachments | length == 1 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length == 1 + - subnet_id_a_1 in attachment.subnet_ids + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_a + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - attachment.options.appliance_mode_support == 'enable' + - attachment.options.dns_support == 'enable' + - attachment.options.ipv6_support == 'disable' + - attachment.state == 'available' + - attachment.transit_gateway_attachment_id == simple_attachment_id + - attachment.tags | length == 0 + - attachment.vpc_owner_id == vpc_owner_a + vars: + attachment: '{{ simple_attach.attachments[0] }}' + + - name: '(CHECK_MODE) Update DNS support -- IDEMPOTENCY' + check_mode: True + ec2_transit_gateway_vpc_attachment: + id: '{{ simple_attachment_id }}' + dns_support: True + register: simple_attach + + - assert: + that: + - simple_attach is not changed + - '"attachments" in simple_attach' + - simple_attach.attachments | length == 1 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length == 1 + - subnet_id_a_1 in attachment.subnet_ids + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_a + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - attachment.options.appliance_mode_support == 'enable' + - attachment.options.dns_support == 'enable' + - attachment.options.ipv6_support == 'disable' + - attachment.state == 'available' + - attachment.transit_gateway_attachment_id == simple_attachment_id + - attachment.tags | length == 0 + - attachment.vpc_owner_id == vpc_owner_a + vars: + attachment: '{{ simple_attach.attachments[0] }}' + + - name: 'Update DNS support -- IDEMPOTENCY' + ec2_transit_gateway_vpc_attachment: + id: '{{ simple_attachment_id }}' + dns_support: True + register: simple_attach + + - assert: + that: + - simple_attach is not changed + - '"attachments" in simple_attach' + - simple_attach.attachments | length == 1 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length == 1 + - subnet_id_a_1 in attachment.subnet_ids + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_a + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - attachment.options.appliance_mode_support == 'enable' + - attachment.options.dns_support == 'enable' + - attachment.options.ipv6_support == 'disable' + - attachment.state == 'available' + - attachment.transit_gateway_attachment_id == simple_attachment_id + - attachment.tags | length == 0 + - attachment.vpc_owner_id == vpc_owner_a + vars: + attachment: '{{ simple_attach.attachments[0] }}' + +# ===== + + - name: '(CHECK_MODE) Update Appliance Mode support' + check_mode: True + ec2_transit_gateway_vpc_attachment: + id: '{{ simple_attachment_id }}' + appliance_mode_support: False + register: simple_attach + + - assert: + that: + - simple_attach is changed + - '"attachments" in simple_attach' + - simple_attach.attachments | length == 1 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length == 1 + - subnet_id_a_1 in attachment.subnet_ids + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_a + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - attachment.options.appliance_mode_support == 'disable' + - attachment.options.dns_support == 'enable' + - attachment.options.ipv6_support == 'disable' + - attachment.state == 'available' + - attachment.transit_gateway_attachment_id == simple_attachment_id + - attachment.tags | length == 0 + - attachment.vpc_owner_id == vpc_owner_a + vars: + attachment: '{{ simple_attach.attachments[0] }}' + + - name: 'Update Appliance Mode support' + ec2_transit_gateway_vpc_attachment: + id: '{{ simple_attachment_id }}' + appliance_mode_support: False + register: simple_attach + + - assert: + that: + - simple_attach is changed + - '"attachments" in simple_attach' + - simple_attach.attachments | length == 1 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length == 1 + - subnet_id_a_1 in attachment.subnet_ids + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_a + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - attachment.options.appliance_mode_support == 'disable' + - attachment.options.dns_support == 'enable' + - attachment.options.ipv6_support == 'disable' + - attachment.state == 'available' + - attachment.transit_gateway_attachment_id == simple_attachment_id + - attachment.tags | length == 0 + - attachment.vpc_owner_id == vpc_owner_a + vars: + attachment: '{{ simple_attach.attachments[0] }}' + + - name: '(CHECK_MODE) Update Appliance Mode support -- IDEMPOTENCY' + check_mode: True + ec2_transit_gateway_vpc_attachment: + id: '{{ simple_attachment_id }}' + appliance_mode_support: False + register: simple_attach + + - assert: + that: + - simple_attach is not changed + - '"attachments" in simple_attach' + - simple_attach.attachments | length == 1 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length == 1 + - subnet_id_a_1 in attachment.subnet_ids + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_a + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - attachment.options.appliance_mode_support == 'disable' + - attachment.options.dns_support == 'enable' + - attachment.options.ipv6_support == 'disable' + - attachment.state == 'available' + - attachment.transit_gateway_attachment_id == simple_attachment_id + - attachment.tags | length == 0 + - attachment.vpc_owner_id == vpc_owner_a + vars: + attachment: '{{ simple_attach.attachments[0] }}' + + - name: 'Update Appliance Mode support -- IDEMPOTENCY' + ec2_transit_gateway_vpc_attachment: + id: '{{ simple_attachment_id }}' + appliance_mode_support: False + register: simple_attach + + - assert: + that: + - simple_attach is not changed + - '"attachments" in simple_attach' + - simple_attach.attachments | length == 1 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length == 1 + - subnet_id_a_1 in attachment.subnet_ids + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_a + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - attachment.options.appliance_mode_support == 'disable' + - attachment.options.dns_support == 'enable' + - attachment.options.ipv6_support == 'disable' + - attachment.state == 'available' + - attachment.transit_gateway_attachment_id == simple_attachment_id + - attachment.tags | length == 0 + - attachment.vpc_owner_id == vpc_owner_a + vars: + attachment: '{{ simple_attach.attachments[0] }}' + +# ============================================================================= +# Subnet Management + + - name: '(CHECK_MODE) Try to add subnet from a different VPC - no purge' + check_mode: True + ec2_transit_gateway_vpc_attachment: + id: '{{ simple_attachment_id }}' + subnets: + - '{{ subnet_id_b_2 }}' + purge_subnets: False + register: simple_attach + ignore_errors: True + + - assert: + that: + - simple_attach is failed + + - name: 'Try to add subnet from a different VPC - no purge' + ec2_transit_gateway_vpc_attachment: + id: '{{ simple_attachment_id }}' + subnets: + - '{{ subnet_id_b_2 }}' + purge_subnets: False + register: simple_attach + ignore_errors: True + + - assert: + that: + - simple_attach is failed + +# ===== + + - name: '(CHECK_MODE) Try to add subnet from a different VPC - with purge' + check_mode: True + ec2_transit_gateway_vpc_attachment: + id: '{{ simple_attachment_id }}' + subnets: + - '{{ subnet_id_a_1 }}' + - '{{ subnet_id_b_2 }}' + purge_subnets: True + register: simple_attach + ignore_errors: True + + - assert: + that: + - simple_attach is failed + + - name: 'Try to add subnet from a different VPC - with purge' + ec2_transit_gateway_vpc_attachment: + id: '{{ simple_attachment_id }}' + subnets: + - '{{ subnet_id_a_1 }}' + - '{{ subnet_id_b_2 }}' + purge_subnets: True + register: simple_attach + ignore_errors: True + + - assert: + that: + - simple_attach is failed + +# ===== + + - name: '(CHECK_MODE) Try to add subnet in the same AZ - no purge' + check_mode: True + ec2_transit_gateway_vpc_attachment: + id: '{{ simple_attachment_id }}' + subnets: + - '{{ subnet_id_b_1a }}' + purge_subnets: False + register: simple_attach + ignore_errors: True + + - assert: + that: + - simple_attach is failed + + - name: 'Try to add subnet in the same AZ - no purge' + ec2_transit_gateway_vpc_attachment: + id: '{{ simple_attachment_id }}' + subnets: + - '{{ subnet_id_a_1a }}' + purge_subnets: False + register: simple_attach + ignore_errors: True + + - assert: + that: + - simple_attach is failed + +# ===== + + - name: '(CHECK_MODE) Try to add subnet in the same AZ - with purge' + check_mode: True + ec2_transit_gateway_vpc_attachment: + id: '{{ simple_attachment_id }}' + subnets: + - '{{ subnet_id_a_1 }}' + - '{{ subnet_id_a_1a }}' + purge_subnets: True + register: simple_attach + ignore_errors: True + + - assert: + that: + - simple_attach is failed + + - name: 'Try to add subnet in the same AZ - with purge' + ec2_transit_gateway_vpc_attachment: + id: '{{ simple_attachment_id }}' + subnets: + - '{{ subnet_id_a_1 }}' + - '{{ subnet_id_a_1a }}' + purge_subnets: True + register: simple_attach + ignore_errors: True + + - assert: + that: + - simple_attach is failed + +# ===== + + - name: '(CHECK_MODE) Add subnet - without purge' + check_mode: True + ec2_transit_gateway_vpc_attachment: + id: '{{ simple_attachment_id }}' + subnets: + - '{{ subnet_id_a_2 }}' + purge_subnets: False + register: simple_attach + + - assert: + that: + - simple_attach is changed + - '"attachments" in simple_attach' + - simple_attach.attachments | length == 1 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length == 2 + - subnet_id_a_1 in attachment.subnet_ids + - subnet_id_a_2 in attachment.subnet_ids + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_a + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - attachment.options.appliance_mode_support == 'disable' + - attachment.options.dns_support == 'enable' + - attachment.options.ipv6_support == 'disable' + - attachment.state == 'available' + - attachment.transit_gateway_attachment_id == simple_attachment_id + - attachment.tags | length == 0 + - attachment.vpc_owner_id == vpc_owner_a + vars: + attachment: '{{ simple_attach.attachments[0] }}' + + - name: 'Add subnet - without purge' + ec2_transit_gateway_vpc_attachment: + id: '{{ simple_attachment_id }}' + subnets: + - '{{ subnet_id_a_2 }}' + purge_subnets: False + register: simple_attach + + - assert: + that: + - simple_attach is changed + - '"attachments" in simple_attach' + - simple_attach.attachments | length == 1 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length == 2 + - subnet_id_a_1 in attachment.subnet_ids + - subnet_id_a_2 in attachment.subnet_ids + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_a + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - attachment.options.appliance_mode_support == 'disable' + - attachment.options.dns_support == 'enable' + - attachment.options.ipv6_support == 'disable' + - attachment.state == 'available' + - attachment.transit_gateway_attachment_id == simple_attachment_id + - attachment.tags | length == 0 + - attachment.vpc_owner_id == vpc_owner_a + vars: + attachment: '{{ simple_attach.attachments[0] }}' + + - name: '(CHECK_MODE) Add subnet - without purge -- IDEMPOTENCY' + check_mode: True + ec2_transit_gateway_vpc_attachment: + id: '{{ simple_attachment_id }}' + subnets: + - '{{ subnet_id_a_2 }}' + purge_subnets: False + register: simple_attach + + - assert: + that: + - simple_attach is not changed + - '"attachments" in simple_attach' + - simple_attach.attachments | length == 1 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length == 2 + - subnet_id_a_1 in attachment.subnet_ids + - subnet_id_a_2 in attachment.subnet_ids + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_a + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - attachment.options.appliance_mode_support == 'disable' + - attachment.options.dns_support == 'enable' + - attachment.options.ipv6_support == 'disable' + - attachment.state == 'available' + - attachment.transit_gateway_attachment_id == simple_attachment_id + - attachment.tags | length == 0 + - attachment.vpc_owner_id == vpc_owner_a + vars: + attachment: '{{ simple_attach.attachments[0] }}' + + - name: 'Add subnet - without purge -- IDEMPOTENCY' + ec2_transit_gateway_vpc_attachment: + id: '{{ simple_attachment_id }}' + subnets: + - '{{ subnet_id_a_2 }}' + purge_subnets: False + register: simple_attach + + - assert: + that: + - simple_attach is not changed + - '"attachments" in simple_attach' + - simple_attach.attachments | length == 1 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length == 2 + - subnet_id_a_1 in attachment.subnet_ids + - subnet_id_a_2 in attachment.subnet_ids + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_a + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - attachment.options.appliance_mode_support == 'disable' + - attachment.options.dns_support == 'enable' + - attachment.options.ipv6_support == 'disable' + - attachment.state == 'available' + - attachment.transit_gateway_attachment_id == simple_attachment_id + - attachment.tags | length == 0 + - attachment.vpc_owner_id == vpc_owner_a + vars: + attachment: '{{ simple_attach.attachments[0] }}' + +# ===== + + - name: '(CHECK_MODE) Add subnet - with purge' + check_mode: True + ec2_transit_gateway_vpc_attachment: + id: '{{ simple_attachment_id }}' + subnets: + - '{{ subnet_id_a_1 }}' + - '{{ subnet_id_a_2 }}' + - '{{ subnet_id_a_3 }}' + purge_subnets: True + register: simple_attach + + - assert: + that: + - simple_attach is changed + - '"attachments" in simple_attach' + - simple_attach.attachments | length == 1 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length == 3 + - subnet_id_a_1 in attachment.subnet_ids + - subnet_id_a_2 in attachment.subnet_ids + - subnet_id_a_3 in attachment.subnet_ids + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_a + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - attachment.options.appliance_mode_support == 'disable' + - attachment.options.dns_support == 'enable' + - attachment.options.ipv6_support == 'disable' + - attachment.state == 'available' + - attachment.transit_gateway_attachment_id == simple_attachment_id + - attachment.tags | length == 0 + - attachment.vpc_owner_id == vpc_owner_a + vars: + attachment: '{{ simple_attach.attachments[0] }}' + + - name: 'Add subnet - with purge' + ec2_transit_gateway_vpc_attachment: + id: '{{ simple_attachment_id }}' + subnets: + - '{{ subnet_id_a_1 }}' + - '{{ subnet_id_a_2 }}' + - '{{ subnet_id_a_3 }}' + purge_subnets: True + register: simple_attach + + - assert: + that: + - simple_attach is changed + - '"attachments" in simple_attach' + - simple_attach.attachments | length == 1 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length == 3 + - subnet_id_a_1 in attachment.subnet_ids + - subnet_id_a_2 in attachment.subnet_ids + - subnet_id_a_3 in attachment.subnet_ids + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_a + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - attachment.options.appliance_mode_support == 'disable' + - attachment.options.dns_support == 'enable' + - attachment.options.ipv6_support == 'disable' + - attachment.state == 'available' + - attachment.transit_gateway_attachment_id == simple_attachment_id + - attachment.tags | length == 0 + - attachment.vpc_owner_id == vpc_owner_a + vars: + attachment: '{{ simple_attach.attachments[0] }}' + + - name: '(CHECK_MODE) Add subnet - with purge -- IDEMPOTENCY' + check_mode: True + ec2_transit_gateway_vpc_attachment: + id: '{{ simple_attachment_id }}' + subnets: + - '{{ subnet_id_a_1 }}' + - '{{ subnet_id_a_2 }}' + - '{{ subnet_id_a_3 }}' + purge_subnets: True + register: simple_attach + + - assert: + that: + - simple_attach is not changed + - '"attachments" in simple_attach' + - simple_attach.attachments | length == 1 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length == 3 + - subnet_id_a_1 in attachment.subnet_ids + - subnet_id_a_2 in attachment.subnet_ids + - subnet_id_a_3 in attachment.subnet_ids + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_a + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - attachment.options.appliance_mode_support == 'disable' + - attachment.options.dns_support == 'enable' + - attachment.options.ipv6_support == 'disable' + - attachment.state == 'available' + - attachment.transit_gateway_attachment_id == simple_attachment_id + - attachment.tags | length == 0 + - attachment.vpc_owner_id == vpc_owner_a + vars: + attachment: '{{ simple_attach.attachments[0] }}' + + - name: 'Add subnet - with purge -- IDEMPOTENCY' + ec2_transit_gateway_vpc_attachment: + id: '{{ simple_attachment_id }}' + subnets: + - '{{ subnet_id_a_1 }}' + - '{{ subnet_id_a_2 }}' + - '{{ subnet_id_a_3 }}' + purge_subnets: True + register: simple_attach + + - assert: + that: + - simple_attach is not changed + - '"attachments" in simple_attach' + - simple_attach.attachments | length == 1 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length == 3 + - subnet_id_a_1 in attachment.subnet_ids + - subnet_id_a_2 in attachment.subnet_ids + - subnet_id_a_3 in attachment.subnet_ids + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_a + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - attachment.options.appliance_mode_support == 'disable' + - attachment.options.dns_support == 'enable' + - attachment.options.ipv6_support == 'disable' + - attachment.state == 'available' + - attachment.transit_gateway_attachment_id == simple_attachment_id + - attachment.tags | length == 0 + - attachment.vpc_owner_id == vpc_owner_a + vars: + attachment: '{{ simple_attach.attachments[0] }}' + +# ===== + + - name: '(CHECK_MODE) Remove subnet' + check_mode: True + ec2_transit_gateway_vpc_attachment: + id: '{{ simple_attachment_id }}' + subnets: + - '{{ subnet_id_a_2 }}' + - '{{ subnet_id_a_3 }}' + purge_subnets: True + register: simple_attach + + - assert: + that: + - simple_attach is changed + - '"attachments" in simple_attach' + - simple_attach.attachments | length == 1 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length == 2 + - subnet_id_a_2 in attachment.subnet_ids + - subnet_id_a_3 in attachment.subnet_ids + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_a + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - attachment.options.appliance_mode_support == 'disable' + - attachment.options.dns_support == 'enable' + - attachment.options.ipv6_support == 'disable' + - attachment.state == 'available' + - attachment.transit_gateway_attachment_id == simple_attachment_id + - attachment.tags | length == 0 + - attachment.vpc_owner_id == vpc_owner_a + vars: + attachment: '{{ simple_attach.attachments[0] }}' + + - name: 'Remove subnet' + ec2_transit_gateway_vpc_attachment: + id: '{{ simple_attachment_id }}' + subnets: + - '{{ subnet_id_a_2 }}' + - '{{ subnet_id_a_3 }}' + purge_subnets: True + register: simple_attach + + - assert: + that: + - simple_attach is changed + - '"attachments" in simple_attach' + - simple_attach.attachments | length == 1 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length == 2 + - subnet_id_a_2 in attachment.subnet_ids + - subnet_id_a_3 in attachment.subnet_ids + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_a + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - attachment.options.appliance_mode_support == 'disable' + - attachment.options.dns_support == 'enable' + - attachment.options.ipv6_support == 'disable' + - attachment.state == 'available' + - attachment.transit_gateway_attachment_id == simple_attachment_id + - attachment.tags | length == 0 + - attachment.vpc_owner_id == vpc_owner_a + vars: + attachment: '{{ simple_attach.attachments[0] }}' + + - name: '(CHECK_MODE) Remove subnet -- IDEMPOTENCY' + check_mode: True + ec2_transit_gateway_vpc_attachment: + id: '{{ simple_attachment_id }}' + subnets: + - '{{ subnet_id_a_2 }}' + - '{{ subnet_id_a_3 }}' + purge_subnets: True + register: simple_attach + + - assert: + that: + - simple_attach is not changed + - '"attachments" in simple_attach' + - simple_attach.attachments | length == 1 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length == 2 + - subnet_id_a_2 in attachment.subnet_ids + - subnet_id_a_3 in attachment.subnet_ids + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_a + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - attachment.options.appliance_mode_support == 'disable' + - attachment.options.dns_support == 'enable' + - attachment.options.ipv6_support == 'disable' + - attachment.state == 'available' + - attachment.transit_gateway_attachment_id == simple_attachment_id + - attachment.tags | length == 0 + - attachment.vpc_owner_id == vpc_owner_a + vars: + attachment: '{{ simple_attach.attachments[0] }}' + + - name: 'Remove subnet -- IDEMPOTENCY' + ec2_transit_gateway_vpc_attachment: + id: '{{ simple_attachment_id }}' + subnets: + - '{{ subnet_id_a_2 }}' + - '{{ subnet_id_a_3 }}' + purge_subnets: True + register: simple_attach + + - assert: + that: + - simple_attach is not changed + - '"attachments" in simple_attach' + - simple_attach.attachments | length == 1 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length == 2 + - subnet_id_a_2 in attachment.subnet_ids + - subnet_id_a_3 in attachment.subnet_ids + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_a + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - attachment.options.appliance_mode_support == 'disable' + - attachment.options.dns_support == 'enable' + - attachment.options.ipv6_support == 'disable' + - attachment.state == 'available' + - attachment.transit_gateway_attachment_id == simple_attachment_id + - attachment.tags | length == 0 + - attachment.vpc_owner_id == vpc_owner_a + vars: + attachment: '{{ simple_attach.attachments[0] }}' + +# ===== + + - name: '(CHECK_MODE) Remove and add subnet' + check_mode: True + ec2_transit_gateway_vpc_attachment: + id: '{{ simple_attachment_id }}' + subnets: + - '{{ subnet_id_a_1 }}' + - '{{ subnet_id_a_2 }}' + purge_subnets: True + register: simple_attach + + - assert: + that: + - simple_attach is changed + - '"attachments" in simple_attach' + - simple_attach.attachments | length == 1 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length == 2 + - subnet_id_a_1 in attachment.subnet_ids + - subnet_id_a_2 in attachment.subnet_ids + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_a + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - attachment.options.appliance_mode_support == 'disable' + - attachment.options.dns_support == 'enable' + - attachment.options.ipv6_support == 'disable' + - attachment.state == 'available' + - attachment.transit_gateway_attachment_id == simple_attachment_id + - attachment.tags | length == 0 + - attachment.vpc_owner_id == vpc_owner_a + vars: + attachment: '{{ simple_attach.attachments[0] }}' + + - name: 'Remove and add subnet' + ec2_transit_gateway_vpc_attachment: + id: '{{ simple_attachment_id }}' + subnets: + - '{{ subnet_id_a_1 }}' + - '{{ subnet_id_a_2 }}' + purge_subnets: True + register: simple_attach + + - assert: + that: + - simple_attach is changed + - '"attachments" in simple_attach' + - simple_attach.attachments | length == 1 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length == 2 + - subnet_id_a_1 in attachment.subnet_ids + - subnet_id_a_2 in attachment.subnet_ids + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_a + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - attachment.options.appliance_mode_support == 'disable' + - attachment.options.dns_support == 'enable' + - attachment.options.ipv6_support == 'disable' + - attachment.state == 'available' + - attachment.transit_gateway_attachment_id == simple_attachment_id + - attachment.tags | length == 0 + - attachment.vpc_owner_id == vpc_owner_a + vars: + attachment: '{{ simple_attach.attachments[0] }}' + + - name: '(CHECK_MODE) Remove and add subnet -- IDEMPOTENCY' + check_mode: True + ec2_transit_gateway_vpc_attachment: + id: '{{ simple_attachment_id }}' + subnets: + - '{{ subnet_id_a_1 }}' + - '{{ subnet_id_a_2 }}' + purge_subnets: True + register: simple_attach + + - assert: + that: + - simple_attach is not changed + - '"attachments" in simple_attach' + - simple_attach.attachments | length == 1 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length == 2 + - subnet_id_a_1 in attachment.subnet_ids + - subnet_id_a_2 in attachment.subnet_ids + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_a + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - attachment.options.appliance_mode_support == 'disable' + - attachment.options.dns_support == 'enable' + - attachment.options.ipv6_support == 'disable' + - attachment.state == 'available' + - attachment.transit_gateway_attachment_id == simple_attachment_id + - attachment.tags | length == 0 + - attachment.vpc_owner_id == vpc_owner_a + vars: + attachment: '{{ simple_attach.attachments[0] }}' + + - name: 'Remove and add subnet -- IDEMPOTENCY' + ec2_transit_gateway_vpc_attachment: + id: '{{ simple_attachment_id }}' + subnets: + - '{{ subnet_id_a_1 }}' + - '{{ subnet_id_a_2 }}' + purge_subnets: True + register: simple_attach + + - assert: + that: + - simple_attach is not changed + - '"attachments" in simple_attach' + - simple_attach.attachments | length == 1 + - '"subnet_ids" in attachment' + - '"transit_gateway_id" in attachment' + - '"vpc_id" in attachment' + - attachment.subnet_ids | length == 2 + - subnet_id_a_1 in attachment.subnet_ids + - subnet_id_a_2 in attachment.subnet_ids + - attachment.transit_gateway_id == tgw_id + - attachment.vpc_id == vpc_id_a + - '"creation_time" in attachment' + - '"options" in attachment' + - '"state" in attachment' + - '"tags" in attachment' + - '"transit_gateway_attachment_id" in attachment' + - '"vpc_owner_id" in attachment' + - '"appliance_mode_support" in attachment.options' + - '"dns_support" in attachment.options' + - '"ipv6_support" in attachment.options' + - attachment.options.appliance_mode_support == 'disable' + - attachment.options.dns_support == 'enable' + - attachment.options.ipv6_support == 'disable' + - attachment.state == 'available' + - attachment.transit_gateway_attachment_id == simple_attachment_id + - attachment.tags | length == 0 + - attachment.vpc_owner_id == vpc_owner_a + vars: + attachment: '{{ simple_attach.attachments[0] }}' + +# ============================================================================= +# Deletion + + - name: '(CHECK_MODE) Delete an attachment - minimal parameters' + check_mode: True + ec2_transit_gateway_vpc_attachment: + state: absent + id: '{{ simple_attachment_id }}' + wait: False + register: simple_attach + + - assert: + that: + - simple_attach is changed + + - name: 'Delete an attachment - minimal parameters' + ec2_transit_gateway_vpc_attachment: + state: absent + id: '{{ simple_attachment_id }}' + wait: False + register: simple_attach + + - assert: + that: + - simple_attach is changed + + - name: '(CHECK_MODE) Delete an attachment - minimal parameters -- IDEMPOTENCY' + check_mode: True + ec2_transit_gateway_vpc_attachment: + state: absent + id: '{{ simple_attachment_id }}' + wait: False + register: simple_attach + + - assert: + that: + - simple_attach is not changed + + - name: 'Delete an attachment - minimal parameters -- IDEMPOTENCY' + ec2_transit_gateway_vpc_attachment: + state: absent + id: '{{ simple_attachment_id }}' + wait: False + register: simple_attach + + - assert: + that: + - simple_attach is not changed + + always: + - name: 'Delete attachment' + ec2_transit_gateway_vpc_attachment: + state: absent + id: '{{ simple_attachment_id }}' + wait: False + ignore_errors: True