Class EnvironmentFile
java.lang.Object
software.amazon.jsii.JsiiObject
software.amazon.awscdk.services.ecs.EnvironmentFile
- All Implemented Interfaces:
software.amazon.jsii.JsiiSerializable
- Direct Known Subclasses:
AssetEnvironmentFile,S3EnvironmentFile
@Generated(value="jsii-pacmak/1.119.0 (build 1634eac)",
date="2025-11-17T14:40:50.512Z")
@Stability(Stable)
public abstract class EnvironmentFile
extends software.amazon.jsii.JsiiObject
Constructs for types of environment files.
Example:
Secret secret;
Secret dbSecret;
StringParameter parameter;
TaskDefinition taskDefinition;
Bucket s3Bucket;
ContainerDefinition newContainer = taskDefinition.addContainer("container", ContainerDefinitionOptions.builder()
.image(ContainerImage.fromRegistry("amazon/amazon-ecs-sample"))
.memoryLimitMiB(1024)
.environment(Map.of( // clear text, not for sensitive data
"STAGE", "prod"))
.environmentFiles(List.of(EnvironmentFile.fromAsset("./demo-env-file.env"), EnvironmentFile.fromBucket(s3Bucket, "assets/demo-env-file.env")))
.secrets(Map.of( // Retrieved from AWS Secrets Manager or AWS Systems Manager Parameter Store at container start-up.
"SECRET", Secret.fromSecretsManager(secret),
"DB_PASSWORD", Secret.fromSecretsManager(dbSecret, "password"), // Reference a specific JSON field, (requires platform version 1.4.0 or later for Fargate tasks)
"API_KEY", Secret.fromSecretsManagerVersion(secret, SecretVersionInfo.builder().versionId("12345").build(), "apiKey"), // Reference a specific version of the secret by its version id or version stage (requires platform version 1.4.0 or later for Fargate tasks)
"PARAMETER", Secret.fromSsmParameter(parameter)))
.build());
newContainer.addEnvironment("QUEUE_NAME", "MyQueue");
newContainer.addSecret("API_KEY", Secret.fromSecretsManager(secret));
newContainer.addSecret("DB_PASSWORD", Secret.fromSecretsManager(secret, "password"));
-
Nested Class Summary
Nested classes/interfaces inherited from class software.amazon.jsii.JsiiObject
software.amazon.jsii.JsiiObject.InitializationMode -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedprotectedEnvironmentFile(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) protectedEnvironmentFile(software.amazon.jsii.JsiiObjectRef objRef) -
Method Summary
Modifier and TypeMethodDescriptionabstract EnvironmentFileConfigbind(software.constructs.Construct scope) Called when the container is initialized to allow this object to bind to the stack.static AssetEnvironmentFileLoads the environment file from a local disk path.static AssetEnvironmentFilefromAsset(String path, AssetOptions options) Loads the environment file from a local disk path.static S3EnvironmentFilefromBucket(IBucket bucket, String key) Loads the environment file from an S3 bucket.static S3EnvironmentFilefromBucket(IBucket bucket, String key, String objectVersion) Loads the environment file from an S3 bucket.Methods inherited from class software.amazon.jsii.JsiiObject
jsiiAsyncCall, jsiiAsyncCall, jsiiCall, jsiiCall, jsiiGet, jsiiGet, jsiiSet, jsiiStaticCall, jsiiStaticCall, jsiiStaticGet, jsiiStaticGet, jsiiStaticSet, jsiiStaticSetMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface software.amazon.jsii.JsiiSerializable
$jsii$toJson
-
Constructor Details
-
EnvironmentFile
protected EnvironmentFile(software.amazon.jsii.JsiiObjectRef objRef) -
EnvironmentFile
protected EnvironmentFile(software.amazon.jsii.JsiiObject.InitializationMode initializationMode) -
EnvironmentFile
@Stability(Stable) protected EnvironmentFile()
-
-
Method Details
-
fromAsset
@Stability(Stable) @NotNull public static AssetEnvironmentFile fromAsset(@NotNull String path, @Nullable AssetOptions options) Loads the environment file from a local disk path.- Parameters:
path- Local disk path. This parameter is required.options-
-
fromAsset
Loads the environment file from a local disk path.- Parameters:
path- Local disk path. This parameter is required.
-
fromBucket
@Stability(Stable) @NotNull public static S3EnvironmentFile fromBucket(@NotNull IBucket bucket, @NotNull String key, @Nullable String objectVersion) Loads the environment file from an S3 bucket.- Parameters:
bucket- The S3 bucket. This parameter is required.key- The object key. This parameter is required.objectVersion- Optional S3 object version.- Returns:
S3EnvironmentFileassociated with the specified S3 object.
-
fromBucket
@Stability(Stable) @NotNull public static S3EnvironmentFile fromBucket(@NotNull IBucket bucket, @NotNull String key) Loads the environment file from an S3 bucket.- Parameters:
bucket- The S3 bucket. This parameter is required.key- The object key. This parameter is required.- Returns:
S3EnvironmentFileassociated with the specified S3 object.
-
bind
@Stability(Stable) @NotNull public abstract EnvironmentFileConfig bind(@NotNull software.constructs.Construct scope) Called when the container is initialized to allow this object to bind to the stack.- Parameters:
scope- The binding scope. This parameter is required.
-