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

glue_connection - Avoid converting connection_parameter keys to lowercase #518

Merged
merged 8 commits into from
Jul 6, 2022
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
minor_changes:
- aws_glue_connection - avoid converting connection_parameters to lowercase (https://github.com/ansible-collections/community.aws/pull/518).
tremble marked this conversation as resolved.
Show resolved Hide resolved
16 changes: 13 additions & 3 deletions plugins/modules/glue_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -309,7 +314,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)

module.exit_json(changed=changed, **camel_dict_to_snake_dict(glue_connection or {}))
glue_connection['RawConnectionProperties'] = glue_connection['ConnectionProperties']

module.exit_json(changed=changed, **camel_dict_to_snake_dict(glue_connection or {}, ignore_list=['ConnectionProperties']))
tremble marked this conversation as resolved.
Show resolved Hide resolved


def delete_glue_connection(connection, module, glue_connection):
Expand Down Expand Up @@ -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)
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 @@ -106,13 +106,14 @@
- 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 @@ -225,13 +226,14 @@
- 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 @@ -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:
Expand Down