Muhammad Ahmed Fraz
Muhammad Ahmed Fraz

Reputation: 1

Setting Up AWS ECS Fargate and RDS PostgreSQL for NestJS Backend

Title: Help with Setting Up AWS ECS Fargate and RDS PostgreSQL for NestJS Backend

Post:

Hi everyone!

I'm working on deploying a NestJS backend using AWS ECS Fargate with RDS PostgreSQL and could use some guidance.

I've already set up the following:

I'm a bit stuck on configuring my environment variables to ensure proper connectivity between ECS and RDS, and setting up the task's networking/security. Specifically:

  1. How do I securely manage database credentials for the ECS tasks using Secrets Manager?
  2. What’s the best way to configure security groups so ECS Fargate can communicate with RDS securely?
  3. Any recommended references or tutorials that walk through a similar setup (ECS + RDS)?

Any advice, resources, or best practices for this type of setup would be greatly appreciated! Thanks in advance.

What did you try?

What was I expecting?

However, despite these steps, I am still facing connectivity and configuration issues that I can't seem to resolve.

Upvotes: 0

Views: 354

Answers (1)

Mark B
Mark B

Reputation: 200627

How do I securely manage database credentials for the ECS tasks using Secrets Manager?

By configuring the ECS task to pull in the secret value as an environment variable, as documented here.

What’s the best way to configure security groups so ECS Fargate can communicate with RDS securely?

Create two security groups, one assigned to the RDS instance, and one assigned to the Fargate tasks.

For the security group assigned to the Fargate tasks, leave the default outbound rule that allows all outbound traffic.

For the security group assigned to the RDS PostgreSQL instance, add an inbound rule allowing traffic on port 5432, with the source value being the ID of the security group assigned to the Fargate tasks.

Upvotes: 0

Related Questions