EksJobDefinition L2 construct
A JobDefinition that uses Eks orchestration.
Example
const jobDefn = new batch.EksJobDefinition(this, 'eksf2', {
container: new batch.EksContainerDefinition(this, 'container', {
image: ecs.ContainerImage.fromRegistry('amazon/amazon-ecs-sample'),
volumes: [batch.EksVolume.emptyDir({
name: 'myEmptyDirVolume',
mountPath: '/mount/path',
medium: batch.EmptyDirMediumType.MEMORY,
readonly: true,
sizeLimit: cdk.Size.mebibytes(2048),
})],
}),
});
job_defn = batch.EksJobDefinition(self, "eksf2",
container=batch.EksContainerDefinition(self, "container",
image=ecs.ContainerImage.from_registry("amazon/amazon-ecs-sample"),
volumes=[batch.EksVolume.empty_dir(
name="myEmptyDirVolume",
mount_path="/mount/path",
medium=batch.EmptyDirMediumType.MEMORY,
readonly=True,
size_limit=cdk.Size.mebibytes(2048)
)]
)
)
EksJobDefinition jobDefn = EksJobDefinition.Builder.create(this, "eksf2")
.container(EksContainerDefinition.Builder.create(this, "container")
.image(ContainerImage.fromRegistry("amazon/amazon-ecs-sample"))
.volumes(List.of(EksVolume.emptyDir(EmptyDirVolumeOptions.builder()
.name("myEmptyDirVolume")
.mountPath("/mount/path")
.medium(EmptyDirMediumType.MEMORY)
.readonly(true)
.sizeLimit(Size.mebibytes(2048))
.build())))
.build())
.build();
// Install: dotnet add package Amazon.CDK.Lib
var jobDefn = new EksJobDefinition(this, "eksf2", new EksJobDefinitionProps {
Container = new EksContainerDefinition(this, "container", new EksContainerDefinitionProps {
Image = ContainerImage.FromRegistry("amazon/amazon-ecs-sample"),
Volumes = new [] { EksVolume.EmptyDir(new EmptyDirVolumeOptions {
Name = "myEmptyDirVolume",
MountPath = "/mount/path",
Medium = EmptyDirMediumType.MEMORY,
Readonly = true,
SizeLimit = Size.Mebibytes(2048)
}) }
})
});
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
jobDefn := batch.NewEksJobDefinition(this, jsii.String("eksf2"), &EksJobDefinitionProps{
Container: batch.NewEksContainerDefinition(this, jsii.String("container"), &EksContainerDefinitionProps{
Image: ecs.ContainerImage_FromRegistry(jsii.String("amazon/amazon-ecs-sample")),
Volumes: []EksVolume{
batch.EksVolume_EmptyDir(&EmptyDirVolumeOptions{
Name: jsii.String("myEmptyDirVolume"),
MountPath: jsii.String("/mount/path"),
Medium: batch.EmptyDirMediumType_MEMORY,
Readonly: jsii.Boolean(true),
SizeLimit: cdk.Size_Mebibytes(jsii.Number(2048)),
}),
},
}),
})
Initializer
new EksJobDefinition(scope: Construct, id: string, props: EksJobDefinitionProps)
EksJobDefinition(scope: Construct, id: str, props: EksJobDefinitionProps)
new EksJobDefinition(Construct scope, String id, EksJobDefinitionProps props)
new EksJobDefinition(Construct scope, string id, EksJobDefinitionProps props)
NewEksJobDefinition(Scope Construct, Id *string, Props EksJobDefinitionProps)
Construct Props
containerEksContainerDefinitioncontainerEksContainerDefinitioncontainerEksContainerDefinitionContainerEksContainerDefinitionContainerEksContainerDefinitionrequired#dnsPolicyoptionalDnsPolicydns_policyoptionalDnsPolicydnsPolicyoptionalDnsPolicyDnsPolicyoptionalDnsPolicyDnsPolicyoptionalDnsPolicy= `DnsPolicy.CLUSTER_FIRST`#jobDefinitionNameoptionalstringjob_definition_nameoptionalstrjobDefinitionNameoptionalStringJobDefinitionNameoptionalstringJobDefinitionNameoptional*string#Default: generated by CloudFormation
parametersoptional{ [key: string]: any }parametersoptionaltyping.Mapping[str, Any]parametersoptionalMap<String, Object>ParametersoptionalIDictionary<string, object>Parametersoptional*map[string]interface{}= none#retryAttemptsoptionalnumberretry_attemptsoptionalint | floatretryAttemptsoptionalNumberRetryAttemptsoptionaldoubleRetryAttemptsoptional*float64= 1#The job is retried on failure the same number of attempts as the value.
retryStrategiesoptionalRetryStrategy[]retry_strategiesoptionaltyping.List[RetryStrategy]retryStrategiesoptionalList<RetryStrategy>RetryStrategiesoptionalRetryStrategy[]RetryStrategiesoptional*[]RetryStrategy#Default: no RetryStrategy
schedulingPriorityoptionalnumberscheduling_priorityoptionalint | floatschedulingPriorityoptionalNumberSchedulingPriorityoptionaldoubleSchedulingPriorityoptional*float64= none#Only used in Fairshare Scheduling to decide which job to run first when there are multiple jobs with the same share identifier.
serviceAccountoptionalstringservice_accountoptionalstrserviceAccountoptionalStringServiceAccountoptionalstringServiceAccountoptional*string#Default: the default service account of the container
service accounts are Kubernetes method of identification and authentication, roughly analogous to IAM users.
skipDeregisterOnUpdateoptionalbooleanskip_deregister_on_updateoptionalboolskipDeregisterOnUpdateoptionalBooleanSkipDeregisterOnUpdateoptionalboolSkipDeregisterOnUpdateoptional*bool#Default: undefined - AWS Batch default is false
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.
timeoutoptionalDurationtimeoutoptionalDurationtimeoutoptionalDurationTimeoutoptionalDurationTimeoutoptionalDuration#Default: no timeout
After the amount of time you specify passes, Batch terminates your jobs if they aren't finished.
useHostNetworkoptionalbooleanuse_host_networkoptionalbooluseHostNetworkoptionalBooleanUseHostNetworkoptionalboolUseHostNetworkoptional*bool= true#Otherwise, the Kubernetes pod networking model is enabled. Most AWS Batch workloads are egress-only and don't require the overhead of IP allocation for each pod for incoming connections.
Properties
containerEksContainerDefinitioncontainerEksContainerDefinitioncontainerEksContainerDefinitionContainerEksContainerDefinitionContainerEksContainerDefinition#dnsPolicymay be undefinedDnsPolicydns_policymay be undefinedDnsPolicydnsPolicymay be undefinedDnsPolicyDnsPolicymay be undefinedDnsPolicyDnsPolicymay be undefinedDnsPolicy#envResourceEnvironmentenvResourceEnvironmentenvResourceEnvironmentEnvResourceEnvironmentEnvResourceEnvironment#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*string#jobDefinitionNamestringjob_definition_namestrjobDefinitionNameStringJobDefinitionNamestringJobDefinitionName*string#jobDefinitionRefJobDefinitionReferencejob_definition_refJobDefinitionReferencejobDefinitionRefJobDefinitionReferenceJobDefinitionRefJobDefinitionReferenceJobDefinitionRefJobDefinitionReference#parametersmay be undefined{ [key: string]: any }parametersmay be undefinedtyping.Mapping[str, Any]parametersmay be undefinedMap<String, Object>Parametersmay be undefinedIDictionary<string, object>Parametersmay be undefined*map[string]interface{}#PROPERTY_INJECTION_IDstringproperty_injection_idstrPROPERTY_INJECTION_IDStringPROPERTY_INJECTION_IDstringPROPERTY_INJECTION_ID*stringstatic#retryAttemptsmay be undefinednumberretry_attemptsmay be undefinedint | floatretryAttemptsmay be undefinedNumberRetryAttemptsmay be undefineddoubleRetryAttemptsmay be undefined*float64#The job is retried on failure the same number of attempts as the value.
retryStrategiesRetryStrategy[]retry_strategiestyping.List[RetryStrategy]retryStrategiesList<RetryStrategy>RetryStrategiesRetryStrategy[]RetryStrategies*[]RetryStrategy#schedulingPrioritymay be undefinednumberscheduling_prioritymay be undefinedint | floatschedulingPrioritymay be undefinedNumberSchedulingPrioritymay be undefineddoubleSchedulingPrioritymay be undefined*float64#Only used in Fairshare Scheduling to decide which job to run first when there are multiple jobs with the same share identifier.
serviceAccountmay be undefinedstringservice_accountmay be undefinedstrserviceAccountmay be undefinedStringServiceAccountmay be undefinedstringServiceAccountmay be undefined*string#service accounts are Kubernetes method of identification and authentication, roughly analogous to IAM users.
skipDeregisterOnUpdatemay be undefinedbooleanskip_deregister_on_updatemay be undefinedboolskipDeregisterOnUpdatemay be undefinedBooleanSkipDeregisterOnUpdatemay be undefinedboolSkipDeregisterOnUpdatemay be undefined*bool#Default: undefined - AWS Batch default is false
timeoutmay be undefinedDurationtimeoutmay be undefinedDurationtimeoutmay be undefinedDurationTimeoutmay be undefinedDurationTimeoutmay be undefinedDuration#After the amount of time you specify passes, Batch terminates your jobs if they aren't finished.
useHostNetworkmay be undefinedbooleanuse_host_networkmay be undefinedbooluseHostNetworkmay be undefinedBooleanUseHostNetworkmay be undefinedboolUseHostNetworkmay be undefined*bool#Otherwise, the Kubernetes pod networking model is enabled. Most AWS Batch workloads are egress-only and don't require the overhead of IP allocation for each pod for incoming connections.
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).
fromEksJobDefinitionArn(scope: Construct, id: string, eksJobDefinitionArn: string): IEksJobDefinition@staticmethod def from_eks_job_definition_arn(scope: Construct, id: str, eks_job_definition_arn: str) -> IEksJobDefinitionpublic static IEksJobDefinition fromEksJobDefinitionArn(Construct scope, String id, String eksJobDefinitionArn)public static IEksJobDefinition FromEksJobDefinitionArn(Construct scope, string id, string eksJobDefinitionArn)func FromEksJobDefinitionArn(Scope Construct, Id *string, EksJobDefinitionArn *string) IEksJobDefinitionstatic#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.