class PythonShellJob (construct)
| Language | Type name |
|---|---|
.NET | Amazon.CDK.AWS.Glue.Alpha.PythonShellJob |
Go | github.com/aws/aws-cdk-go/awscdkgluealpha/v2#PythonShellJob |
Java | software.amazon.awscdk.services.glue.alpha.PythonShellJob |
Python | aws_cdk.aws_glue_alpha.PythonShellJob |
TypeScript (source) | @aws-cdk/aws-glue-alpha » PythonShellJob |
⚠️ Deprecated: undefined
Implements
IConstruct, IDependable, IResource, IEnvironment, IJob, IGrantable, IJob
Python Shell Jobs class.
A Python shell job runs Python scripts as a shell and supports a Python version that depends on the AWS Glue version you are using. This can be used to schedule and run tasks that don't require an Apache Spark environment.
Example
import * as cdk from 'aws-cdk-lib';
import * as iam from 'aws-cdk-lib/aws-iam';
declare const stack: cdk.Stack;
declare const role: iam.IRole;
declare const script: glue.Code;
new glue.PythonShellJob(stack, 'ImportedJob', { role, script });
Initializer
new PythonShellJob(scope: Construct, id: string, props: PythonShellJobProps)
⚠️ Deprecated: undefined
Parameters
- scope
Construct - id
string - props
PythonShell Job Props
PythonShellJob constructor.
Construct Props
| Name | Type | Description |
|---|---|---|
| role | IRole | IAM Role (required) IAM Role to use for Glue job execution Must be specified by the developer because the L2 doesn't have visibility into the actions the script(s) takes during the job execution The role must trust the Glue service principal (glue.amazonaws.com) and be granted sufficient permissions. |
| script | Code | Script Code Location (required) Script to run when the Glue job executes. |
| connections? | IConnection[] | Connections (optional) List of connections to use for this Glue job Connections are used to connect to other AWS Service or resources within a VPC. |
| continuous | Continuous | Enables continuous logging with the specified props. |
| default | { [string]: string } | Default Arguments (optional) The default arguments for every run of this Glue job, specified as name-value pairs. |
| description? | string | Description (optional) Developer-specified description of the Glue job. |
| extra | Code[] | Additional Python files that AWS Glue adds to the Python path before executing your script. |
| glue | Glue | Glue Version The version of Glue to use to execute this job. |
| job | string | Name of the Glue job (optional) Developer-specified name of the Glue job. |
| job | boolean | Specifies whether job run queuing is enabled for the job runs for this job. |
| library | Library | The set of pre-installed Python libraries to make available to the job. |
| max | Max | The total number of DPU to assign to the Python Job. |
| max | number | Max Concurrent Runs (optional) The maximum number of runs this Glue job can concurrently run. |
| max | number | Max Retries (optional) Maximum number of retry attempts Glue performs if the job fails. |
| python | Python | The version of Python to use to execute this job. |
| security | ISecurity | Security Configuration (optional) Defines the encryption options for the Glue job. |
| tags? | { [string]: string } | Tags (optional) A list of key:value pairs of tags to apply to this Glue job resources. |
| timeout? | Duration | Timeout (optional) The maximum time that a job run can consume resources before it is terminated and enters TIMEOUT status. |
role
⚠️ Deprecated: undefined
Type:
IRole
IAM Role (required) IAM Role to use for Glue job execution Must be specified by the developer because the L2 doesn't have visibility into the actions the script(s) takes during the job execution The role must trust the Glue service principal (glue.amazonaws.com) and be granted sufficient permissions.
See also: https://docs.aws.amazon.com/glue/latest/dg/getting-started-access.html
script
⚠️ Deprecated: undefined
Type:
Code
Script Code Location (required) Script to run when the Glue job executes.
Can be uploaded from the local directory structure using fromAsset or referenced via S3 location using fromBucket
connections?
⚠️ Deprecated: undefined
Type:
IConnection[]
(optional, default: [] - no connections are added to the job)
Connections (optional) List of connections to use for this Glue job Connections are used to connect to other AWS Service or resources within a VPC.
continuousLogging?
⚠️ Deprecated: undefined
Type:
Continuous
(optional, default: continuous logging is enabled.)
Enables continuous logging with the specified props.
defaultArguments?
⚠️ Deprecated: undefined
Type:
{ [string]: string }
(optional, default: no arguments)
Default Arguments (optional) The default arguments for every run of this Glue job, specified as name-value pairs.
This map is the escape hatch for Glue job arguments that this construct does not model. It
MUST NOT be used to set arguments that already have a dedicated prop — configure those through
the corresponding prop instead (continuousLogging, enableMetrics,
enableObservabilityMetrics, sparkUI, className, extraJars, extraJarsFirst,
extraPythonFiles, extraFiles). Passing a construct-managed argument (e.g.
--enable-continuous-cloudwatch-log, --enable-metrics, --enable-spark-ui,
--job-language) or a Glue-reserved argument (--debug, --mode, --JOB_NAME, --endpoint)
here throws at synthesis time, so there is exactly one way to express each intent.
Also note that these are emitted verbatim into the CloudFormation template, so avoid placing secrets here in plaintext. Pass secrets to the job at runtime through AWS Secrets Manager instead. A synthesis-time warning is emitted when an argument key looks like a credential and holds a plaintext literal.
See also: [https://docs.aws.amazon.com/glue/latest/dg/aws-glue-programming-etl-glue-arguments.html for a list of reserved parameters](https://docs.aws.amazon.com/glue/latest/dg/aws-glue-programming-etl-glue-arguments.html for a list of reserved parameters)
description?
⚠️ Deprecated: undefined
Type:
string
(optional, default: no value)
Description (optional) Developer-specified description of the Glue job.
extraPythonFiles?
⚠️ Deprecated: undefined
Type:
Code[]
(optional, default: no extra Python files)
Additional Python files that AWS Glue adds to the Python path before executing your script.
Only individual files are supported, directories are not supported.
Equivalent to the --extra-py-files job argument.
glueVersion?
⚠️ Deprecated: undefined
Type:
Glue
(optional, default: determined by the job type: 4.0 for ETL and Streaming, 5.0 for Flex, 3.0 for Python Shell)
Glue Version The version of Glue to use to execute this job.
jobName?
⚠️ Deprecated: undefined
Type:
string
(optional, default: a name is automatically generated)
Name of the Glue job (optional) Developer-specified name of the Glue job.
jobRunQueuingEnabled?
⚠️ Deprecated: undefined
Type:
boolean
(optional, default: false)
Specifies whether job run queuing is enabled for the job runs for this job.
A value of true means job run queuing is enabled for the job runs. If false or not populated, the job runs will not be considered for queueing. If this field does not match the value set in the job run, then the value from the job run field will be used. This property must be set to false for flex jobs. If this property is enabled, maxRetries must be set to zero.
librarySet?
⚠️ Deprecated: undefined
Type:
Library
(optional, default: LibrarySet.ANALYTICS when running Python 3.9, otherwise no library set is configured)
The set of pre-installed Python libraries to make available to the job.
Only applies to jobs running Python 3.9. Set to LibrarySet.NONE when your libraries are
custom or conflict with the pre-installed ones.
maxCapacity?
⚠️ Deprecated: undefined
Type:
Max
(optional, default: 0.0625)
The total number of DPU to assign to the Python Job.
maxConcurrentRuns?
⚠️ Deprecated: undefined
Type:
number
(optional, default: 1)
Max Concurrent Runs (optional) The maximum number of runs this Glue job can concurrently run.
An error is returned when this threshold is reached. The maximum value you can specify is controlled by a service limit.
maxRetries?
⚠️ Deprecated: undefined
Type:
number
(optional, default: 0)
Max Retries (optional) Maximum number of retry attempts Glue performs if the job fails.
pythonVersion?
⚠️ Deprecated: undefined
Type:
Python
(optional, default: PythonVersion.THREE_NINE)
The version of Python to use to execute this job.
Python shell jobs only support PythonVersion.THREE_NINE. The older PythonVersion.TWO
(Python 2.7) and PythonVersion.THREE (Python 3.6) runtimes have been retired by AWS Glue
and are no longer available for Python shell jobs.
securityConfiguration?
⚠️ Deprecated: undefined
Type:
ISecurity
(optional, default: no security configuration.)
Security Configuration (optional) Defines the encryption options for the Glue job.
tags?
⚠️ Deprecated: undefined
Type:
{ [string]: string }
(optional, default: {} - no tags)
Tags (optional) A list of key:value pairs of tags to apply to this Glue job resources.
timeout?
⚠️ Deprecated: undefined
Type:
Duration
(optional, default: 2880 (2 days for non-streaming))
Timeout (optional) The maximum time that a job run can consume resources before it is terminated and enters TIMEOUT status.
Specified in minutes.
Properties
| Name | Type | Description |
|---|---|---|
| env | Resource | The environment this resource belongs to. |
| grant | IPrincipal | The principal to grant permissions to. |
| job | string | The ARN of the job. |
| job | string | The name of the job. |
| job | Job | A reference to this Job resource, for use with the generated L1 ref interface. |
| node | Node | The tree node. |
| role | IRole | The IAM role Glue assumes to run this job. |
| stack | Stack | The stack in which this resource is defined. |
| static PROPERTY_INJECTION_ID | string | Uniquely identifies this class. |
env
⚠️ Deprecated: undefined
Type:
Resource
The environment this resource belongs to.
For resources that are created and managed in a Stack (those created by
creating new class instances like new Role(), new Bucket(), etc.), this
is always the same as the environment of the stack they belong to.
For referenced resources (those obtained from referencing methods like
Role.fromRoleArn(), Bucket.fromBucketName(), etc.), they might be
different than the stack they were imported into.
grantPrincipal
⚠️ Deprecated: undefined
Type:
IPrincipal
The principal to grant permissions to.
jobArn
⚠️ Deprecated: undefined
Type:
string
The ARN of the job.
jobName
⚠️ Deprecated: undefined
Type:
string
The name of the job.
jobRef
⚠️ Deprecated: undefined
Type:
Job
A reference to this Job resource, for use with the generated L1 ref interface.
node
⚠️ Deprecated: undefined
Type:
Node
The tree node.
role
⚠️ Deprecated: undefined
Type:
IRole
The IAM role Glue assumes to run this job.
stack
⚠️ Deprecated: undefined
Type:
Stack
The stack in which this resource is defined.
static PROPERTY_INJECTION_ID
⚠️ Deprecated: undefined
Type:
string
Uniquely identifies this class.
Methods
| Name | Description |
|---|---|
| apply | Override the cross-stack reference strength for this resource. |
| apply | Apply the given removal policy to this resource. |
| metric(metricName, type, props?) | Create a CloudWatch metric. |
| metric | Return a CloudWatch Metric indicating job failure. |
| metric | Return a CloudWatch Metric indicating job success. |
| metric | Return a CloudWatch Metric indicating job timeout. |
| on | Create a CloudWatch Event Rule for this Glue Job when it's in a given state. |
| on | Return a CloudWatch Event Rule matching FAILED state. |
| on | Create a CloudWatch Event Rule matching JobState.SUCCEEDED. |
| on | Return a CloudWatch Event Rule matching TIMEOUT state. |
| to | Returns a string representation of this construct. |
| with(...mixins) | Applies one or more mixins to this construct. |
applyCrossStackReferenceStrength(strength)
public applyCrossStackReferenceStrength(strength: ReferenceStrength): void
⚠️ Deprecated: undefined
Parameters
- strength
Reference— - The reference strength to use for this resource.Strength
Override the cross-stack reference strength for this resource.
When set, any cross-stack reference to this resource will use the specified
mechanism instead of the global default determined by the
@aws-cdk/core:defaultCrossStackReferences context key. This is useful for
selectively weakening specific references to avoid the "deadly embrace" problem
without changing the app-wide default.
applyRemovalPolicy(policy)
public applyRemovalPolicy(policy: RemovalPolicy): void
⚠️ Deprecated: undefined
Parameters
- policy
RemovalPolicy
Apply the given removal policy to this resource.
The Removal Policy controls what happens to this resource when it stops being managed by CloudFormation, either because you've removed it from the CDK application or because you've made a change that requires the resource to be replaced.
The resource can be deleted (RemovalPolicy.DESTROY), or left in your AWS
account for data recovery and cleanup later (RemovalPolicy.RETAIN).
metric(metricName, type, props?)
public metric(metricName: string, type: MetricType, props?: MetricOptions): Metric
⚠️ Deprecated: undefined
Parameters
- metricName
string— name of the metric typically prefixed withglue.driver.,glue.<executorId>.orglue.ALL.. - type
Metric— the metric type.Type - props
Metric— metric options.Options
Returns
Create a CloudWatch metric.
metricFailure(props?)
public metricFailure(props?: MetricOptions): Metric
⚠️ Deprecated: undefined
Parameters
- props
MetricOptions
Returns
Return a CloudWatch Metric indicating job failure.
This metric is based on the Rule returned by no-args onFailure() call.
metricSuccess(props?)
public metricSuccess(props?: MetricOptions): Metric
⚠️ Deprecated: undefined
Parameters
- props
MetricOptions
Returns
Return a CloudWatch Metric indicating job success.
This metric is based on the Rule returned by no-args onSuccess() call.
metricTimeout(props?)
public metricTimeout(props?: MetricOptions): Metric
⚠️ Deprecated: undefined
Parameters
- props
MetricOptions
Returns
Return a CloudWatch Metric indicating job timeout.
This metric is based on the Rule returned by no-args onTimeout() call.
onEvent(id, options?)
public onEvent(id: string, options?: OnEventOptions): Rule
⚠️ Deprecated: undefined
Parameters
- id
string— construct id. - options
On— event options.Event Options
Returns
Create a CloudWatch Event Rule for this Glue Job when it's in a given state.
onFailure(id, options?)
public onFailure(id: string, options?: OnEventOptions): Rule
⚠️ Deprecated: undefined
Parameters
- id
string— construct id. - options
On— optional event options.Event Options
Returns
Return a CloudWatch Event Rule matching FAILED state.
onSuccess(id, options?)
public onSuccess(id: string, options?: OnEventOptions): Rule
⚠️ Deprecated: undefined
Parameters
- id
string— construct id. - options
On— optional event options.Event Options
Returns
Create a CloudWatch Event Rule matching JobState.SUCCEEDED.
onTimeout(id, options?)
public onTimeout(id: string, options?: OnEventOptions): Rule
⚠️ Deprecated: undefined
Parameters
- id
string— construct id. - options
On— optional event options.Event Options
Returns
Return a CloudWatch Event Rule matching TIMEOUT state.
toString()
public toString(): string
⚠️ Deprecated: undefined
Returns
string
Returns a string representation of this construct.
with(...mixins)
public with(...mixins: IMixin[]): IConstruct
⚠️ Deprecated: undefined
Parameters
- mixins
IMixin
Returns
Applies one or more mixins to this construct.
Mixins are applied in order. The list of constructs is captured at the
start of the call, so constructs added by a mixin will not be visited.
Use multiple with() calls if subsequent mixins should apply to added
constructs.

.NET
Go
Java
Python
TypeScript (