Skip to content

Commit

Permalink
glue_connection - Avoid converting connection_parameter keys to lower…
Browse files Browse the repository at this point in the history
…case (#518)

glue_connection - Avoid converting connection_parameter keys to lowercase

SUMMARY

This is a follow to my own PR #503.
This is a cosmetic change that prevents converting keys in connection_parameters dict to lowercase.

ISSUE TYPE

Bugfix Pull Request

COMPONENT NAME

aws_glue_connection
ADDITIONAL INFORMATION

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.

Reviewed-by: Mark Chappell <None>
(cherry picked from commit b03919d)
  • Loading branch information
ichekaldin authored and patchback[bot] committed Jul 6, 2022
1 parent c2337c1 commit d7272fe
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 12 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
minor_changes:
- 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).
19 changes: 16 additions & 3 deletions plugins/modules/aws_glue_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,10 +108,12 @@

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
Expand Down Expand Up @@ -148,6 +150,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
Expand Down Expand Up @@ -308,7 +315,13 @@ 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 {}))
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']))


def delete_glue_connection(connection, module, glue_connection):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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:
Expand Down Expand Up @@ -101,18 +101,19 @@
- 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"]
- 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:
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:
Expand Down Expand Up @@ -152,7 +153,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:
Expand Down Expand Up @@ -191,7 +192,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:
Expand Down Expand Up @@ -220,18 +221,19 @@
- 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"]
- 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:
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:
Expand Down Expand Up @@ -259,11 +261,12 @@
- 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"]
- 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:
Expand Down

0 comments on commit d7272fe

Please sign in to comment.