Skip to content

Commit

Permalink
Added 'worker_type' and 'glue_version' attributes to the module (ansi…
Browse files Browse the repository at this point in the history
…ble-collections#370)

* Added 'worker_type' and 'glue_version' attributes to the module
* fix: fixed compare_glue_job_params to compare the new attributes
* Added changelog - fragments
* Minor docs tweaks
  • Loading branch information
vijayanandsharma authored and danielcotton committed Nov 23, 2021
1 parent 192924c commit 03c305a
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 2 deletions.
3 changes: 3 additions & 0 deletions changelogs/fragments/370_add_attributes_glue_module.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
minor_changes:
- aws_glue_job - added ``number_of_workers``, ``worker_type`` and ``glue_version`` attributes to the module (https://github.com/ansible-collections/community.aws/pull/370).
37 changes: 35 additions & 2 deletions plugins/modules/aws_glue_job.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@
description:
- Manage an AWS Glue job. See U(https://aws.amazon.com/glue/) for details.
requirements: [ boto3 ]
author: "Rob White (@wimnat)"
author:
- "Rob White (@wimnat)"
- "Vijayanand Sharma (@vijayanandsharma)"
options:
allocated_capacity:
description:
Expand Down Expand Up @@ -75,6 +77,22 @@
description:
- The job timeout in minutes.
type: int
glue_version:
description:
- Glue version determines the versions of Apache Spark and Python that AWS Glue supports.
type: str
version_added: 1.5.0
worker_type:
description:
- The type of predefined worker that is allocated when a job runs.
choices: [ 'Standard', 'G.1X', 'G.2X' ]
type: str
version_added: 1.5.0
number_of_workers:
description:
- The number of workers of a defined workerType that are allocated when a job runs.
type: int
version_added: 1.5.0
extends_documentation_fragment:
- amazon.aws.aws
- amazon.aws.ec2
Expand Down Expand Up @@ -249,6 +267,12 @@ def _compare_glue_job_params(user_params, current_params):
return True
if 'Timeout' in user_params and user_params['Timeout'] != current_params['Timeout']:
return True
if 'GlueVersion' in user_params and user_params['GlueVersion'] != current_params['GlueVersion']:
return True
if 'WorkerType' in user_params and user_params['WorkerType'] != current_params['WorkerType']:
return True
if 'NumberOfWorkers' in user_params and user_params['NumberOfWorkers'] != current_params['NumberOfWorkers']:
return True

return False

Expand Down Expand Up @@ -283,6 +307,12 @@ def create_or_update_glue_job(connection, module, glue_job):
params['MaxRetries'] = module.params.get("max_retries")
if module.params.get("timeout") is not None:
params['Timeout'] = module.params.get("timeout")
if module.params.get("glue_version") is not None:
params['GlueVersion'] = module.params.get("glue_version")
if module.params.get("worker_type") is not None:
params['WorkerType'] = module.params.get("worker_type")
if module.params.get("number_of_workers") is not None:
params['NumberOfWorkers'] = module.params.get("number_of_workers")

# If glue_job is not None then check if it needs to be modified, else create it
if glue_job:
Expand Down Expand Up @@ -346,7 +376,10 @@ def main():
name=dict(required=True, type='str'),
role=dict(type='str'),
state=dict(required=True, choices=['present', 'absent'], type='str'),
timeout=dict(type='int')
timeout=dict(type='int'),
glue_version=dict(type='str'),
worker_type=dict(choices=['Standard', 'G.1X', 'G.2X'], type='str'),
number_of_workers=dict(type='int'),
)
)

Expand Down

0 comments on commit 03c305a

Please sign in to comment.