# S3EnvironmentFile

Environment file from S3.

Extends: [EnvironmentFile](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_ecs.EnvironmentFile.html) › S3EnvironmentFile
Obtainable from: [EnvironmentFile.fromBucket](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_ecs.EnvironmentFile.html#frombucket)

- Source: [`aws-ecs/lib/environment-file.ts`](https://github.com/aws/aws-cdk/blob/v2.278.0/packages/aws-cdk-lib/aws-ecs/lib/environment-file.ts#L81)

## Example

TypeScript:

```ts
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import { aws_ecs as ecs } from 'aws-cdk-lib';
import { aws_s3 as s3 } from 'aws-cdk-lib';

declare const bucket: s3.Bucket;
const s3EnvironmentFile = new ecs.S3EnvironmentFile(bucket, 'key', /* all optional props */ 'objectVersion');
```

Python:

```python
# The code below shows an example of how to instantiate this type.
# The values are placeholders you should change.
from aws_cdk import aws_ecs as ecs
from aws_cdk import aws_s3 as s3

# bucket: s3.Bucket

s3_environment_file = ecs.S3EnvironmentFile(bucket, "key", "objectVersion")
```

Java:

```java
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import software.amazon.awscdk.services.ecs.*;
import software.amazon.awscdk.services.s3.*;

Bucket bucket;

S3EnvironmentFile s3EnvironmentFile = new S3EnvironmentFile(bucket, "key", "objectVersion");
```

C# / .NET:

```csharp
// Install: dotnet add package Amazon.CDK.Lib
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
using Amazon.CDK.AWS.ECS;
using Amazon.CDK.AWS.S3;

Bucket bucket;

var s3EnvironmentFile = new S3EnvironmentFile(bucket, "key", "objectVersion");
```

Golang:

```go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
// The code below shows an example of how to instantiate this type.
// The values are placeholders you should change.
import "github.com/aws/aws-cdk-go/awscdk"
import "github.com/aws/aws-cdk-go/awscdk"

var bucket Bucket

s3EnvironmentFile := awscdk.Aws_ecs.NewS3EnvironmentFile(bucket, jsii.String("key"), jsii.String("objectVersion"))
```

## Initializer

TypeScript:

```ts
new S3EnvironmentFile(bucket: IBucket, key: string, objectVersion?: string)
```

Python:

```python
S3EnvironmentFile(bucket: IBucket, key: str, object_version: typing.Optional[str] = None)
```

Java:

```java
new S3EnvironmentFile(IBucket bucket, String key, String objectVersion)
```

C# / .NET:

```csharp
new S3EnvironmentFile(IBucket bucket, string key, string? objectVersion = null)
```

Golang:

```go
NewS3EnvironmentFile(Bucket IBucket, Key *string, ObjectVersion *string)
```

## Methods

- `bind(_scope: Construct): EnvironmentFileConfig` — Called when the container is initialized to allow this object to bind to the stack.

- `fromAsset(path: string, options?: AssetOptions): AssetEnvironmentFile` (static) — Loads the environment file from a local disk path.

  **Parameters**

  - `path` — Local disk path.

- `fromBucket(bucket: IBucket, key: string, objectVersion?: string): S3EnvironmentFile // chainable` (static) — Loads the environment file from an S3 bucket.

  **Parameters**

  - `bucket` — The S3 bucket.
  - `key` — The object key.
  - `objectVersion` — Optional S3 object version.

  **Returns:** `S3EnvironmentFile` associated with the specified S3 object.
