Skip to content

Commit

Permalink
Add documentation and tests for return values
Browse files Browse the repository at this point in the history
  • Loading branch information
tremble committed Sep 17, 2021
1 parent 3cb67e4 commit 24c8211
Show file tree
Hide file tree
Showing 3 changed files with 127 additions and 30 deletions.
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
minor_changes:
- elasticache_subnet_group - module migrated to boto3 AWS SDK (https://github.com/ansible-collections/community.aws/pull/723).
- elasticache_subnet_group - add return values (https://github.com/ansible-collections/community.aws/pull/723).
36 changes: 36 additions & 0 deletions plugins/modules/elasticache_subnet_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,42 @@
name: norwegian-blue
'''

RETURN = r'''
cache_subnet_group:
description: Description of the Elasticache Subnet Group.
returned: always
type: dict
contains:
arn:
description: The Amazon Resource Name (ARN) of the cache subnet group.
returned: when the subnet group exists
type: str
sample: arn:aws:elasticache:us-east-1:012345678901:subnetgroup:norwegian-blue
description:
description: The description of the cache subnet group.
returned: when the cache subnet group exists
type: str
sample: My Fancy Ex Parrot Subnet Group
name:
description: The name of the cache subnet group.
returned: when the cache subnet group exists
type: str
sample: norwegian-blue
vpc_id:
description: The VPC ID of the cache subnet group.
returned: when the cache subnet group exists
type: str
sample: norwegian-blue
subnet_ids:
description: The IDs of the subnets beloging to the cache subnet group.
returned: when the cache subnet group exists
type: list
elements: str
sample:
- subnet-aaaaaaaa
- subnet-bbbbbbbb
'''

try:
import botocore
except ImportError:
Expand Down
120 changes: 90 additions & 30 deletions tests/integration/targets/elasticache_subnet_group/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,21 @@
that:
- create_group is successful
- create_group is changed
#- '"group" in create_group'
#- '"name" in create_group.group'
#- '"vpc_id" in create_group.group'
#- create_group.group.name == group_name
#- create_group.group.vpc_id == vpc_id
- '"cache_subnet_group" in create_group'
- '"arn" in create_group.cache_subnet_group'
- '"description" in create_group.cache_subnet_group'
- '"name" in create_group.cache_subnet_group'
- '"subnet_ids" in create_group.cache_subnet_group'
- '"vpc_id" in create_group.cache_subnet_group'
- create_group.cache_subnet_group.description == description_default
- create_group.cache_subnet_group.name == group_name
- subnet_id_a in create_group.cache_subnet_group.subnet_ids
- subnet_id_b in create_group.cache_subnet_group.subnet_ids
- subnet_id_c not in create_group.cache_subnet_group.subnet_ids
- subnet_id_d not in create_group.cache_subnet_group.subnet_ids
- create_group.cache_subnet_group.vpc_id == vpc_id
- create_group.cache_subnet_group.arn.startswith('arn:')
- create_group.cache_subnet_group.arn.endswith(group_name)

- name: Create Subnet Group - idempotency
elasticache_subnet_group:
Expand All @@ -93,11 +103,21 @@
that:
- create_group is successful
- create_group is not changed
#- '"group" in create_group'
#- '"name" in create_group.group'
#- '"vpc_id" in create_group.group'
#- create_group.group.name == group_name
#- create_group.group.vpc_id == vpc_id
- '"cache_subnet_group" in create_group'
- '"arn" in create_group.cache_subnet_group'
- '"description" in create_group.cache_subnet_group'
- '"name" in create_group.cache_subnet_group'
- '"subnet_ids" in create_group.cache_subnet_group'
- '"vpc_id" in create_group.cache_subnet_group'
- create_group.cache_subnet_group.description == description_default
- create_group.cache_subnet_group.name == group_name
- subnet_id_a in create_group.cache_subnet_group.subnet_ids
- subnet_id_b in create_group.cache_subnet_group.subnet_ids
- subnet_id_c not in create_group.cache_subnet_group.subnet_ids
- subnet_id_d not in create_group.cache_subnet_group.subnet_ids
- create_group.cache_subnet_group.vpc_id == vpc_id
- create_group.cache_subnet_group.arn.startswith('arn:')
- create_group.cache_subnet_group.arn.endswith(group_name)

# ============================================================

Expand All @@ -116,11 +136,21 @@
that:
- update_description is successful
- update_description is changed
#- '"group" in update_description'
#- '"name" in update_description.group'
#- '"vpc_id" in update_description.group'
#- update_description.group.name == group_name
#- update_description.group.vpc_id == vpc_id
- '"cache_subnet_group" in update_description'
- '"arn" in update_description.cache_subnet_group'
- '"description" in update_description.cache_subnet_group'
- '"name" in update_description.cache_subnet_group'
- '"subnet_ids" in update_description.cache_subnet_group'
- '"vpc_id" in update_description.cache_subnet_group'
- update_description.cache_subnet_group.description == description_updated
- update_description.cache_subnet_group.name == group_name
- subnet_id_a in update_description.cache_subnet_group.subnet_ids
- subnet_id_b in update_description.cache_subnet_group.subnet_ids
- subnet_id_c not in update_description.cache_subnet_group.subnet_ids
- subnet_id_d not in update_description.cache_subnet_group.subnet_ids
- update_description.cache_subnet_group.vpc_id == vpc_id
- update_description.cache_subnet_group.arn.startswith('arn:')
- update_description.cache_subnet_group.arn.endswith(group_name)

- name: Update Subnet Group Description - idempotency
elasticache_subnet_group:
Expand All @@ -137,11 +167,21 @@
that:
- update_description is successful
- update_description is not changed
#- '"group" in update_description'
#- '"name" in update_description.group'
#- '"vpc_id" in update_description.group'
#- update_description.group.name == group_name
#- update_description.group.vpc_id == vpc_id
- '"cache_subnet_group" in update_description'
- '"arn" in update_description.cache_subnet_group'
- '"description" in update_description.cache_subnet_group'
- '"name" in update_description.cache_subnet_group'
- '"subnet_ids" in update_description.cache_subnet_group'
- '"vpc_id" in update_description.cache_subnet_group'
- update_description.cache_subnet_group.description == description_updated
- update_description.cache_subnet_group.name == group_name
- subnet_id_a in update_description.cache_subnet_group.subnet_ids
- subnet_id_b in update_description.cache_subnet_group.subnet_ids
- subnet_id_c not in update_description.cache_subnet_group.subnet_ids
- subnet_id_d not in update_description.cache_subnet_group.subnet_ids
- update_description.cache_subnet_group.vpc_id == vpc_id
- update_description.cache_subnet_group.arn.startswith('arn:')
- update_description.cache_subnet_group.arn.endswith(group_name)

# ============================================================

Expand All @@ -160,11 +200,21 @@
that:
- update_subnets is successful
- update_subnets is changed
#- '"group" in update_subnets'
#- '"name" in update_subnets.group'
#- '"vpc_id" in update_subnets.group'
#- update_subnets.group.name == group_name
#- update_subnets.group.vpc_id == vpc_id
- '"cache_subnet_group" in update_subnets'
- '"arn" in update_subnets.cache_subnet_group'
- '"description" in update_subnets.cache_subnet_group'
- '"name" in update_subnets.cache_subnet_group'
- '"subnet_ids" in update_subnets.cache_subnet_group'
- '"vpc_id" in update_subnets.cache_subnet_group'
- update_subnets.cache_subnet_group.description == description_updated
- update_subnets.cache_subnet_group.name == group_name
- subnet_id_a not in update_subnets.cache_subnet_group.subnet_ids
- subnet_id_b not in update_subnets.cache_subnet_group.subnet_ids
- subnet_id_c in update_subnets.cache_subnet_group.subnet_ids
- subnet_id_d in update_subnets.cache_subnet_group.subnet_ids
- update_subnets.cache_subnet_group.vpc_id == vpc_id
- update_subnets.cache_subnet_group.arn.startswith('arn:')
- update_subnets.cache_subnet_group.arn.endswith(group_name)

- name: Update Subnet Group subnets - idempotency
elasticache_subnet_group:
Expand All @@ -181,11 +231,21 @@
that:
- update_subnets is successful
- update_subnets is not changed
#- '"group" in update_subnets'
#- '"name" in update_subnets.group'
#- '"vpc_id" in update_subnets.group'
#- update_subnets.group.name == group_name
#- update_subnets.group.vpc_id == vpc_id
- '"cache_subnet_group" in update_subnets'
- '"arn" in update_subnets.cache_subnet_group'
- '"description" in update_subnets.cache_subnet_group'
- '"name" in update_subnets.cache_subnet_group'
- '"subnet_ids" in update_subnets.cache_subnet_group'
- '"vpc_id" in update_subnets.cache_subnet_group'
- update_subnets.cache_subnet_group.description == description_updated
- update_subnets.cache_subnet_group.name == group_name
- subnet_id_a not in update_subnets.cache_subnet_group.subnet_ids
- subnet_id_b not in update_subnets.cache_subnet_group.subnet_ids
- subnet_id_c in update_subnets.cache_subnet_group.subnet_ids
- subnet_id_d in update_subnets.cache_subnet_group.subnet_ids
- update_subnets.cache_subnet_group.vpc_id == vpc_id
- update_subnets.cache_subnet_group.arn.startswith('arn:')
- update_subnets.cache_subnet_group.arn.endswith(group_name)

# ============================================================

Expand Down

0 comments on commit 24c8211

Please sign in to comment.