Show / Hide Table of Contents

Class EnvironmentFile

Constructs for types of environment files.

Inheritance
System.Object
EnvironmentFile
AssetEnvironmentFile
S3EnvironmentFile
Namespace: Amazon.CDK.AWS.ECS
Assembly: Amazon.CDK.AWS.ECS.dll
Syntax (csharp)
public abstract class EnvironmentFile : DeputyBase
Syntax (vb)
Public MustInherit Class EnvironmentFile
    Inherits DeputyBase
Remarks

ExampleMetadata: infused

Examples
Secret secret;
Secret dbSecret;
StringParameter parameter;
TaskDefinition taskDefinition;
Bucket s3Bucket;


var newContainer = taskDefinition.AddContainer("container", new ContainerDefinitionOptions {
    Image = ContainerImage.FromRegistry("amazon/amazon-ecs-sample"),
    MemoryLimitMiB = 1024,
    Environment = new Dictionary<string, string> {  // clear text, not for sensitive data
        { "STAGE", "prod" } },
    EnvironmentFiles = new [] { EnvironmentFile.FromAsset("./demo-env-file.env"), EnvironmentFile.FromBucket(s3Bucket, "assets/demo-env-file.env") },
    Secrets = new Dictionary<string, Secret> {  // 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, new SecretVersionInfo { VersionId = "12345" }, "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) } }
});
newContainer.AddEnvironment("QUEUE_NAME", "MyQueue");

Synopsis

Constructors

EnvironmentFile()
EnvironmentFile(ByRefValue)

Used by jsii to construct an instance of this class from a Javascript-owned object reference

EnvironmentFile(DeputyBase.DeputyProps)

Used by jsii to construct an instance of this class from DeputyProps

Methods

Bind(Construct)

Called when the container is initialized to allow this object to bind to the stack.

FromAsset(String, IAssetOptions)

Loads the environment file from a local disk path.

FromBucket(IBucket, String, String)

Loads the environment file from an S3 bucket.

Constructors

EnvironmentFile()

protected EnvironmentFile()

EnvironmentFile(ByRefValue)

Used by jsii to construct an instance of this class from a Javascript-owned object reference

protected EnvironmentFile(ByRefValue reference)
Parameters
reference Amazon.JSII.Runtime.Deputy.ByRefValue

The Javascript-owned object reference

EnvironmentFile(DeputyBase.DeputyProps)

Used by jsii to construct an instance of this class from DeputyProps

protected EnvironmentFile(DeputyBase.DeputyProps props)
Parameters
props Amazon.JSII.Runtime.Deputy.DeputyBase.DeputyProps

The deputy props

Methods

Bind(Construct)

Called when the container is initialized to allow this object to bind to the stack.

public abstract IEnvironmentFileConfig Bind(Construct scope)
Parameters
scope Construct

The binding scope.

Returns

IEnvironmentFileConfig

FromAsset(String, IAssetOptions)

Loads the environment file from a local disk path.

public static AssetEnvironmentFile FromAsset(string path, IAssetOptions options = null)
Parameters
path System.String

Local disk path.

options IAssetOptions

Local disk path.

Returns

AssetEnvironmentFile

FromBucket(IBucket, String, String)

Loads the environment file from an S3 bucket.

public static S3EnvironmentFile FromBucket(IBucket bucket, string key, string objectVersion = null)
Parameters
bucket IBucket

The S3 bucket.

key System.String

The object key.

objectVersion System.String

Optional S3 object version.

Returns

S3EnvironmentFile

S3EnvironmentFile associated with the specified S3 object.

Back to top Generated by DocFX