Dockerize .NET Core and Deploy to AWS ECS Fargate with Gitlab CI

Here is what we are gonna do/learn in this document

  • Using Gitlab-CI How to Dockerize and Deploy our .Net Core Application To ECS Fargate

What we need are,

  • Gitlab Repository
  • AWS Account ( Access and Secret Keys )

1. Edit Files on Repository

1.1 Edit the aws-ecs.json File

First, create and edit aws-ecs.json file root folder in the repository

Change the parameters with yours,

executionRoleArnIAM ID
namename of your ECS
imagename of your image URL in ECR
awslogs-region: the region you are working in
awslogs-stream-prefix: optional
awslogs-group: optional
taskRoleArnIAM ID
familyyour task definition family name

1.2 Update the .gitlab-ci.yml File

Change the parameters with yours,

EXAMPLE_REPOSITORY_URL: name of your image name
REGION: 
the region you are working in
EXAMPLE_TASK_DEFINTION_NAME: 
optional
EXAMPLE_CLUSTER_NAME: 
name of your ECS
EXAMPLE_SERVICE_NAME: 
optional
EXAMPLE_DESIRED_COUNT: 
optional -How many tasks you planning to run-

You can set the parameters in GitLab > Settings > CI / CD > Variables
But in this documentation, I chose to set the parameters in the Yaml file.

1.3 Dockerfile

Edit Dockerfile with your definitions it is just an example,

2. Final Step

Before deploying the app we need to add variables into the GitLab which are necessary to connect our AWS account.

in GitLab > Settings > CI / CD > Variables

AWS_ACCESS_KEY_ID : ****
AWS_SECRET_ACCESS_KEY : ****
AWS_DEFAULT_REGION : ****


Thank you for reading in next documentation I will explain “Creating AWS ECS Fargate For .NET Core Application”

Happy Deploying!!

0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x