This repository demonstrates how you can use Terraform to provision a AWS CodePipeline & CodeBuild setup that builds and pushes Docker containers to AWS ECR.
- clone repo locally
- cd into the ifrastructure folder find cicd-pipeline-with-ecr.tf
- edit file replacing below values with what you want
- repo_name = ""your-docker-image-build-name"
- organization_name = "yourorg"
- run terrafrom apply
- ex: terraform apply -auto-approve -var image_name=yourdockerfile
-
look for output from terraform, find "ecr_image_respository_url"
-
in aws console find your newly created codecommit repo , should be value you specified in the .tf file as "repo_name"
-
Clone this repo to your workstation
- you may need to setup HTTPS Git credentials for AWS CodeCommit if you havent already.
-
Add your docker file, code, buidlspec.yml, buildspec_test.yml to this local cloned repo.
-
Modify the buildspec.yml file add "ecr_image_respository_url" where indicated, under build and post build.
-
git add., git commit -am"initial" then git push the new files to code commit.
-
in aws console go to codepipline to see your pipeline working.
-
if it doesnt work, troubleshoot.