![JAR search and dependency download from the Maven repository](/logo.png)
io.cloudshiftdev.awscdk.services.batch.EcsJobDefinitionProps.kt Maven / Gradle / Ivy
@file:Suppress("RedundantVisibilityModifier","RedundantUnitReturnType","RemoveRedundantQualifierName","unused","UnusedImport","ClassName","REDUNDANT_PROJECTION","DEPRECATION")
package io.cloudshiftdev.awscdk.services.batch
import io.cloudshiftdev.awscdk.Duration
import io.cloudshiftdev.awscdk.common.CdkDslMarker
import io.cloudshiftdev.awscdk.common.CdkObject
import io.cloudshiftdev.awscdk.common.CdkObjectWrappers
import kotlin.Any
import kotlin.Boolean
import kotlin.Number
import kotlin.String
import kotlin.Unit
import kotlin.collections.List
import kotlin.collections.Map
/**
* Props for EcsJobDefinition.
*
* Example:
*
* ```
* IVpc vpc;
* EcsJobDefinition ecsJob = EcsJobDefinition.Builder.create(this, "JobDefn")
* .container(EcsEc2ContainerDefinition.Builder.create(this, "containerDefn")
* .image(ContainerImage.fromRegistry("public.ecr.aws/amazonlinux/amazonlinux:latest"))
* .memory(Size.mebibytes(2048))
* .cpu(256)
* .build())
* .build();
* JobQueue queue = JobQueue.Builder.create(this, "JobQueue")
* .computeEnvironments(List.of(OrderedComputeEnvironment.builder()
* .computeEnvironment(ManagedEc2EcsComputeEnvironment.Builder.create(this, "managedEc2CE")
* .vpc(vpc)
* .build())
* .order(1)
* .build()))
* .priority(10)
* .build();
* User user = new User(this, "MyUser");
* ecsJob.grantSubmitJob(user, queue);
* ```
*/
public interface EcsJobDefinitionProps : JobDefinitionProps {
/**
* The container that this job will run.
*/
public fun container(): IEcsContainerDefinition
/**
* Whether to propogate tags from the JobDefinition to the ECS task that Batch spawns.
*
* Default: false
*/
public fun propagateTags(): Boolean? = unwrap(this).getPropagateTags()
/**
* A builder for [EcsJobDefinitionProps]
*/
@CdkDslMarker
public interface Builder {
/**
* @param container The container that this job will run.
*/
public fun container(container: IEcsContainerDefinition)
/**
* @param jobDefinitionName The name of this job definition.
*/
public fun jobDefinitionName(jobDefinitionName: String)
/**
* @param parameters The default parameters passed to the container These parameters can be
* referenced in the `command` that you give to the container.
*/
public fun parameters(parameters: Map)
/**
* @param propagateTags Whether to propogate tags from the JobDefinition to the ECS task that
* Batch spawns.
*/
public fun propagateTags(propagateTags: Boolean)
/**
* @param retryAttempts The number of times to retry a job.
* The job is retried on failure the same number of attempts as the value.
*/
public fun retryAttempts(retryAttempts: Number)
/**
* @param retryStrategies Defines the retry behavior for this job.
*/
public fun retryStrategies(retryStrategies: List)
/**
* @param retryStrategies Defines the retry behavior for this job.
*/
public fun retryStrategies(vararg retryStrategies: RetryStrategy)
/**
* @param schedulingPriority The priority of this Job.
* Only used in Fairshare Scheduling
* to decide which job to run first when there are multiple jobs
* with the same share identifier.
*/
public fun schedulingPriority(schedulingPriority: Number)
/**
* @param timeout The timeout time for jobs that are submitted with this job definition.
* After the amount of time you specify passes,
* Batch terminates your jobs if they aren't finished.
*/
public fun timeout(timeout: Duration)
}
private class BuilderImpl : Builder {
private val cdkBuilder: software.amazon.awscdk.services.batch.EcsJobDefinitionProps.Builder =
software.amazon.awscdk.services.batch.EcsJobDefinitionProps.builder()
/**
* @param container The container that this job will run.
*/
override fun container(container: IEcsContainerDefinition) {
cdkBuilder.container(container.let(IEcsContainerDefinition.Companion::unwrap))
}
/**
* @param jobDefinitionName The name of this job definition.
*/
override fun jobDefinitionName(jobDefinitionName: String) {
cdkBuilder.jobDefinitionName(jobDefinitionName)
}
/**
* @param parameters The default parameters passed to the container These parameters can be
* referenced in the `command` that you give to the container.
*/
override fun parameters(parameters: Map) {
cdkBuilder.parameters(parameters.mapValues{CdkObjectWrappers.unwrap(it.value)})
}
/**
* @param propagateTags Whether to propogate tags from the JobDefinition to the ECS task that
* Batch spawns.
*/
override fun propagateTags(propagateTags: Boolean) {
cdkBuilder.propagateTags(propagateTags)
}
/**
* @param retryAttempts The number of times to retry a job.
* The job is retried on failure the same number of attempts as the value.
*/
override fun retryAttempts(retryAttempts: Number) {
cdkBuilder.retryAttempts(retryAttempts)
}
/**
* @param retryStrategies Defines the retry behavior for this job.
*/
override fun retryStrategies(retryStrategies: List) {
cdkBuilder.retryStrategies(retryStrategies.map(RetryStrategy.Companion::unwrap))
}
/**
* @param retryStrategies Defines the retry behavior for this job.
*/
override fun retryStrategies(vararg retryStrategies: RetryStrategy): Unit =
retryStrategies(retryStrategies.toList())
/**
* @param schedulingPriority The priority of this Job.
* Only used in Fairshare Scheduling
* to decide which job to run first when there are multiple jobs
* with the same share identifier.
*/
override fun schedulingPriority(schedulingPriority: Number) {
cdkBuilder.schedulingPriority(schedulingPriority)
}
/**
* @param timeout The timeout time for jobs that are submitted with this job definition.
* After the amount of time you specify passes,
* Batch terminates your jobs if they aren't finished.
*/
override fun timeout(timeout: Duration) {
cdkBuilder.timeout(timeout.let(Duration.Companion::unwrap))
}
public fun build(): software.amazon.awscdk.services.batch.EcsJobDefinitionProps =
cdkBuilder.build()
}
private class Wrapper(
cdkObject: software.amazon.awscdk.services.batch.EcsJobDefinitionProps,
) : CdkObject(cdkObject),
EcsJobDefinitionProps {
/**
* The container that this job will run.
*/
override fun container(): IEcsContainerDefinition =
unwrap(this).getContainer().let(IEcsContainerDefinition::wrap)
/**
* The name of this job definition.
*
* Default: - generated by CloudFormation
*/
override fun jobDefinitionName(): String? = unwrap(this).getJobDefinitionName()
/**
* The default parameters passed to the container These parameters can be referenced in the
* `command` that you give to the container.
*
* Default: none
*
* [Documentation](https://docs.aws.amazon.com/batch/latest/userguide/job_definition_parameters.html#parameters)
*/
override fun parameters(): Map = unwrap(this).getParameters() ?: emptyMap()
/**
* Whether to propogate tags from the JobDefinition to the ECS task that Batch spawns.
*
* Default: false
*/
override fun propagateTags(): Boolean? = unwrap(this).getPropagateTags()
/**
* The number of times to retry a job.
*
* The job is retried on failure the same number of attempts as the value.
*
* Default: 1
*/
override fun retryAttempts(): Number? = unwrap(this).getRetryAttempts()
/**
* Defines the retry behavior for this job.
*
* Default: - no `RetryStrategy`
*/
override fun retryStrategies(): List =
unwrap(this).getRetryStrategies()?.map(RetryStrategy::wrap) ?: emptyList()
/**
* The priority of this Job.
*
* Only used in Fairshare Scheduling
* to decide which job to run first when there are multiple jobs
* with the same share identifier.
*
* Default: none
*/
override fun schedulingPriority(): Number? = unwrap(this).getSchedulingPriority()
/**
* The timeout time for jobs that are submitted with this job definition.
*
* After the amount of time you specify passes,
* Batch terminates your jobs if they aren't finished.
*
* Default: - no timeout
*/
override fun timeout(): Duration? = unwrap(this).getTimeout()?.let(Duration::wrap)
}
public companion object {
public operator fun invoke(block: Builder.() -> Unit = {}): EcsJobDefinitionProps {
val builderImpl = BuilderImpl()
return Wrapper(builderImpl.apply(block).build())
}
internal fun wrap(cdkObject: software.amazon.awscdk.services.batch.EcsJobDefinitionProps):
EcsJobDefinitionProps = CdkObjectWrappers.wrap(cdkObject) as? EcsJobDefinitionProps ?:
Wrapper(cdkObject)
internal fun unwrap(wrapped: EcsJobDefinitionProps):
software.amazon.awscdk.services.batch.EcsJobDefinitionProps = (wrapped as
CdkObject).cdkObject as software.amazon.awscdk.services.batch.EcsJobDefinitionProps
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy