diff --git a/plugins/modules/redshift_subnet_group.py b/plugins/modules/redshift_subnet_group.py index c67a46e4c00..a609dd47a2c 100644 --- a/plugins/modules/redshift_subnet_group.py +++ b/plugins/modules/redshift_subnet_group.py @@ -64,20 +64,33 @@ RETURN = r''' cluster_subnet_group: - description: dictionary containing Redshift subnet group information + description: A dictionary containing information about the Redshift subnet group. returned: success type: dict contains: name: - description: name of the Redshift subnet group - returned: success + description: Name of the Redshift subnet group. + returned: when the cache subnet group exists type: str sample: "redshift_subnet_group_name" vpc_id: - description: Id of the VPC where the subnet is located - returned: success + description: Id of the VPC where the subnet is located. + returned: when the cache subnet group exists type: str sample: "vpc-aabb1122" + description: + description: The description of the cache subnet group. + returned: when the cache subnet group exists + type: str + sample: Redshift subnet + subnet_ids: + description: The IDs of the subnets beloging to the Redshift subnet group. + returned: when the cache subnet group exists + type: list + elements: str + sample: + - subnet-aaaaaaaa + - subnet-bbbbbbbb ''' try: @@ -90,6 +103,7 @@ from ansible_collections.amazon.aws.plugins.module_utils.core import AnsibleAWSModule from ansible_collections.amazon.aws.plugins.module_utils.core import is_boto3_error_code from ansible_collections.amazon.aws.plugins.module_utils.ec2 import AWSRetry +from ansible_collections.amazon.aws.plugins.module_utils.ec2 import boto3_tag_list_to_ansible_dict def get_subnet_group(name): @@ -112,8 +126,10 @@ def get_subnet_group(name): cluster_subnet_groups=camel_dict_to_snake_dict(groups), ) + tags = boto3_tag_list_to_ansible_dict(groups[0]['Tags']) subnet_group = camel_dict_to_snake_dict(groups[0]) + subnet_group['tags'] = tags subnet_group['name'] = subnet_group['cluster_subnet_group_name'] subnet_ids = list(s['subnet_identifier'] for s in subnet_group['subnets']) diff --git a/tests/integration/targets/redshift_subnet_group/tasks/main.yml b/tests/integration/targets/redshift_subnet_group/tasks/main.yml index b1d269235e6..c8f8552d758 100644 --- a/tests/integration/targets/redshift_subnet_group/tasks/main.yml +++ b/tests/integration/targets/redshift_subnet_group/tasks/main.yml @@ -101,6 +101,17 @@ - '"vpc_id" in create_group.group' - create_group.group.name == group_name - create_group.group.vpc_id == vpc_id + - '"cluster_subnet_group" in create_group' + - '"description" in create_group.cluster_subnet_group' + - '"subnet_ids" in create_group.cluster_subnet_group' + - '"vpc_id" in create_group.cluster_subnet_group' + - create_group.cluster_subnet_group.name == group_name + - create_group.cluster_subnet_group.description == description_default + - subnet_id_a in create_group.cluster_subnet_group.subnet_ids + - subnet_id_b in create_group.cluster_subnet_group.subnet_ids + - subnet_id_c not in create_group.cluster_subnet_group.subnet_ids + - subnet_id_d not in create_group.cluster_subnet_group.subnet_ids + - create_group.cluster_subnet_group.vpc_id == vpc_id - name: Create Subnet Group - idempotency redshift_subnet_group: @@ -122,6 +133,17 @@ - '"vpc_id" in create_group.group' - create_group.group.name == group_name - create_group.group.vpc_id == vpc_id + - '"cluster_subnet_group" in create_group' + - '"description" in create_group.cluster_subnet_group' + - '"subnet_ids" in create_group.cluster_subnet_group' + - '"vpc_id" in create_group.cluster_subnet_group' + - create_group.cluster_subnet_group.name == group_name + - create_group.cluster_subnet_group.description == description_default + - subnet_id_a in create_group.cluster_subnet_group.subnet_ids + - subnet_id_b in create_group.cluster_subnet_group.subnet_ids + - subnet_id_c not in create_group.cluster_subnet_group.subnet_ids + - subnet_id_d not in create_group.cluster_subnet_group.subnet_ids + - create_group.cluster_subnet_group.vpc_id == vpc_id # ============================================================ @@ -146,6 +168,17 @@ - '"vpc_id" in update_description.group' - update_description.group.name == group_name - update_description.group.vpc_id == vpc_id + - '"cluster_subnet_group" in update_description' + - '"description" in update_description.cluster_subnet_group' + - '"subnet_ids" in update_description.cluster_subnet_group' + - '"vpc_id" in update_description.cluster_subnet_group' + - update_description.cluster_subnet_group.name == group_name + - update_description.cluster_subnet_group.description == description_updated + - subnet_id_a in update_description.cluster_subnet_group.subnet_ids + - subnet_id_b in update_description.cluster_subnet_group.subnet_ids + - subnet_id_c not in update_description.cluster_subnet_group.subnet_ids + - subnet_id_d not in update_description.cluster_subnet_group.subnet_ids + - update_description.cluster_subnet_group.vpc_id == vpc_id - name: Update Subnet Group Description - idempotency redshift_subnet_group: @@ -168,6 +201,17 @@ - '"vpc_id" in update_description.group' - update_description.group.name == group_name - update_description.group.vpc_id == vpc_id + - '"cluster_subnet_group" in update_description' + - '"description" in update_description.cluster_subnet_group' + - '"subnet_ids" in update_description.cluster_subnet_group' + - '"vpc_id" in update_description.cluster_subnet_group' + - update_description.cluster_subnet_group.name == group_name + - update_description.cluster_subnet_group.description == description_updated + - subnet_id_a in update_description.cluster_subnet_group.subnet_ids + - subnet_id_b in update_description.cluster_subnet_group.subnet_ids + - subnet_id_c not in update_description.cluster_subnet_group.subnet_ids + - subnet_id_d not in update_description.cluster_subnet_group.subnet_ids + - update_description.cluster_subnet_group.vpc_id == vpc_id # ============================================================ @@ -192,6 +236,17 @@ - '"vpc_id" in update_subnets.group' - update_subnets.group.name == group_name - update_subnets.group.vpc_id == vpc_id + - '"cluster_subnet_group" in update_subnets' + - '"description" in update_subnets.cluster_subnet_group' + - '"subnet_ids" in update_subnets.cluster_subnet_group' + - '"vpc_id" in update_subnets.cluster_subnet_group' + - update_subnets.cluster_subnet_group.name == group_name + - update_subnets.cluster_subnet_group.description == description_updated + - subnet_id_a not in update_subnets.cluster_subnet_group.subnet_ids + - subnet_id_b not in update_subnets.cluster_subnet_group.subnet_ids + - subnet_id_c in update_subnets.cluster_subnet_group.subnet_ids + - subnet_id_d in update_subnets.cluster_subnet_group.subnet_ids + - update_subnets.cluster_subnet_group.vpc_id == vpc_id - name: Update Subnet Group subnets - idempotency redshift_subnet_group: @@ -214,6 +269,17 @@ - '"vpc_id" in update_subnets.group' - update_subnets.group.name == group_name - update_subnets.group.vpc_id == vpc_id + - '"cluster_subnet_group" in update_subnets' + - '"description" in update_subnets.cluster_subnet_group' + - '"subnet_ids" in update_subnets.cluster_subnet_group' + - '"vpc_id" in update_subnets.cluster_subnet_group' + - update_subnets.cluster_subnet_group.name == group_name + - update_subnets.cluster_subnet_group.description == description_updated + - subnet_id_a not in update_subnets.cluster_subnet_group.subnet_ids + - subnet_id_b not in update_subnets.cluster_subnet_group.subnet_ids + - subnet_id_c in update_subnets.cluster_subnet_group.subnet_ids + - subnet_id_d in update_subnets.cluster_subnet_group.subnet_ids + - update_subnets.cluster_subnet_group.vpc_id == vpc_id # ============================================================ @@ -259,6 +325,17 @@ - '"vpc_id" in create_group.group' - create_group.group.name == group_name - create_group.group.vpc_id == vpc_id + - '"cluster_subnet_group" in create_group' + - '"description" in create_group.cluster_subnet_group' + - '"subnet_ids" in create_group.cluster_subnet_group' + - '"vpc_id" in create_group.cluster_subnet_group' + - create_group.cluster_subnet_group.name == group_name + - create_group.cluster_subnet_group.description == group_name + - subnet_id_a in create_group.cluster_subnet_group.subnet_ids + - subnet_id_b not in create_group.cluster_subnet_group.subnet_ids + - subnet_id_c not in create_group.cluster_subnet_group.subnet_ids + - subnet_id_d not in create_group.cluster_subnet_group.subnet_ids + - create_group.cluster_subnet_group.vpc_id == vpc_id - name: Create minimal Subnet Group - idempotency redshift_subnet_group: @@ -278,6 +355,17 @@ - '"vpc_id" in create_group.group' - create_group.group.name == group_name - create_group.group.vpc_id == vpc_id + - '"cluster_subnet_group" in create_group' + - '"description" in create_group.cluster_subnet_group' + - '"subnet_ids" in create_group.cluster_subnet_group' + - '"vpc_id" in create_group.cluster_subnet_group' + - create_group.cluster_subnet_group.name == group_name + - create_group.cluster_subnet_group.description == group_name + - subnet_id_a in create_group.cluster_subnet_group.subnet_ids + - subnet_id_b not in create_group.cluster_subnet_group.subnet_ids + - subnet_id_c not in create_group.cluster_subnet_group.subnet_ids + - subnet_id_d not in create_group.cluster_subnet_group.subnet_ids + - create_group.cluster_subnet_group.vpc_id == vpc_id # ============================================================ @@ -301,6 +389,17 @@ - '"vpc_id" in update_complex.group' - update_complex.group.name == group_name - update_complex.group.vpc_id == vpc_id + - '"cluster_subnet_group" in update_complex' + - '"description" in update_complex.cluster_subnet_group' + - '"subnet_ids" in update_complex.cluster_subnet_group' + - '"vpc_id" in update_complex.cluster_subnet_group' + - update_complex.cluster_subnet_group.name == group_name + - update_complex.cluster_subnet_group.description == description_updated + - subnet_id_a in update_complex.cluster_subnet_group.subnet_ids + - subnet_id_b in update_complex.cluster_subnet_group.subnet_ids + - subnet_id_c not in update_complex.cluster_subnet_group.subnet_ids + - subnet_id_d not in update_complex.cluster_subnet_group.subnet_ids + - update_complex.cluster_subnet_group.vpc_id == vpc_id - name: Full Update Subnet Group - idempotency redshift_subnet_group: @@ -322,6 +421,17 @@ - '"vpc_id" in update_complex.group' - update_complex.group.name == group_name - update_complex.group.vpc_id == vpc_id + - '"cluster_subnet_group" in update_complex' + - '"description" in update_complex.cluster_subnet_group' + - '"subnet_ids" in update_complex.cluster_subnet_group' + - '"vpc_id" in update_complex.cluster_subnet_group' + - update_complex.cluster_subnet_group.name == group_name + - update_complex.cluster_subnet_group.description == description_updated + - subnet_id_a in update_complex.cluster_subnet_group.subnet_ids + - subnet_id_b in update_complex.cluster_subnet_group.subnet_ids + - subnet_id_c not in update_complex.cluster_subnet_group.subnet_ids + - subnet_id_d not in update_complex.cluster_subnet_group.subnet_ids + - update_complex.cluster_subnet_group.vpc_id == vpc_id # ============================================================