Code Class
Represents a Glue Job's Code assets (an asset can be a scripts, a jar, a python file or any other file).
Example
ts
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;
// Create a job to run from the workflow
const job = new glue.PySparkEtlJob(stack, 'Job', { role, script });
// Create a workflow and add a trigger that runs the job
const workflow = new glue.Workflow(stack, 'Workflow');
workflow.addOnDemandTrigger('OnDemandTrigger', {
actions: [glue.Action.job(job)],
});
Initializer
ts
new Code()
python
Code()
java
new Code()
csharp
new Code()
go
NewCode()
Methods
bind(scope: Construct, grantable: IGrantable): CodeConfigdef bind(self, scope: Construct, grantable: IGrantable) -> CodeConfigpublic CodeConfig bind(Construct scope, IGrantable grantable)public CodeConfig Bind(Construct scope, IGrantable grantable)func Bind(Scope Construct, Grantable IGrantable) CodeConfig#Called when the Job is initialized to allow this object to bind.
fromAsset(path: string, options?: AssetOptions): AssetCode@staticmethod def from_asset(path: str, options: typing.Optional[AssetOptions] = None) -> AssetCodepublic static AssetCode fromAsset(String path, AssetOptions options)public static AssetCode FromAsset(string path, AssetOptions? options = null)func FromAsset(Path *string, Options AssetOptions) AssetCodestatic#Job code from a local disk path.
1 parameter
Parameters
pathpathpathpathPath— code file (not a directory).
fromBucket(bucket: IBucket, key: string): S3Code@staticmethod def from_bucket(bucket: IBucket, key: str) -> S3Codepublic static S3Code fromBucket(IBucket bucket, String key)public static S3Code FromBucket(IBucket bucket, string key)func FromBucket(Bucket IBucket, Key *string) S3Codestatic#Job code as an S3 object.
2 parameters
Parameters
bucketbucketbucketbucketBucket— The S3 bucket.keykeykeykeyKey— The object key.