Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rds_cluster: add support for ServerlessV2ScalingConfiguration #1839

Merged
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
minor_changes:
- rds_cluster - Add support for ServerlessV2ScalingConfiguration to create and modify cluster operations (https://github.com/ansible-collections/amazon.aws/pull/1839).
36 changes: 36 additions & 0 deletions plugins/modules/rds_cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -350,6 +350,24 @@
- The prefix for all of the file names that contain the data used to create the Amazon Aurora DB cluster.
- If you do not specify a SourceS3Prefix value, then the Amazon Aurora DB cluster is created by using all of the files in the Amazon S3 bucket.
type: str
serverless_v2_scaling_configuration:
description:
mandar242 marked this conversation as resolved.
Show resolved Hide resolved
- Contains the scaling configuration of an Aurora Serverless v2 DB cluster.
type: dict
suboptions:
min_capacity:
description:
- The minimum number of Aurora capacity units (ACUs) for a DB instance in an Aurora Serverless v2 cluster.
- ACU values can be specified in in half-step increments, such as C(8), C(8.5), C(9), and so on.
- The smallest possible value is C(0.5).
type: float
max_capacity:
description:
- The maximum number of Aurora capacity units (ACUs) for a DB instance in an Aurora Serverless v2 cluster.
- ACU values can be specified in in half-step increments, such as C(40), C(40.5), C(41), and so on.
- The largest possible value is C(128).
type: float
version_added: 7.2.0
skip_final_snapshot:
description:
- Whether a final DB cluster snapshot is created before the DB cluster is deleted.
Expand Down Expand Up @@ -690,6 +708,15 @@
returned: always
type: str
sample: rds-cluster-demo.cluster-ro-cvlrtwiennww.us-east-1.rds.amazonaws.com
serverless_v2_scaling_configuration:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add version_added: 7.2.0 here too.

description: The scaling configuration for an Aurora Serverless v2 DB cluster.
returned: when configured
type: dict
sample: {
"max_capacity": 4.5,
"min_capacity": 2.5
}
version_added: 7.2.0
status:
description: The status of the DB cluster.
returned: always
Expand Down Expand Up @@ -821,6 +848,7 @@ def get_create_options(params_dict):
"StorageType",
"Iops",
"EngineMode",
"ServerlessV2ScalingConfiguration",
]

return dict((k, v) for k, v in params_dict.items() if k in options and v is not None)
Expand Down Expand Up @@ -855,6 +883,7 @@ def get_modify_options(params_dict, force_update_password):
"StorageType",
"Iops",
"EngineMode",
"ServerlessV2ScalingConfiguration",
]
modify_options = dict((k, v) for k, v in params_dict.items() if k in options and v is not None)
if not force_update_password:
Expand Down Expand Up @@ -1232,6 +1261,13 @@ def main():
s3_bucket_name=dict(),
s3_ingestion_role_arn=dict(),
s3_prefix=dict(),
serverless_v2_scaling_configuration=dict(
type="dict",
options=dict(
min_capacity=dict(type="float"),
max_capacity=dict(type="float"),
),
),
skip_final_snapshot=dict(type="bool", default=False),
snapshot_identifier=dict(),
source_db_cluster_identifier=dict(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ test_engine: aurora-mysql
test_engine_version: 8.0
test_instance_class: db.r5.large

min_capacity: 2.5
max_capacity: 4.5

# Global cluster parameters ================================
test_global_cluster_name: ansible-test-global-{{ tiny_prefix }}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
---
- name: Run tests for testing serverless v2 scaling configuration
block:
- name: Create a cluster (check_mode)
amazon.aws.rds_cluster:
db_cluster_identifier: "{{ cluster_id }}"
region: "{{ aws_region }}"
engine: "{{ test_engine }}"
engine_version: "{{ test_engine_version }}"
username: "{{ username }}"
password: "{{ password }}"
serverless_v2_scaling_configuration:
min_capacity: "{{ min_capacity }}"
max_capacity: "{{ max_capacity }}"
check_mode: true
register: create_result_check_mode

- name: Get RDS cluster info
amazon.aws.rds_cluster_info:
db_cluster_identifier: "{{ cluster_id }}"
region: "{{ aws_region }}"
register: result

- assert:
that:
- create_result_check_mode is changed
- create_result_check_mode is not failed
- result.clusters | length == 0

- name: Create a cluster
amazon.aws.rds_cluster:
db_cluster_identifier: "{{ cluster_id }}"
region: "{{ aws_region }}"
engine: "{{ test_engine }}"
engine_version: "{{ test_engine_version }}"
username: "{{ username }}"
password: "{{ password }}"
serverless_v2_scaling_configuration:
min_capacity: "{{ min_capacity }}"
max_capacity: "{{ max_capacity }}"
register: create_result

- name: Get RDS cluster info
amazon.aws.rds_cluster_info:
db_cluster_identifier: "{{ cluster_id }}"
region: "{{ aws_region }}"
register: result

- assert:
that:
- create_result is changed
- create_result is not failed
- result.clusters[0].serverless_v2_scaling_configuration is defined
- result.clusters[0].serverless_v2_scaling_configuration.min_capacity == 2.5
- result.clusters[0].serverless_v2_scaling_configuration.max_capacity == 4.5

- name: Modify cluster - update serverless v2 scaling configuration (check_mode)
amazon.aws.rds_cluster:
db_cluster_identifier: "{{ cluster_id }}"
region: "{{ aws_region }}"
engine: "{{ test_engine }}"
username: "{{ username }}"
password: "{{ password }}"
serverless_v2_scaling_configuration:
min_capacity: 2
max_capacity: 5
check_mode: true
register: modify_result_check_mode

- name: Get RDS cluster info
amazon.aws.rds_cluster_info:
db_cluster_identifier: "{{ cluster_id }}"
region: "{{ aws_region }}"
register: result

- assert:
that:
- modify_result_check_mode is changed
- modify_result_check_mode is not failed
- result.clusters[0].serverless_v2_scaling_configuration is defined
- result.clusters[0].serverless_v2_scaling_configuration.min_capacity != 2
- result.clusters[0].serverless_v2_scaling_configuration.max_capacity != 5

- name: Modify cluster - update serverless v2 scaling configuration
amazon.aws.rds_cluster:
db_cluster_identifier: "{{ cluster_id }}"
region: "{{ aws_region }}"
engine: "{{ test_engine }}"
username: "{{ username }}"
password: "{{ password }}"
serverless_v2_scaling_configuration:
min_capacity: 2
max_capacity: 5
register: modify_result

- name: Get RDS cluster info
amazon.aws.rds_cluster_info:
db_cluster_identifier: "{{ cluster_id }}"
region: "{{ aws_region }}"
register: result

- assert:
that:
- modify_result is changed
- modify_result is not failed
- result.clusters[0].serverless_v2_scaling_configuration is defined
- result.clusters[0].serverless_v2_scaling_configuration.min_capacity == 2
- result.clusters[0].serverless_v2_scaling_configuration.max_capacity == 5

always:

- name: Delete DB cluster created in this test
amazon.aws.rds_cluster:
cluster_id: "{{ cluster_id }}"
region: "{{ aws_region }}"
skip_final_snapshot: true
state: absent
ignore_errors: true
3 changes: 3 additions & 0 deletions tests/integration/targets/rds_cluster_modify/tasks/main.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@
# - name: Run tests for testing remove cluster from global db
# import_tasks: remove_from_global_db.yaml

- name: Run tests for testing serverless v2 scaling configuration
import_tasks: create_update_cluster_serverless_v2_scaling_configuration.yaml

- name: Ensure the resource doesn't exist
amazon.aws.rds_cluster:
id: "{{ cluster_id }}"
Expand Down
Loading