class Job
| Language | Type name |
|---|---|
.NET | Amazon.CDK.AWS.Glue.Job |
Go | github.com/aws/aws-cdk-go/awscdk/v2/awsglue#Job |
Java | software.amazon.awscdk.services.glue.Job |
Python | aws_cdk.aws_glue.Job |
TypeScript (source) | aws-cdk-lib » aws_glue » Job |
Implements
IConstruct, IDependable, IResource, IEnvironment, IJob, IGrantable, IJob
Extends
Job
Implemented by
Py, Py, Py, Python, Scala, Scala, Scala
A Glue Job.
Example
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import { aws_glue as glue } from 'aws-cdk-lib';
import { aws_iam as iam } from 'aws-cdk-lib';
declare const role: iam.Role;
const job = glue.Job.fromJobAttributes(this, 'MyJob', {
jobName: 'jobName',
// the properties below are optional
role: role,
});
Initializer
new Job(scope: Construct, id: string, props?: ResourceProps)
Parameters
- scope
Construct - id
string - props
ResourceProps
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. |
env
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
Type:
IPrincipal
The principal to grant permissions to.
jobArn
Type:
string
The ARN of the job.
jobName
Type:
string
The name of the job.
jobRef
Type:
Job
A reference to this Job resource, for use with the generated L1 ref interface.
node
Type:
Node
The tree node.
role
Type:
IRole
The IAM role Glue assumes to run this job.
stack
Type:
Stack
The stack in which this resource is defined.
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. |
| protected code | |
| protected merge | Merge the customer-supplied defaultArguments with the arguments this construct manages. |
| protected set | Declare key as construct-managed and, when value is defined, emit it into the job's arguments. |
| protected setup | Register (and, when enabled, emit) the continuous-logging arguments this job manages. |
| static from | Identifies an existing Glue Job from a subset of attributes that can be referenced from within another Stack or Construct. |
applyCrossStackReferenceStrength(strength)
public applyCrossStackReferenceStrength(strength: ReferenceStrength): void
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
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
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
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
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
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
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
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
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
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
Returns
string
Returns a string representation of this construct.
with(...mixins)
public with(...mixins: IMixin[]): IConstruct
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.
protected codeS3ObjectUrl(code)
protected codeS3ObjectUrl(code: Code): string
Parameters
- code
Code
Returns
string
protected mergeDefaultArguments(defaultArguments?)
protected mergeDefaultArguments(defaultArguments?: { [string]: string }): { [string]: string }
Parameters
- defaultArguments
{ [string]: string }— the caller-supplied escape-hatch arguments, if any.
Returns
{ [string]: string }
Merge the customer-supplied defaultArguments with the arguments this construct manages.
The construct owns every argument it emits — whether the value comes from a dedicated typed
prop (e.g. continuousLogging, enableMetrics, sparkUI) or from the job class itself
(e.g. --job-language). Those arguments, plus the arguments Glue reserves for its own use,
MUST be configured through their dedicated props rather than the untyped defaultArguments
map, so there is exactly one way to express each intent. Passing such a key through
defaultArguments therefore throws instead of silently winning or being silently dropped.
A managed key whose supplied value is identical to the construct's value is not contradictory, so it is allowed rather than rejected (auto-correcting config is preferred over errors). Glue-reserved keys are never emitted by the construct, so there is no value to reconcile and they always throw.
The reserved set is _managedArgumentKeys — every key the construct declared through
{@link setManagedArgument}, whether or not a value was emitted for it. It is deliberately NOT
derived from the keys that carry a value: a typed prop that turns a feature off (e.g.
enableMetrics: false) emits no value but still reserves its key, so defaultArguments cannot
silently re-enable it.
Conflict detection relies on string equality of the argument keys, which cannot see through
unresolved tokens (e.g. a key produced by CfnJson that only resolves at deploy time). If a
key is a token, the check is skipped for that key and a synthesis-time warning is emitted, so
the (rare) case where a token key resolves to a managed argument at deploy time — in which the
construct-managed value would silently take precedence — is surfaced rather than hidden.
protected setManagedArgument(key, value?)
protected setManagedArgument(key: string, value?: string): void
Parameters
- key
string— the Glue argument key, e.g.--enable-metrics. - value
string— the value to emit, orundefinedto reserve the key without emitting it.
Declare key as construct-managed and, when value is defined, emit it into the job's arguments.
This is the single sink for every argument a job construct derives from its typed props (or
from the job class itself). Call it once per managed key, passing undefined as the value when
the corresponding feature is turned off or unset — the key is still reserved from
defaultArguments either way, so a disabled feature cannot be re-enabled through the escape
hatch. There is deliberately no other way for a subclass to emit a managed argument, so the
reserved set can never drift from what is emitted.
protected setupContinuousLogging(role, props?, securityConfiguration?)
protected setupContinuousLogging(role: IRole, props?: ContinuousLoggingProps, securityConfiguration?: ISecurityConfiguration): void
Parameters
- role
IRole— The IAM role to grant write access to a custom log group, if one is provided. - props
Continuous— The properties for continuous logging configuration.Logging Props - securityConfiguration
ISecurity— The security configuration attached to the job, if any.Configuration
Register (and, when enabled, emit) the continuous-logging arguments this job manages.
All five continuous-logging keys are reserved on every job type regardless of configuration:
they are always registered through {@link setManagedArgument}, and carry a value only when
logging is enabled. This keeps defaultArguments from re-enabling logging a user turned off.
static fromJobAttributes(scope, id, attrs)
public static fromJobAttributes(scope: Construct, id: string, attrs: JobAttributes): IJob
Parameters
- scope
Construct— The scope creating construct (usuallythis). - id
string— The construct's id. - attrs
Job— Attributes for the Glue Job we want to import.Attributes
Returns
Identifies an existing Glue Job from a subset of attributes that can be referenced from within another Stack or Construct.

.NET
Go
Java
Python
TypeScript (