Skip to content

CI-CD pipeline through Github workflow actions present in .github folder along with Terraform code present in modules folder & environment/demo folder.

Notifications You must be signed in to change notification settings

praveen1664/GithubAction_CI_Terraform_ECR_Docker_ECS_EFS

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

74 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Github Actions Integration with terraform to create VPC,SG, ECR , ECS, EFS & mounting of EFS

What it contains

  1. This is a complete CI-CD pipeline through Github workflow actions present in .github folder along with Terraform code present in modules folder & environment/demo folder. As soon as there is a checkin in main branch a github workflow will trigger the terrform scripts with workflow name tearrform_plan_apply which will create the followings in AWS on broader level with terraform:

    A. VPC B. CIDR C. Subnets D. Necessary Security Groups E. Elastic Container Registry F. Create Elastic File Systems G. Mount the file syste. H. Create Tasks Definitions I. Mouting Point of EFS to data J. Necessary Policies. K. Policies to assume role.

**Note: We have commented out terraform apply Plan in our .github\workflows\terraform.yml file to prevent any accidental run for infra creation. However we have shown complete CI CD for question no 3 in https://github.com/praveen1664/Github-Bitcoin-Pipeline.git repo. At apply stage you will get below message: sh Terraform Apply is commented out to prevent any accidental run. We have implemented full pipeline in Question 3 in https://github.com/praveen1664/Github-Bitcoin-Pipeline.git repository. Here you can check the Terraform Plan for resource creation or destroy name=SELECTED_COLOR::green sh

  1. How it could be run?

It contain 2 Github Actions Work Flow as part of CI CD
1. "Terraform_Plan_Apply"
2. Terraform destroy
1. Workflow "Terraform_Plan_Apply" will triggred automatically with a push in main branch with Github Actions.
2. There is another GitHub Work which is provided to destroy the infra created in first step. Terraform Destroy Prsent in Gighub,Repo,Actions which could be triggered manually. No Automation is provided here. Please run this if you have run the first GitHub action workflow. It is used to

b. To destroy all the infrastructure created by teraform.

What You need

A valid Github Repo A Valid AWS account with programatic access enabled with access_key & secret_key.

What You need to do to test this code?

(A) Test it in Same repo, same github account my aws account in same structure the please contact me.


  1. Clone this repo & do some dummy checkin say add some comment in READMDEmd.
  2. Make some meaningful comments & do a push.
  3. The Github action "Terraform_Plan_Apply" will trigger automatically.
  4. You can Watch it to be completed in repo,Actions,Terraform_Plan_Apply workflow
  5. check all of the logs.
  6. You can contact me to see how the infra has been created in aws.
  7. Run anoher work flow to destroy the infra from repo , Actions, terraform_destroy to destroy the infra. (You need toenter Destroy to proceed further)

(B) Test this from command line on your system


  1. Take a system which have terraform installed.
  2. Install aws-cli
  3. do aws configure from cli.
  4. Clone my repository.
  5. In providers section uncomment the profile block & region
  6. Also remove my remote backend
  7. Goto , environment\demo folder & run following commands a) terraform init b) terraform plan c) terraform apply
  8. To destroy Please rund the following d) terraform destroy

(C) Want to test it with your github account then


  1. Clone this repo from main branch
  2. Remove my backend from providers section.
  3. Add your backend.
  4. Create your repo & update secrets in your repo by creating 2 variables a) AWS_ACCESS_KEY_ID for your user access Key b) AWS_SECRET_ACCESS_KEY for your secret Key.
  5. In .github\workflowfolder\terraform.yml update aws-region with your region of choice.
  6. Add this code to your repo.
  7. Do some dummy checkin to main.
  8. The Github action "Terraform_Plan_Apply" will trigger automatically.
  9. You can Watch it to be completed in repo,Actions,Terraform_Plan_Apply workflow
  10. Check all of the logs.
  11. You can cross check your aws account to verify the build.
  12. Run anoher work flow from repo , Actions, terraform_destroy to destroy the infra. (You need toenter Destroy to proceed further)

About

CI-CD pipeline through Github workflow actions present in .github folder along with Terraform code present in modules folder & environment/demo folder.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published