aws-cdk pass ENV to NextJS app throught Ec2TaskDefinition

0 votes

My node.js app needs creds and an endpoint to a DB. I deploy the app using cdk and Ec2TaskDefinition. With ECS.ContainerDefinition.addEnvironment(...) I pass env's to a Docker container. Dockerfile has a multistage type where in the last stage I gather all required envs into a string for future usage in NextJS app.

FROM --platform=linux/amd64 node:16-alpine AS deps
#Skiped code
#....
FROM --platform=linux/amd64 node:16-alpine AS runner

ENV DATABASE_URL=postgresql://${DB_USERNAME}:${DB_PASSWORD}@${DB_ENDPOINT}/postgres?schema=public

EXPOSE 8081
CMD ["node_modules/.bin/next", "start", "-p", "8081"]

But in the next app instead of proper formed string I get something like this:

postgresql://:@/postgres?schema=public

All ENV's are empty. But I can see all required envs in Task definition Web interface on Amazon. Seems that I need to transfer them to Docker somehow...

Jan 3, 2023 in AWS by Tejashwini
• 3,820 points
261 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.

Related Questions In AWS

+1 vote
3 answers

Not able to pass params POST to AWS Lambda from Amazon API Gateway

For this template : application/x-www-form-urlencoded  This line below will ...READ MORE

answered Jun 13, 2018 in AWS by Cloud gunner
• 4,670 points
8,379 views
0 votes
1 answer

Deploy react app to AWS with pm2

Under 'tools' directory, in 'distServer.js' try to ...READ MORE

answered Feb 6, 2019 in AWS by Fatima
2,421 views
+2 votes
1 answer
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

How to Pass the VPC ID while creating the Ec2 instance in AWS using Python Boto3

import boto3 ec2 = boto3.resource('ec2') instance = ec2.create_instances( ...READ MORE

answered Jan 29, 2019 in AWS by Priyaj
• 58,090 points
2,970 views
0 votes
1 answer

AWS ECS Service for Wordpress

If your container needs access to the ...READ MORE

answered Sep 20, 2018 in AWS by Priyaj
• 58,090 points
1,347 views
0 votes
1 answer
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP