Development and deployment of a .NET 6 project with a focus on Amazon EC2 and RDS PostgreSQL.
This .NET 6 project is an application that demonstrates the construction of a REST API using JWT for authentication and authorization. The project utilizes Entity Framework to manage access to a PostgreSQL database hosted on Amazon RDS. The repository pattern is applied for data management.
- .NET 6
- Entity Framework Core
- Amazon EC2
- Amazon RDS
- xUnit
- AutoMapper
- FluentValidation
- Jwt
Before starting development and deployment of the project, you need to set up your development environment. Make sure you have:
-
An AWS account to configure EC2 and RDS.
Each project has its folder, and its tests are together in these folders.
├── src/
│ ├── ApiAws.Api/Aws.Api # Application API
│ ├── ApiAws.Infra/Aws.Infra # Data access layer
│ ├── ApiAws.Domain/Aws.Domain # Domain layer
│ ├── ApiAws.Services/Aws.Services # Services layer
│ └── ApiAws.Api.sln # Visual Studio solution
│
├── .gitignore # .gitignore file
├── README.md # This file
└── appsettings.json # Application settings
Customize the project structure according to your application's needs.
-
Clone this repository inside your EC2 instance with .NET and dotnet ef installed:
git clone https://github.com/guilhermebernava/api-aws.git
-
Configure environment variables in the
appsettings.json
file with the database connection information. -
Run Entity Framework migrations to create the database schema:
dotnet ef database update
-
Ensure that the files within
launchSettings.json
are configured to access your EC2's URL."Prod": { "commandName": "Project", "dotnetRunMessages": true, "launchBrowser": true, "launchUrl": "swagger", "applicationUrl": "https://+:443;http://+:80", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Prod" } }
-
Run the application on your EC2 instance:
sudo dotnet run