software.amazon.awscdk.services.ecs.FargateTaskDefinition Maven / Gradle / Ivy
package software.amazon.awscdk.services.ecs;
/**
* The details of a task definition run on a Fargate cluster.
*/
@javax.annotation.Generated(value = "jsii-pacmak/1.31.0 (build 6fa403d)", date = "2021-07-21T15:56:51.222Z")
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable)
@software.amazon.jsii.Jsii(module = software.amazon.awscdk.services.ecs.$Module.class, fqn = "@aws-cdk/aws-ecs.FargateTaskDefinition")
public class FargateTaskDefinition extends software.amazon.awscdk.services.ecs.TaskDefinition implements software.amazon.awscdk.services.ecs.IFargateTaskDefinition {
protected FargateTaskDefinition(final software.amazon.jsii.JsiiObjectRef objRef) {
super(objRef);
}
protected FargateTaskDefinition(final software.amazon.jsii.JsiiObject.InitializationMode initializationMode) {
super(initializationMode);
}
/**
* Constructs a new instance of the FargateTaskDefinition class.
*
* @param scope This parameter is required.
* @param id This parameter is required.
* @param props
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable)
public FargateTaskDefinition(final @org.jetbrains.annotations.NotNull software.constructs.Construct scope, final @org.jetbrains.annotations.NotNull java.lang.String id, final @org.jetbrains.annotations.Nullable software.amazon.awscdk.services.ecs.FargateTaskDefinitionProps props) {
super(software.amazon.jsii.JsiiObject.InitializationMode.JSII);
software.amazon.jsii.JsiiEngine.getInstance().createNewObject(this, new Object[] { java.util.Objects.requireNonNull(scope, "scope is required"), java.util.Objects.requireNonNull(id, "id is required"), props });
}
/**
* Constructs a new instance of the FargateTaskDefinition class.
*
* @param scope This parameter is required.
* @param id This parameter is required.
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable)
public FargateTaskDefinition(final @org.jetbrains.annotations.NotNull software.constructs.Construct scope, final @org.jetbrains.annotations.NotNull java.lang.String id) {
super(software.amazon.jsii.JsiiObject.InitializationMode.JSII);
software.amazon.jsii.JsiiEngine.getInstance().createNewObject(this, new Object[] { java.util.Objects.requireNonNull(scope, "scope is required"), java.util.Objects.requireNonNull(id, "id is required") });
}
/**
* Imports a task definition from the specified task definition ARN.
*
* @param scope This parameter is required.
* @param id This parameter is required.
* @param fargateTaskDefinitionArn This parameter is required.
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable)
public static @org.jetbrains.annotations.NotNull software.amazon.awscdk.services.ecs.IFargateTaskDefinition fromFargateTaskDefinitionArn(final @org.jetbrains.annotations.NotNull software.constructs.Construct scope, final @org.jetbrains.annotations.NotNull java.lang.String id, final @org.jetbrains.annotations.NotNull java.lang.String fargateTaskDefinitionArn) {
return software.amazon.jsii.JsiiObject.jsiiStaticCall(software.amazon.awscdk.services.ecs.FargateTaskDefinition.class, "fromFargateTaskDefinitionArn", software.amazon.jsii.NativeType.forClass(software.amazon.awscdk.services.ecs.IFargateTaskDefinition.class), new Object[] { java.util.Objects.requireNonNull(scope, "scope is required"), java.util.Objects.requireNonNull(id, "id is required"), java.util.Objects.requireNonNull(fargateTaskDefinitionArn, "fargateTaskDefinitionArn is required") });
}
/**
* Import an existing Fargate task definition from its attributes.
*
* @param scope This parameter is required.
* @param id This parameter is required.
* @param attrs This parameter is required.
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable)
public static @org.jetbrains.annotations.NotNull software.amazon.awscdk.services.ecs.IFargateTaskDefinition fromFargateTaskDefinitionAttributes(final @org.jetbrains.annotations.NotNull software.constructs.Construct scope, final @org.jetbrains.annotations.NotNull java.lang.String id, final @org.jetbrains.annotations.NotNull software.amazon.awscdk.services.ecs.FargateTaskDefinitionAttributes attrs) {
return software.amazon.jsii.JsiiObject.jsiiStaticCall(software.amazon.awscdk.services.ecs.FargateTaskDefinition.class, "fromFargateTaskDefinitionAttributes", software.amazon.jsii.NativeType.forClass(software.amazon.awscdk.services.ecs.IFargateTaskDefinition.class), new Object[] { java.util.Objects.requireNonNull(scope, "scope is required"), java.util.Objects.requireNonNull(id, "id is required"), java.util.Objects.requireNonNull(attrs, "attrs is required") });
}
/**
* The Docker networking mode to use for the containers in the task.
*
* Fargate tasks require the awsvpc network mode.
*/
@Override
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable)
public @org.jetbrains.annotations.NotNull software.amazon.awscdk.services.ecs.NetworkMode getNetworkMode() {
return software.amazon.jsii.Kernel.get(this, "networkMode", software.amazon.jsii.NativeType.forClass(software.amazon.awscdk.services.ecs.NetworkMode.class));
}
/**
* A fluent builder for {@link software.amazon.awscdk.services.ecs.FargateTaskDefinition}.
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable)
public static final class Builder implements software.amazon.jsii.Builder {
/**
* @return a new instance of {@link Builder}.
* @param scope This parameter is required.
* @param id This parameter is required.
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable)
public static Builder create(final software.constructs.Construct scope, final java.lang.String id) {
return new Builder(scope, id);
}
private final software.constructs.Construct scope;
private final java.lang.String id;
private software.amazon.awscdk.services.ecs.FargateTaskDefinitionProps.Builder props;
private Builder(final software.constructs.Construct scope, final java.lang.String id) {
this.scope = scope;
this.id = id;
}
/**
* The name of the IAM task execution role that grants the ECS agent to call AWS APIs on your behalf.
*
* The role will be used to retrieve container images from ECR and create CloudWatch log groups.
*
* Default: - An execution role will be automatically created if you use ECR images in your task definition.
*
* @return {@code this}
* @param executionRole The name of the IAM task execution role that grants the ECS agent to call AWS APIs on your behalf. This parameter is required.
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable)
public Builder executionRole(final software.amazon.awscdk.services.iam.IRole executionRole) {
this.props().executionRole(executionRole);
return this;
}
/**
* The name of a family that this task definition is registered to.
*
* A family groups multiple versions of a task definition.
*
* Default: - Automatically generated name.
*
* @return {@code this}
* @param family The name of a family that this task definition is registered to. This parameter is required.
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable)
public Builder family(final java.lang.String family) {
this.props().family(family);
return this;
}
/**
* The configuration details for the App Mesh proxy.
*
* Default: - No proxy configuration.
*
* @return {@code this}
* @param proxyConfiguration The configuration details for the App Mesh proxy. This parameter is required.
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable)
public Builder proxyConfiguration(final software.amazon.awscdk.services.ecs.ProxyConfiguration proxyConfiguration) {
this.props().proxyConfiguration(proxyConfiguration);
return this;
}
/**
* The name of the IAM role that grants containers in the task permission to call AWS APIs on your behalf.
*
* Default: - A task role is automatically created for you.
*
* @return {@code this}
* @param taskRole The name of the IAM role that grants containers in the task permission to call AWS APIs on your behalf. This parameter is required.
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable)
public Builder taskRole(final software.amazon.awscdk.services.iam.IRole taskRole) {
this.props().taskRole(taskRole);
return this;
}
/**
* The list of volume definitions for the task.
*
* For more information, see
* Task Definition Parameter Volumes.
*
* Default: - No volumes are passed to the Docker daemon on a container instance.
*
* @return {@code this}
* @param volumes The list of volume definitions for the task. This parameter is required.
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable)
public Builder volumes(final java.util.List extends software.amazon.awscdk.services.ecs.Volume> volumes) {
this.props().volumes(volumes);
return this;
}
/**
* The number of cpu units used by the task.
*
* For tasks using the Fargate launch type,
* this field is required and you must use one of the following values,
* which determines your range of valid values for the memory parameter:
*
* 256 (.25 vCPU) - Available memory values: 512 (0.5 GB), 1024 (1 GB), 2048 (2 GB)
*
* 512 (.5 vCPU) - Available memory values: 1024 (1 GB), 2048 (2 GB), 3072 (3 GB), 4096 (4 GB)
*
* 1024 (1 vCPU) - Available memory values: 2048 (2 GB), 3072 (3 GB), 4096 (4 GB), 5120 (5 GB), 6144 (6 GB), 7168 (7 GB), 8192 (8 GB)
*
* 2048 (2 vCPU) - Available memory values: Between 4096 (4 GB) and 16384 (16 GB) in increments of 1024 (1 GB)
*
* 4096 (4 vCPU) - Available memory values: Between 8192 (8 GB) and 30720 (30 GB) in increments of 1024 (1 GB)
*
* Default: 256
*
* @return {@code this}
* @param cpu The number of cpu units used by the task. This parameter is required.
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable)
public Builder cpu(final java.lang.Number cpu) {
this.props().cpu(cpu);
return this;
}
/**
* The amount (in MiB) of memory used by the task.
*
* For tasks using the Fargate launch type,
* this field is required and you must use one of the following values, which determines your range of valid values for the cpu parameter:
*
* 512 (0.5 GB), 1024 (1 GB), 2048 (2 GB) - Available cpu values: 256 (.25 vCPU)
*
* 1024 (1 GB), 2048 (2 GB), 3072 (3 GB), 4096 (4 GB) - Available cpu values: 512 (.5 vCPU)
*
* 2048 (2 GB), 3072 (3 GB), 4096 (4 GB), 5120 (5 GB), 6144 (6 GB), 7168 (7 GB), 8192 (8 GB) - Available cpu values: 1024 (1 vCPU)
*
* Between 4096 (4 GB) and 16384 (16 GB) in increments of 1024 (1 GB) - Available cpu values: 2048 (2 vCPU)
*
* Between 8192 (8 GB) and 30720 (30 GB) in increments of 1024 (1 GB) - Available cpu values: 4096 (4 vCPU)
*
* Default: 512
*
* @return {@code this}
* @param memoryLimitMiB The amount (in MiB) of memory used by the task. This parameter is required.
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable)
public Builder memoryLimitMiB(final java.lang.Number memoryLimitMiB) {
this.props().memoryLimitMiB(memoryLimitMiB);
return this;
}
/**
* @returns a newly built instance of {@link software.amazon.awscdk.services.ecs.FargateTaskDefinition}.
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable)
@Override
public software.amazon.awscdk.services.ecs.FargateTaskDefinition build() {
return new software.amazon.awscdk.services.ecs.FargateTaskDefinition(
this.scope,
this.id,
this.props != null ? this.props.build() : null
);
}
private software.amazon.awscdk.services.ecs.FargateTaskDefinitionProps.Builder props() {
if (this.props == null) {
this.props = new software.amazon.awscdk.services.ecs.FargateTaskDefinitionProps.Builder();
}
return this.props;
}
}
}