-
Notifications
You must be signed in to change notification settings - Fork 4.5k
(ECS): Missing support for environment files for Fargate deployments #18226
Description
Description
I'm trying to configure my Fargate service to use Environment Files. The official documentation says 1:
Support for environment files is restricted to the EC2 launch type for files hosted on S3.
At the same time, Fargate supports Environment Files for a long time 23.
Is there any chance this feature will be added soon? Since it's supported by EC2 already, should be an easy win.
Use Case
I need this to manage my secrets and env variables in a more secure way. Any workaround ideas are appreciated.
Proposed Solution
Environment files are supported fully for Fargate deployments. Bonus points - it's possible to provide env files configuration in ApplicationLoadBalancedTaskImageOptions
Other information
Unit tests are misleading for this configuration. The following test will pass, while cdk synth won't add the environment file to the template:
// Code
// ...
taskDefinition.addContainer("StaticoonBotContainerWeb", ContainerDefinitionOptions.builder()
.containerName("web")
.portMappings(List.of(PortMapping.builder().hostPort(1234).containerPort(1234).build()))
.image(image)
.environmentFiles(List.of(new S3EnvironmentFile(bucket, "<key>")))
.build());
// ...
// Test
@Test
void usesS3EnvironmentFile() {
template.hasResourceProperties("AWS::ECS::TaskDefinition", Map.of(
"ContainerDefinitions", Match.arrayWith(List.of(Match.objectLike(Map.of(
"EnvironmentFiles", List.of(Map.of(
"Type", "s3",
"Value", "arn:aws:s3:::<bucket>/<key>"
))
))))
));
}Acknowledge
- I may be able to implement this feature request
- This feature might incur a breaking change