DEV Community

Discussion on: Deploy a Next.js application on AWS using CDK & Fargate

Collapse
 
zoun profile image
Sonia

You can add env variables like this :

taskDefinition.addContainer('container', {
  image: ecs.ContainerImage.fromRegistry("amazon/amazon-ecs-sample"),
  memoryLimitMiB: 1024,
  environment: { // clear text, not for sensitive data
    STAGE: 'prod',
  },
  environmentFiles: [ // list of environment files hosted either on local disk or S3
    ecs.EnvironmentFile.fromAsset('./demo-env-file.env'),
    ecs.EnvironmentFile.fromBucket(s3Bucket, 'assets/demo-env-file.env'),
  ],
});
Enter fullscreen mode Exit fullscreen mode

Honestly, i haven't tried it with SSR, so i cannot give you an answer for that.