EcsJobDefinition L2 construct
A JobDefinition that uses ECS orchestration.
Example
const jobDefn = new batch.EcsJobDefinition(this, 'JobDefn', {
container: new batch.EcsFargateContainerDefinition(this, 'myFargateContainer', {
image: ecs.ContainerImage.fromRegistry('public.ecr.aws/amazonlinux/amazonlinux:latest'),
memory: cdk.Size.mebibytes(2048),
cpu: 256,
ephemeralStorageSize: cdk.Size.gibibytes(100),
fargateCpuArchitecture: ecs.CpuArchitecture.ARM64,
fargateOperatingSystemFamily: ecs.OperatingSystemFamily.LINUX,
}),
});
job_defn = batch.EcsJobDefinition(self, "JobDefn",
container=batch.EcsFargateContainerDefinition(self, "myFargateContainer",
image=ecs.ContainerImage.from_registry("public.ecr.aws/amazonlinux/amazonlinux:latest"),
memory=cdk.Size.mebibytes(2048),
cpu=256,
ephemeral_storage_size=cdk.Size.gibibytes(100),
fargate_cpu_architecture=ecs.CpuArchitecture.ARM64,
fargate_operating_system_family=ecs.OperatingSystemFamily.LINUX
)
)
EcsJobDefinition jobDefn = EcsJobDefinition.Builder.create(this, "JobDefn")
.container(EcsFargateContainerDefinition.Builder.create(this, "myFargateContainer")
.image(ContainerImage.fromRegistry("public.ecr.aws/amazonlinux/amazonlinux:latest"))
.memory(Size.mebibytes(2048))
.cpu(256)
.ephemeralStorageSize(Size.gibibytes(100))
.fargateCpuArchitecture(CpuArchitecture.ARM64)
.fargateOperatingSystemFamily(OperatingSystemFamily.LINUX)
.build())
.build();
// Install: dotnet add package Amazon.CDK.Lib
var jobDefn = new EcsJobDefinition(this, "JobDefn", new EcsJobDefinitionProps {
Container = new EcsFargateContainerDefinition(this, "myFargateContainer", new EcsFargateContainerDefinitionProps {
Image = ContainerImage.FromRegistry("public.ecr.aws/amazonlinux/amazonlinux:latest"),
Memory = Size.Mebibytes(2048),
Cpu = 256,
EphemeralStorageSize = Size.Gibibytes(100),
FargateCpuArchitecture = CpuArchitecture.ARM64,
FargateOperatingSystemFamily = OperatingSystemFamily.LINUX
})
});
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
jobDefn := batch.NewEcsJobDefinition(this, jsii.String("JobDefn"), &EcsJobDefinitionProps{
Container: batch.NewEcsFargateContainerDefinition(this, jsii.String("myFargateContainer"), &EcsFargateContainerDefinitionProps{
Image: ecs.ContainerImage_FromRegistry(jsii.String("public.ecr.aws/amazonlinux/amazonlinux:latest")),
Memory: cdk.Size_Mebibytes(jsii.Number(2048)),
Cpu: jsii.Number(256),
EphemeralStorageSize: cdk.Size_Gibibytes(jsii.Number(100)),
FargateCpuArchitecture: ecs.CpuArchitecture_ARM64(),
FargateOperatingSystemFamily: ecs.OperatingSystemFamily_LINUX(),
}),
})
Initializer
new EcsJobDefinition(scope: Construct, id: string, props: EcsJobDefinitionProps)
EcsJobDefinition(scope: Construct, id: str, props: EcsJobDefinitionProps)
new EcsJobDefinition(Construct scope, String id, EcsJobDefinitionProps props)
new EcsJobDefinition(Construct scope, string id, EcsJobDefinitionProps props)
NewEcsJobDefinition(Scope Construct, Id *string, Props EcsJobDefinitionProps)
Construct Props
containerIEcsContainerDefinitioncontainerIEcsContainerDefinitioncontainerIEcsContainerDefinitionContainerIEcsContainerDefinitionContainerIEcsContainerDefinitionrequired#jobDefinitionNamestringjob_definition_namestrjobDefinitionNameStringJobDefinitionNamestringJobDefinitionName*string= generated by CloudFormation#parameters{ [key: string]: any }parameterstyping.Mapping[str, Any]parametersMap<String, Object>ParametersIDictionary<string, object>Parameters*map[string]interface{}= none#propagateTagsbooleanpropagate_tagsboolpropagateTagsBooleanPropagateTagsboolPropagateTags*bool= false#retryAttemptsnumberretry_attemptsint | floatretryAttemptsNumberRetryAttemptsdoubleRetryAttempts*float64= 1#The job is retried on failure the same number of attempts as the value.
retryStrategiesRetryStrategy[]retry_strategiestyping.List[RetryStrategy]retryStrategiesList<RetryStrategy>RetryStrategiesRetryStrategy[]RetryStrategies*[]RetryStrategy= no `RetryStrategy`#schedulingPrioritynumberscheduling_priorityint | floatschedulingPriorityNumberSchedulingPrioritydoubleSchedulingPriority*float64= none#Only used in Fairshare Scheduling to decide which job to run first when there are multiple jobs with the same share identifier.
skipDeregisterOnUpdatebooleanskip_deregister_on_updateboolskipDeregisterOnUpdateBooleanSkipDeregisterOnUpdateboolSkipDeregisterOnUpdate*bool= undefined - AWS Batch default is…#When the property is set to false, the previous revision of the job definition is de-registered after a new revision is created. When the property is set to true, the previous revision of the job definition is not de-registered.
default
Default: undefined - AWS Batch default is false
Properties
containerIEcsContainerDefinitioncontainerIEcsContainerDefinitioncontainerIEcsContainerDefinitionContainerIEcsContainerDefinitionContainerIEcsContainerDefinitionrequired#envResourceEnvironmentenvResourceEnvironmentenvResourceEnvironmentEnvResourceEnvironmentEnvResourceEnvironmentrequired#notes
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.
jobDefinitionArnstringjob_definition_arnstrjobDefinitionArnStringJobDefinitionArnstringJobDefinitionArn*stringrequired#jobDefinitionNamestringjob_definition_namestrjobDefinitionNameStringJobDefinitionNamestringJobDefinitionName*stringrequired#jobDefinitionRefJobDefinitionReferencejob_definition_refJobDefinitionReferencejobDefinitionRefJobDefinitionReferenceJobDefinitionRefJobDefinitionReferenceJobDefinitionRefJobDefinitionReferencerequired#parameters{ [key: string]: any }parameterstyping.Mapping[str, Any]parametersMap<String, Object>ParametersIDictionary<string, object>Parameters*map[string]interface{}#PROPERTY_INJECTION_IDstringproperty_injection_idstrPROPERTY_INJECTION_IDStringPROPERTY_INJECTION_IDstringPROPERTY_INJECTION_ID*stringrequiredstatic#retryAttemptsnumberretry_attemptsint | floatretryAttemptsNumberRetryAttemptsdoubleRetryAttempts*float64#The job is retried on failure the same number of attempts as the value.
retryStrategiesRetryStrategy[]retry_strategiestyping.List[RetryStrategy]retryStrategiesList<RetryStrategy>RetryStrategiesRetryStrategy[]RetryStrategies*[]RetryStrategyrequired#schedulingPrioritynumberscheduling_priorityint | floatschedulingPriorityNumberSchedulingPrioritydoubleSchedulingPriority*float64#Only used in Fairshare Scheduling to decide which job to run first when there are multiple jobs with the same share identifier.
skipDeregisterOnUpdatebooleanskip_deregister_on_updateboolskipDeregisterOnUpdateBooleanSkipDeregisterOnUpdateboolSkipDeregisterOnUpdate*bool= undefined - AWS Batch default is…#default
Default: undefined - AWS Batch default is false
Methods
addRetryStrategy(strategy: RetryStrategy): voiddef add_retry_strategy(self, strategy: RetryStrategy) -> Nonepublic void addRetryStrategy(RetryStrategy strategy)public void AddRetryStrategy(RetryStrategy strategy)func AddRetryStrategy(Strategy RetryStrategy)#applyCrossStackReferenceStrength(strength: ReferenceStrength): voiddef apply_cross_stack_reference_strength(self, strength: ReferenceStrength) -> Nonepublic void applyCrossStackReferenceStrength(ReferenceStrength strength)public void ApplyCrossStackReferenceStrength(ReferenceStrength strength)func ApplyCrossStackReferenceStrength(Strength ReferenceStrength)#notes · 1 parameter
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.
Parameters
strengthstrengthstrengthstrengthStrength— - The reference strength to use for this resource.
applyRemovalPolicy(policy: RemovalPolicy): voiddef apply_removal_policy(self, policy: RemovalPolicy) -> Nonepublic void applyRemovalPolicy(RemovalPolicy policy)public void ApplyRemovalPolicy(RemovalPolicy policy)func ApplyRemovalPolicy(Policy RemovalPolicy)#notes
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).
fromJobDefinitionArn(scope: Construct, id: string, jobDefinitionArn: string): IJobDefinition@staticmethod def from_job_definition_arn(scope: Construct, id: str, job_definition_arn: str) -> IJobDefinitionpublic static IJobDefinition fromJobDefinitionArn(Construct scope, String id, String jobDefinitionArn)public static IJobDefinition FromJobDefinitionArn(Construct scope, string id, string jobDefinitionArn)func FromJobDefinitionArn(Scope Construct, Id *string, JobDefinitionArn *string) IJobDefinitionstatic#grantSubmitJob(identity: IGrantable, queue: IJobQueueRef): voiddef grant_submit_job(self, identity: IGrantable, queue: IJobQueueRef) -> Nonepublic void grantSubmitJob(IGrantable identity, IJobQueueRef queue)public void GrantSubmitJob(IGrantable identity, IJobQueueRef queue)func GrantSubmitJob(Identity IGrantable, Queue IJobQueueRef)#[disable-awslint:no-grants]
isConstruct(x: any): boolean@staticmethod def is_construct(x: Any) -> boolpublic static Boolean isConstruct(Object x)public static bool IsConstruct(object x)func IsConstruct(X interface{}) *boolstatic#notes · 1 parameter · returns
Use this method instead of instanceof to properly detect Construct instances, even when the construct library is symlinked.
Explanation: in JavaScript, multiple copies of the constructs library on disk are seen as independent, completely different libraries. As a consequence, the class Construct in each copy of the constructs library is seen as a different class, and an instance of one class will not test as instanceof the other class. npm install will not create installations like this, but users may manually symlink construct libraries together or use a monorepo tool: in those cases, multiple copies of the constructs library can be accidentally installed, and instanceof will behave unpredictably. It is safest to avoid using instanceof, and using this type-testing method instead.
Parameters
xxxxX— Any object.
Returns: true if x is an object created from a class which extends Construct.
isOwnedResource(construct: IConstruct): boolean@staticmethod def is_owned_resource(construct: IConstruct) -> boolpublic static Boolean isOwnedResource(IConstruct construct)public static bool IsOwnedResource(IConstruct construct)func IsOwnedResource(Construct IConstruct) *boolstatic#isResource(construct: IConstruct): boolean@staticmethod def is_resource(construct: IConstruct) -> boolpublic static Boolean isResource(IConstruct construct)public static bool IsResource(IConstruct construct)func IsResource(Construct IConstruct) *boolstatic#toString(): stringdef to_string(self, ) -> strpublic String toString()public string ToString()func ToString() *string#with(...mixins: IMixin[]): IConstructdef with(self, mixins: IMixin) -> IConstructpublic IConstruct with(IMixin mixins)public IConstruct With(IMixin mixins)func With(Mixins IMixin) IConstruct#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.