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

[PR #518/b03919db backport][stable-4] glue_connection - Avoid converting connection_parameter keys to lowercase #1321

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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