software.amazon.awscdk.services.ecs.EcsOptimizedImageOptions Maven / Gradle / Ivy
Show all versions of ecs Show documentation
package software.amazon.awscdk.services.ecs;
/**
* Additional configuration properties for EcsOptimizedImage factory functions.
*
* Example:
*
*
* Vpc vpc;
* AutoScalingGroup autoScalingGroup = AutoScalingGroup.Builder.create(this, "ASG")
* .machineImage(EcsOptimizedImage.amazonLinux(EcsOptimizedImageOptions.builder().cachedInContext(true).build()))
* .vpc(vpc)
* .instanceType(new InstanceType("t2.micro"))
* .build();
*
*/
@javax.annotation.Generated(value = "jsii-pacmak/1.52.1 (build 5ccc8f6)", date = "2022-01-20T19:50:05.569Z")
@software.amazon.jsii.Jsii(module = software.amazon.awscdk.services.ecs.$Module.class, fqn = "@aws-cdk/aws-ecs.EcsOptimizedImageOptions")
@software.amazon.jsii.Jsii.Proxy(EcsOptimizedImageOptions.Jsii$Proxy.class)
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable)
public interface EcsOptimizedImageOptions extends software.amazon.jsii.JsiiSerializable {
/**
* Whether the AMI ID is cached to be stable between deployments.
*
* By default, the newest image is used on each deployment. This will cause
* instances to be replaced whenever a new version is released, and may cause
* downtime if there aren't enough running instances in the AutoScalingGroup
* to reschedule the tasks on.
*
* If set to true, the AMI ID will be cached in cdk.context.json
and the
* same value will be used on future runs. Your instances will not be replaced
* but your AMI version will grow old over time. To refresh the AMI lookup,
* you will have to evict the value from the cache using the cdk context
* command. See https://docs.aws.amazon.com/cdk/latest/guide/context.html for
* more information.
*
* Can not be set to true
in environment-agnostic stacks.
*
* Default: false
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable)
default @org.jetbrains.annotations.Nullable java.lang.Boolean getCachedInContext() {
return null;
}
/**
* @return a {@link Builder} of {@link EcsOptimizedImageOptions}
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable)
static Builder builder() {
return new Builder();
}
/**
* A builder for {@link EcsOptimizedImageOptions}
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable)
public static final class Builder implements software.amazon.jsii.Builder {
java.lang.Boolean cachedInContext;
/**
* Sets the value of {@link EcsOptimizedImageOptions#getCachedInContext}
* @param cachedInContext Whether the AMI ID is cached to be stable between deployments.
* By default, the newest image is used on each deployment. This will cause
* instances to be replaced whenever a new version is released, and may cause
* downtime if there aren't enough running instances in the AutoScalingGroup
* to reschedule the tasks on.
*
* If set to true, the AMI ID will be cached in cdk.context.json
and the
* same value will be used on future runs. Your instances will not be replaced
* but your AMI version will grow old over time. To refresh the AMI lookup,
* you will have to evict the value from the cache using the cdk context
* command. See https://docs.aws.amazon.com/cdk/latest/guide/context.html for
* more information.
*
* Can not be set to true
in environment-agnostic stacks.
* @return {@code this}
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable)
public Builder cachedInContext(java.lang.Boolean cachedInContext) {
this.cachedInContext = cachedInContext;
return this;
}
/**
* Builds the configured instance.
* @return a new instance of {@link EcsOptimizedImageOptions}
* @throws NullPointerException if any required attribute was not provided
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable)
@Override
public EcsOptimizedImageOptions build() {
return new Jsii$Proxy(this);
}
}
/**
* An implementation for {@link EcsOptimizedImageOptions}
*/
@software.amazon.jsii.Stability(software.amazon.jsii.Stability.Level.Stable)
@software.amazon.jsii.Internal
final class Jsii$Proxy extends software.amazon.jsii.JsiiObject implements EcsOptimizedImageOptions {
private final java.lang.Boolean cachedInContext;
/**
* Constructor that initializes the object based on values retrieved from the JsiiObject.
* @param objRef Reference to the JSII managed object.
*/
protected Jsii$Proxy(final software.amazon.jsii.JsiiObjectRef objRef) {
super(objRef);
this.cachedInContext = software.amazon.jsii.Kernel.get(this, "cachedInContext", software.amazon.jsii.NativeType.forClass(java.lang.Boolean.class));
}
/**
* Constructor that initializes the object based on literal property values passed by the {@link Builder}.
*/
protected Jsii$Proxy(final Builder builder) {
super(software.amazon.jsii.JsiiObject.InitializationMode.JSII);
this.cachedInContext = builder.cachedInContext;
}
@Override
public final java.lang.Boolean getCachedInContext() {
return this.cachedInContext;
}
@Override
@software.amazon.jsii.Internal
public com.fasterxml.jackson.databind.JsonNode $jsii$toJson() {
final com.fasterxml.jackson.databind.ObjectMapper om = software.amazon.jsii.JsiiObjectMapper.INSTANCE;
final com.fasterxml.jackson.databind.node.ObjectNode data = com.fasterxml.jackson.databind.node.JsonNodeFactory.instance.objectNode();
if (this.getCachedInContext() != null) {
data.set("cachedInContext", om.valueToTree(this.getCachedInContext()));
}
final com.fasterxml.jackson.databind.node.ObjectNode struct = com.fasterxml.jackson.databind.node.JsonNodeFactory.instance.objectNode();
struct.set("fqn", om.valueToTree("@aws-cdk/aws-ecs.EcsOptimizedImageOptions"));
struct.set("data", data);
final com.fasterxml.jackson.databind.node.ObjectNode obj = com.fasterxml.jackson.databind.node.JsonNodeFactory.instance.objectNode();
obj.set("$jsii.struct", struct);
return obj;
}
@Override
public final boolean equals(final Object o) {
if (this == o) return true;
if (o == null || getClass() != o.getClass()) return false;
EcsOptimizedImageOptions.Jsii$Proxy that = (EcsOptimizedImageOptions.Jsii$Proxy) o;
return this.cachedInContext != null ? this.cachedInContext.equals(that.cachedInContext) : that.cachedInContext == null;
}
@Override
public final int hashCode() {
int result = this.cachedInContext != null ? this.cachedInContext.hashCode() : 0;
return result;
}
}
}