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.98.0 (build 00b106d)", date="2024-05-08T21:35:06.558Z") @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

    Constructors
    Modifier
    Constructor
    Description
    protected
     
    protected
    EnvironmentFile(software.amazon.jsii.JsiiObject.InitializationMode initializationMode)
     
    protected
    EnvironmentFile(software.amazon.jsii.JsiiObjectRef objRef)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    bind(software.constructs.Construct scope)
    Called when the container is initialized to allow this object to bind to the stack.
    Loads the environment file from a local disk path.
    fromAsset(String path, AssetOptions options)
    Loads the environment file from a local disk path.
    fromBucket(IBucket bucket, String key)
    Loads the environment file from an S3 bucket.
    fromBucket(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, jsiiStaticSet

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods 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

      @Stability(Stable) @NotNull public static AssetEnvironmentFile fromAsset(@NotNull String path)
      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:
      S3EnvironmentFile associated 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:
      S3EnvironmentFile associated 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.