1

I have a SQL Server database running on Windows Server EC2 instance. I also have Web API (ASP.NET Core WebAPI) deployed as a Service in ECS cluster (Fargate launch type).

What connection string should I use to access this database from my web API?

Right now I'm trying:

data source=NAME_OF_THE_EC2_INSTANCE;initial catalog=DATABASE_NAME;User Id=USER_NAME;Password=PASSWORD;MultipleActiveResultSets=True;App=EntityFramework;Connection Timeout=10;

But it doesn't work. The error returned suggests that the app doesn't even see the database at all.

Ish Thomas
  • 2,270
  • 2
  • 27
  • 57

1 Answers1

0

It seems you'll need to use a NAT instance/Gateway This will enable connectivity between your Fargate instance and EC2 instance where DB is installed.

Another source and also the official documentation

"...Container instances need external network access to communicate with the Amazon ECS service endpoint, so if your container instances are running in a private VPC, they need a network address translation (NAT) instance to provide this access. For more information, see NAT Instances in the Amazon VPC User Guide."

Ravik
  • 694
  • 7
  • 12