Skip to content

Commit

Permalink
pass TagSpecifications only if tags are set (not {} and not None)
Browse files Browse the repository at this point in the history
  • Loading branch information
tremble committed Nov 24, 2023
1 parent 58ff3ec commit caaad89
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
2 changes: 2 additions & 0 deletions changelogs/fragments/1843-ec2_vpc_subnet.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1,4 @@
minor_changes:
- ec2_vpc_subnet - use ``ResourceTags`` to set initial tags upon creation (https://github.com/ansible-collections/amazon.aws/issues/1843)
- ec2_vpc_subnet - the default value for ``tags`` has been changed from ``{}`` to ``None``, to remove tags from a subnet an empty map must
be explicitly passed to the module (https://github.com/ansible-collections/amazon.aws/pull/1876).
4 changes: 2 additions & 2 deletions plugins/modules/ec2_eip.py
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ def allocate_address(
)

params = {"Domain": domain}
if tags is not None:
if tags:
params["TagSpecifications"] = boto3_tag_specifications(tags, types="elastic-ip")

try:
Expand Down Expand Up @@ -538,7 +538,7 @@ def allocate_address_from_pool(
if public_ipv4_pool is not None:
params["PublicIpv4Pool"] = public_ipv4_pool

if tags is not None:
if tags:
params["TagSpecifications"] = boto3_tag_specifications(tags, types="elastic-ip")

try:
Expand Down
2 changes: 1 addition & 1 deletion plugins/modules/ec2_vpc_igw.py
Original file line number Diff line number Diff line change
Expand Up @@ -313,7 +313,7 @@ def ensure_igw_present(self, igw_id, vpc_id, tags, purge_tags, force_attach, det

try:
create_params = {}
if tags is not None:
if tags:
create_params["TagSpecifications"] = boto3_tag_specifications(tags, types="internet-gateway")
response = self._connection.create_internet_gateway(aws_retry=True, **create_params)

Expand Down
6 changes: 2 additions & 4 deletions plugins/modules/ec2_vpc_subnet.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,6 @@
- Ignored unless I(wait=True).
default: 300
type: int
tags:
default: {}
extends_documentation_fragment:
- amazon.aws.common.modules
- amazon.aws.region.modules
Expand Down Expand Up @@ -280,7 +278,7 @@ def create_subnet(conn, module, vpc_id, cidr, tags, ipv6_cidr=None, outpost_arn=
if az:
params["AvailabilityZone"] = az

if tags is not None:
if tags:
params["TagSpecifications"] = boto3_tag_specifications(tags, types="subnet")

if outpost_arn:
Expand Down Expand Up @@ -554,7 +552,7 @@ def main():
ipv6_cidr=dict(default="", required=False),
outpost_arn=dict(default="", type="str", required=False),
state=dict(default="present", choices=["present", "absent"]),
tags=dict(default={}, required=False, type="dict", aliases=["resource_tags"]),
tags=dict(required=False, type="dict", aliases=["resource_tags"]),
vpc_id=dict(required=True),
map_public=dict(default=False, required=False, type="bool"),
assign_instances_ipv6=dict(default=False, required=False, type="bool"),
Expand Down

0 comments on commit caaad89

Please sign in to comment.