Can I define a CodePipeline with Terraform that deploys my Terraform resources?
-
I'm trying to figure out the best way to automate the deployment of infrastructure resources defined in Terraform. Ideally, I'd like to deploy all my code — including resource definitions — in a CI/CD manner.
So, if I define an AWS CodePipeline that reads my Terraform code from GitHub, can I have that CodePipeline...deploy itself (+ any other AWS resources defined in the repo)?
Update:
I built this and tried to push a change through the pipeline that updated the CodeBuild image. It seems like the CodeBuild step to run Terraform succeeded in updating the pipeline, but then the "Build" stage that did this ended up in a "Cancelled" state with the message:
Pipeline definition was updated
.So it seems like it sort of worked, but I may have to kick off a manual release of the most recent change after that. Any downsides/risks?
-
Step 1: Sign into AWS Console
Step 2: Navigate to CodePipeline service
Step 3: Click on the “Create Pipeline” button
Step 4: Enter the Pipeline name and click on the “Next” button
Step 5: Select “GitHub” as Source provider and enter the following values
Repository: https://github.com/cloudacademy/cloud-academy-terraform-pipeline.git
Branch: master
Click on the “Next” button
Step 6: Select the following Build provider
AWS CodeBuild
Project name:
Click on the “Next” button
Step 7: Select the following Deploy provider
AWS CodeDeploy
Deployment provider: S3
Click on the “Next” button
Step 8: Review the values and click on the “Create Pipeline” button
Step 9: Select the following Build provider
AWS CodeBuild
Project name:
Click on the “Next” button
Step 10: Select the following Deploy provider
AWS CodeDeploy
Deployment provider: S3
Click on the “Next” button
Step 11: Review the values and click on the “Create Pipeline” button
Step 12: Select the following Build provider
AWS CodeBuild
Project name:
Click on the “Next” button
Step 13: Select the following Deploy provider
AWS CodeDeploy
Deployment provider: S3
Click on the “Next” button
Step 14: Review the values and click on the “Create Pipeline” button
Step 15: Select the following Build provider
AWS CodeBuild
Project name:
Click on the “Next” button
Step 16: Select the following Deploy provider
AWS CodeDeploy
Deployment provider: S3
Click on the “Next” button
Step 17: Review the values and click on the “Create Pipeline” button
Step 18: Review