From 378a4ec6362aa705f0e5fb597f1efc179713556a Mon Sep 17 00:00:00 2001 From: ichekaldin <39010411+ichekaldin@users.noreply.github.com> Date: Thu, 1 Apr 2021 04:03:21 +0000 Subject: [PATCH 1/8] Avoid converting connection_parameter keys to lowercase This is a follow to my own PR #503: https://github.com/ansible-collections/community.aws/pull/503 This is a cosmetic change that prevents converting keys in connection_parameters dict to lowercase. As an example, this: ``` - community.aws.glue_connection: name: test-connection connection_parameters: JDBC_ENFORCE_SSL: "false" ... ``` is a valid value, while this: ``` - community.aws.glue_connection: name: test-connection connection_parameters: JDBC_ENFORCE_SSL: "false" ... ``` is not. This PR simply aligns the module output to the expected input. --- ...ection-do-not-lowercase-connection-parameters.yml | 2 ++ plugins/modules/glue_connection.py | 2 +- .../tasks/test_connection_network.yml | 12 ++++++------ 3 files changed, 9 insertions(+), 7 deletions(-) create mode 100644 changelogs/fragments/518-aws_glue_connection-do-not-lowercase-connection-parameters.yml diff --git a/changelogs/fragments/518-aws_glue_connection-do-not-lowercase-connection-parameters.yml b/changelogs/fragments/518-aws_glue_connection-do-not-lowercase-connection-parameters.yml new file mode 100644 index 00000000000..d9013043035 --- /dev/null +++ b/changelogs/fragments/518-aws_glue_connection-do-not-lowercase-connection-parameters.yml @@ -0,0 +1,2 @@ +minor_changes: + - aws_glue_connection - Avoid converting connection_parameters to lowercase (https://github.com/ansible-collections/community.aws/pull/518). diff --git a/plugins/modules/glue_connection.py b/plugins/modules/glue_connection.py index c8adb83fc66..b4a684a3fbb 100644 --- a/plugins/modules/glue_connection.py +++ b/plugins/modules/glue_connection.py @@ -309,7 +309,7 @@ def create_or_update_glue_connection(connection, connection_ec2, module, glue_co if changed and not module.check_mode: glue_connection = _await_glue_connection(connection, module) - module.exit_json(changed=changed, **camel_dict_to_snake_dict(glue_connection or {})) + module.exit_json(changed=changed, **camel_dict_to_snake_dict(glue_connection or {}, ignore_list=['ConnectionProperties'])) def delete_glue_connection(connection, module, glue_connection): diff --git a/tests/integration/targets/glue_connection/tasks/test_connection_network.yml b/tests/integration/targets/glue_connection/tasks/test_connection_network.yml index ce8af4d2f21..34485ab6111 100644 --- a/tests/integration/targets/glue_connection/tasks/test_connection_network.yml +++ b/tests/integration/targets/glue_connection/tasks/test_connection_network.yml @@ -52,7 +52,7 @@ name: "{{ resource_prefix }}" availability_zone: "{{ aws_region }}a" connection_properties: - jdbc_enforce_ssl: "false" + JDBC_ENFORCE_SSL: "false" connection_type: NETWORK description: Test connection security_groups: @@ -73,7 +73,7 @@ name: "{{ resource_prefix }}" availability_zone: "{{ aws_region }}a" connection_properties: - jdbc_enforce_ssl: "false" + JDBC_ENFORCE_SSL: "false" connection_type: NETWORK description: Test connection security_groups: @@ -112,7 +112,7 @@ name: "{{ resource_prefix }}" availability_zone: "{{ aws_region }}a" connection_properties: - jdbc_enforce_ssl: "false" + JDBC_ENFORCE_SSL: "false" connection_type: NETWORK description: Test connection security_groups: @@ -152,7 +152,7 @@ name: "{{ resource_prefix }}" availability_zone: "{{ aws_region }}a" connection_properties: - jdbc_enforce_ssl: "false" + JDBC_ENFORCE_SSL: "false" connection_type: NETWORK description: Test connection security_groups: @@ -191,7 +191,7 @@ name: "{{ resource_prefix }}" availability_zone: "{{ aws_region }}a" connection_properties: - jdbc_enforce_ssl: "false" + JDBC_ENFORCE_SSL: "false" connection_type: NETWORK description: Test connection modified security_groups: @@ -231,7 +231,7 @@ name: "{{ resource_prefix }}" availability_zone: "{{ aws_region }}a" connection_properties: - jdbc_enforce_ssl: "false" + JDBC_ENFORCE_SSL: "false" connection_type: NETWORK description: Test connection modified security_groups: From 76adcd1e5bbb05df52f69512ab854b9a648786ff Mon Sep 17 00:00:00 2001 From: ichekaldin <39010411+ichekaldin@users.noreply.github.com> Date: Thu, 1 Apr 2021 15:38:34 +0000 Subject: [PATCH 2/8] Minor formatting change (to re-trigger the tests) --- ...s_glue_connection-do-not-lowercase-connection-parameters.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelogs/fragments/518-aws_glue_connection-do-not-lowercase-connection-parameters.yml b/changelogs/fragments/518-aws_glue_connection-do-not-lowercase-connection-parameters.yml index d9013043035..dd572351921 100644 --- a/changelogs/fragments/518-aws_glue_connection-do-not-lowercase-connection-parameters.yml +++ b/changelogs/fragments/518-aws_glue_connection-do-not-lowercase-connection-parameters.yml @@ -1,2 +1,2 @@ minor_changes: - - aws_glue_connection - Avoid converting connection_parameters to lowercase (https://github.com/ansible-collections/community.aws/pull/518). + - aws_glue_connection - Avoid converting connection_parameters to lowercase (https://github.com/ansible-collections/community.aws/pull/518) From efbf66fb2bdbf23b9bf4189b9501f3a8ab71e667 Mon Sep 17 00:00:00 2001 From: Ivan Chekaldin Date: Wed, 6 Jul 2022 09:37:12 -0400 Subject: [PATCH 3/8] Add raw_connection_parameters return key and deprecation notice --- plugins/modules/glue_connection.py | 14 ++++++++++++-- .../tasks/test_connection_network.yml | 3 +++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/plugins/modules/glue_connection.py b/plugins/modules/glue_connection.py index b4a684a3fbb..1f5138ed3de 100644 --- a/plugins/modules/glue_connection.py +++ b/plugins/modules/glue_connection.py @@ -109,10 +109,10 @@ RETURN = r''' connection_properties: - description: A dict of key-value pairs used as parameters for this connection. + description: (deprecated) A dict of key-value pairs (converted to lowercase) used as parameters for this connection. This return key has been deprecated, and will be removed in a release after 2024-06-01. returned: when state is present type: dict - sample: {'JDBC_CONNECTION_URL':'jdbc:mysql://mydb:3306/databasename','USERNAME':'x','PASSWORD':'y'} + sample: {'jdbc_connection_url':'jdbc:mysql://mydb:3306/databasename','username':'x','password':'y'} connection_type: description: The type of the connection. returned: when state is present @@ -149,6 +149,11 @@ returned: when state is present type: dict sample: {'subnet-id':'subnet-aabbccddee'} +raw_connection_properties: + description: A dict of key-value pairs used as parameters for this connection. + returned: when state is present + type: dict + sample: {'JDBC_CONNECTION_URL':'jdbc:mysql://mydb:3306/databasename','USERNAME':'x','PASSWORD':'y'} ''' # Non-ansible imports @@ -309,6 +314,8 @@ def create_or_update_glue_connection(connection, connection_ec2, module, glue_co if changed and not module.check_mode: glue_connection = _await_glue_connection(connection, module) + glue_connection['RawConnectionProperties'] = glue_connection['ConnectionProperties'] + module.exit_json(changed=changed, **camel_dict_to_snake_dict(glue_connection or {}, ignore_list=['ConnectionProperties'])) @@ -363,6 +370,9 @@ def main(): supports_check_mode=True ) + module.deprecate("The 'connection_properties' return key is deprecated and will be replaced by 'raw_connection_properties'. Both values are returned for now.", + date='2024-06-01', collection_name='community.aws') + retry_decorator = AWSRetry.jittered_backoff(retries=10) connection_glue = module.client('glue', retry_decorator=retry_decorator) connection_ec2 = module.client('ec2', retry_decorator=retry_decorator) diff --git a/tests/integration/targets/glue_connection/tasks/test_connection_network.yml b/tests/integration/targets/glue_connection/tasks/test_connection_network.yml index 34485ab6111..2f3e7663842 100644 --- a/tests/integration/targets/glue_connection/tasks/test_connection_network.yml +++ b/tests/integration/targets/glue_connection/tasks/test_connection_network.yml @@ -106,6 +106,7 @@ - glue_connection.physical_connection_requirements.subnet_id == connection_info["Connection"]["PhysicalConnectionRequirements"]["SubnetId"] - glue_connection.physical_connection_requirements.security_group_id_list == connection_info["Connection"]["PhysicalConnectionRequirements"]["SecurityGroupIdList"] - glue_connection.physical_connection_requirements.availability_zone == connection_info["Connection"]["PhysicalConnectionRequirements"]["AvailabilityZone"] + - glue_connection.raw_connection_properties == connection_info["Connection"]["ConnectionProperties"] - name: Create Glue connection (idempotent) (check mode) aws_glue_connection: @@ -225,6 +226,7 @@ - glue_connection_update_check.physical_connection_requirements.subnet_id == connection_info_update_check["Connection"]["PhysicalConnectionRequirements"]["SubnetId"] - glue_connection_update_check.physical_connection_requirements.security_group_id_list == connection_info_update_check["Connection"]["PhysicalConnectionRequirements"]["SecurityGroupIdList"] - glue_connection_update_check.physical_connection_requirements.availability_zone == connection_info_update_check["Connection"]["PhysicalConnectionRequirements"]["AvailabilityZone"] + - glue_connection_update_check.raw_connection_properties == connection_info_update_check["Connection"]["ConnectionProperties"] - name: Update Glue connection aws_glue_connection: @@ -264,6 +266,7 @@ - glue_connection_update.physical_connection_requirements.subnet_id == connection_info_update["Connection"]["PhysicalConnectionRequirements"]["SubnetId"] - glue_connection_update.physical_connection_requirements.security_group_id_list == connection_info_update["Connection"]["PhysicalConnectionRequirements"]["SecurityGroupIdList"] - glue_connection_update.physical_connection_requirements.availability_zone == connection_info_update["Connection"]["PhysicalConnectionRequirements"]["AvailabilityZone"] + - glue_connection_update.raw_connection_properties == connection_info_update["Connection"]["ConnectionProperties"] - name: Delete Glue connection (check mode) aws_glue_connection: From 48aa53a1c658957d85b915c471fb9b9f704104b9 Mon Sep 17 00:00:00 2001 From: ichekaldin <39010411+ichekaldin@users.noreply.github.com> Date: Thu, 1 Apr 2021 04:03:21 +0000 Subject: [PATCH 4/8] Avoid converting connection_parameter keys to lowercase This is a follow to my own PR #503: https://github.com/ansible-collections/community.aws/pull/503 This is a cosmetic change that prevents converting keys in connection_parameters dict to lowercase. As an example, this: ``` - community.aws.glue_connection: name: test-connection connection_parameters: JDBC_ENFORCE_SSL: "false" ... ``` is a valid value, while this: ``` - community.aws.glue_connection: name: test-connection connection_parameters: JDBC_ENFORCE_SSL: "false" ... ``` is not. This PR simply aligns the module output to the expected input. --- ...s_glue_connection-do-not-lowercase-connection-parameters.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/changelogs/fragments/518-aws_glue_connection-do-not-lowercase-connection-parameters.yml b/changelogs/fragments/518-aws_glue_connection-do-not-lowercase-connection-parameters.yml index dd572351921..836a7119b1e 100644 --- a/changelogs/fragments/518-aws_glue_connection-do-not-lowercase-connection-parameters.yml +++ b/changelogs/fragments/518-aws_glue_connection-do-not-lowercase-connection-parameters.yml @@ -1,2 +1,2 @@ minor_changes: - - aws_glue_connection - Avoid converting connection_parameters to lowercase (https://github.com/ansible-collections/community.aws/pull/518) +- aws_glue_connection - avoid converting connection_parameters to lowercase (https://github.com/ansible-collections/community.aws/pull/518). From 2d886e8d7935520ab7527a9a9c64b48cf835a873 Mon Sep 17 00:00:00 2001 From: Mark Chappell Date: Wed, 6 Jul 2022 16:26:06 +0200 Subject: [PATCH 5/8] Apply suggestions from code review --- ...glue_connection-do-not-lowercase-connection-parameters.yml | 4 +++- plugins/modules/glue_connection.py | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/changelogs/fragments/518-aws_glue_connection-do-not-lowercase-connection-parameters.yml b/changelogs/fragments/518-aws_glue_connection-do-not-lowercase-connection-parameters.yml index 836a7119b1e..abe1b4702a6 100644 --- a/changelogs/fragments/518-aws_glue_connection-do-not-lowercase-connection-parameters.yml +++ b/changelogs/fragments/518-aws_glue_connection-do-not-lowercase-connection-parameters.yml @@ -1,2 +1,4 @@ minor_changes: -- aws_glue_connection - avoid converting connection_parameters to lowercase (https://github.com/ansible-collections/community.aws/pull/518). +- aws_glue_connection - added new ``raw_connection_parameters`` return key which doesn't snake case the connection parameters (https://github.com/ansible-collections/community.aws/pull/518). +deprecated_features: +- aws_glue_connection - the ``connection_parameters`` return key has been deprecated and will be removed in a release after 2024-06-01, it is being replaced by the ``raw_connection_parameters`` key (https://github.com/ansible-collections/community.aws/pull/518). diff --git a/plugins/modules/glue_connection.py b/plugins/modules/glue_connection.py index 1f5138ed3de..ed08b8071fc 100644 --- a/plugins/modules/glue_connection.py +++ b/plugins/modules/glue_connection.py @@ -316,7 +316,7 @@ def create_or_update_glue_connection(connection, connection_ec2, module, glue_co glue_connection['RawConnectionProperties'] = glue_connection['ConnectionProperties'] - module.exit_json(changed=changed, **camel_dict_to_snake_dict(glue_connection or {}, ignore_list=['ConnectionProperties'])) + module.exit_json(changed=changed, **camel_dict_to_snake_dict(glue_connection or {}, ignore_list=['RawConnectionProperties'])) def delete_glue_connection(connection, module, glue_connection): From d0bb86382218cda766f6ac437fe5b69b7cbdcca9 Mon Sep 17 00:00:00 2001 From: Mark Chappell Date: Wed, 6 Jul 2022 16:27:13 +0200 Subject: [PATCH 6/8] Only copy value if we have a glue_connection object --- plugins/modules/glue_connection.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/plugins/modules/glue_connection.py b/plugins/modules/glue_connection.py index ed08b8071fc..22ba73e5648 100644 --- a/plugins/modules/glue_connection.py +++ b/plugins/modules/glue_connection.py @@ -314,7 +314,11 @@ def create_or_update_glue_connection(connection, connection_ec2, module, glue_co if changed and not module.check_mode: glue_connection = _await_glue_connection(connection, module) - glue_connection['RawConnectionProperties'] = glue_connection['ConnectionProperties'] + + if glue_connection: + module.deprecate("The 'connection_properties' return key is deprecated and will be replaced by 'raw_connection_properties'. Both values are returned for now.", + date='2024-06-01', collection_name='community.aws') + glue_connection['RawConnectionProperties'] = glue_connection['ConnectionProperties'] module.exit_json(changed=changed, **camel_dict_to_snake_dict(glue_connection or {}, ignore_list=['RawConnectionProperties'])) @@ -370,9 +374,6 @@ def main(): supports_check_mode=True ) - module.deprecate("The 'connection_properties' return key is deprecated and will be replaced by 'raw_connection_properties'. Both values are returned for now.", - date='2024-06-01', collection_name='community.aws') - retry_decorator = AWSRetry.jittered_backoff(retries=10) connection_glue = module.client('glue', retry_decorator=retry_decorator) connection_ec2 = module.client('ec2', retry_decorator=retry_decorator) From 06c34c69170b8a56e8658f0b040eb56e4978c15d Mon Sep 17 00:00:00 2001 From: Mark Chappell Date: Wed, 6 Jul 2022 16:47:30 +0200 Subject: [PATCH 7/8] lint --- plugins/modules/glue_connection.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/plugins/modules/glue_connection.py b/plugins/modules/glue_connection.py index 22ba73e5648..1f278d66b3b 100644 --- a/plugins/modules/glue_connection.py +++ b/plugins/modules/glue_connection.py @@ -109,7 +109,9 @@ RETURN = r''' connection_properties: - description: (deprecated) A dict of key-value pairs (converted to lowercase) used as parameters for this connection. This return key has been deprecated, and will be removed in a release after 2024-06-01. + description: + - (deprecated) A dict of key-value pairs (converted to lowercase) used as parameters for this connection. + - This return key has been deprecated, and will be removed in a release after 2024-06-01. returned: when state is present type: dict sample: {'jdbc_connection_url':'jdbc:mysql://mydb:3306/databasename','username':'x','password':'y'} @@ -314,9 +316,9 @@ def create_or_update_glue_connection(connection, connection_ec2, module, glue_co if changed and not module.check_mode: glue_connection = _await_glue_connection(connection, module) - if glue_connection: - module.deprecate("The 'connection_properties' return key is deprecated and will be replaced by 'raw_connection_properties'. Both values are returned for now.", + module.deprecate("The 'connection_properties' return key is deprecated and will be replaced" + " by 'raw_connection_properties'. Both values are returned for now.", date='2024-06-01', collection_name='community.aws') glue_connection['RawConnectionProperties'] = glue_connection['ConnectionProperties'] From 3c4df1e8dc82fc9666cc64c82972096f6da93478 Mon Sep 17 00:00:00 2001 From: Mark Chappell Date: Wed, 6 Jul 2022 16:50:42 +0200 Subject: [PATCH 8/8] raw_connection_properties --- .../glue_connection/tasks/test_connection_network.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/integration/targets/glue_connection/tasks/test_connection_network.yml b/tests/integration/targets/glue_connection/tasks/test_connection_network.yml index 2f3e7663842..2300155851b 100644 --- a/tests/integration/targets/glue_connection/tasks/test_connection_network.yml +++ b/tests/integration/targets/glue_connection/tasks/test_connection_network.yml @@ -101,7 +101,7 @@ - glue_connection.changed - glue_connection.name == connection_info["Connection"]["Name"] - glue_connection.description == connection_info["Connection"]["Description"] - - glue_connection.connection_properties == connection_info["Connection"]["ConnectionProperties"] + - glue_connection.raw_connection_properties == connection_info["Connection"]["ConnectionProperties"] - glue_connection.connection_type == connection_info["Connection"]["ConnectionType"] - glue_connection.physical_connection_requirements.subnet_id == connection_info["Connection"]["PhysicalConnectionRequirements"]["SubnetId"] - glue_connection.physical_connection_requirements.security_group_id_list == connection_info["Connection"]["PhysicalConnectionRequirements"]["SecurityGroupIdList"] @@ -221,7 +221,7 @@ - glue_connection_update_check.changed - glue_connection_update_check.name == connection_info_update_check["Connection"]["Name"] - glue_connection_update_check.description == connection_info_update_check["Connection"]["Description"] - - glue_connection_update_check.connection_properties == connection_info_update_check["Connection"]["ConnectionProperties"] + - glue_connection_update_check.raw_connection_properties == connection_info_update_check["Connection"]["ConnectionProperties"] - glue_connection_update_check.connection_type == connection_info_update_check["Connection"]["ConnectionType"] - glue_connection_update_check.physical_connection_requirements.subnet_id == connection_info_update_check["Connection"]["PhysicalConnectionRequirements"]["SubnetId"] - glue_connection_update_check.physical_connection_requirements.security_group_id_list == connection_info_update_check["Connection"]["PhysicalConnectionRequirements"]["SecurityGroupIdList"] @@ -261,7 +261,7 @@ - glue_connection_update.changed - glue_connection_update.name == connection_info_update["Connection"]["Name"] - glue_connection_update.description == connection_info_update["Connection"]["Description"] - - glue_connection_update.connection_properties == connection_info_update["Connection"]["ConnectionProperties"] + - glue_connection_update.raw_connection_properties == connection_info_update["Connection"]["ConnectionProperties"] - glue_connection_update.connection_type == connection_info_update["Connection"]["ConnectionType"] - glue_connection_update.physical_connection_requirements.subnet_id == connection_info_update["Connection"]["PhysicalConnectionRequirements"]["SubnetId"] - glue_connection_update.physical_connection_requirements.security_group_id_list == connection_info_update["Connection"]["PhysicalConnectionRequirements"]["SecurityGroupIdList"]