Answers: <p>Step 1: Sign into AWS Console</p>
  <p>Step 2: Navigate to CodePipeline service</p>
  <p>Step 3: Click on the “Create Pipeline” button</p>
  <p>Step 4: Enter the Pipeline name and click on the “Next” button</p>
  <p>Step 5: Select “GitHub” as Source provider and enter the following values</p>
  <p>Repository: <a href="https://github.com/cloudacademy/cloud-academy-terraform-pipeline.git" rel="nofollow noreferrer">https://github.com/cloudacademy/cloud-academy-terraform-pipeline.git</a></p>
  <p>Branch: master</p>
  <p>Click on the “Next” button</p>
  <p>Step 6: Select the following Build provider</p>
  <p>AWS CodeBuild</p>
  <p>Project name: </p>
  <p>Click on the “Next” button</p>
  <p>Step 7: Select the following Deploy provider</p>
  <p>AWS CodeDeploy</p>
  <p>Deployment provider: S3</p>
  <p>Click on the “Next” button</p>
  <p>Step 8: Review the values and click on the “Create Pipeline” button</p>
  <p>Step 9: Select the following Build provider</p>
  <p>AWS CodeBuild</p>
  <p>Project name: </p>
  <p>Click on the “Next” button</p>
  <p>Step 10: Select the following Deploy provider</p>
  <p>AWS CodeDeploy</p>
  <p>Deployment provider: S3</p>
  <p>Click on the “Next” button</p>
  <p>Step 11: Review the values and click on the “Create Pipeline” button</p>
  <p>Step 12: Select the following Build provider</p>
  <p>AWS CodeBuild</p>
  <p>Project name: </p>
  <p>Click on the “Next” button</p>
  <p>Step 13: Select the following Deploy provider</p>
  <p>AWS CodeDeploy</p>
  <p>Deployment provider: S3</p>
  <p>Click on the “Next” button</p>
  <p>Step 14: Review the values and click on the “Create Pipeline” button</p>
  <p>Step 15: Select the following Build provider</p>
  <p>AWS CodeBuild</p>
  <p>Project name: </p>
  <p>Click on the “Next” button</p>
  <p>Step 16: Select the following Deploy provider</p>
  <p>AWS CodeDeploy</p>
  <p>Deployment provider: S3</p>
  <p>Click on the “Next” button</p>
  <p>Step 17: Review the values and click on the “Create Pipeline” button</p>
  <p>Step 18: Review</p>
  
Answers: CC BY-SA 4.0
Answers: 2022-10-19T13:37:36.943Z
Answers: I appreciate the thorough answer, but this seems to me like a step-by-step guide on how to create a Terraform pipeline. It looks like it is defined in the console at that (I'm not sure what the GitHub repo you meant to link does — I'm getting a 404). 
  
  I'm more looking for the answer as to whether I can define a pipeline in Terraform and have it deploy itself and other AWS resources.
Answers: Jed
Answers: CC BY-SA 4.0
Answers: 2022-10-19T05:21:41.143Z
Answers: 2022-10-19T05:21:41.143Z
Answers: Rahul Sherkar
Body: <p>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.</p>
  <p>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)?</p>
  <p><strong>Update:</strong></p>
  <p>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 &quot;Build&quot; stage that did this ended up in a &quot;Cancelled&quot; state with the message: <code>Pipeline definition was updated</code>.</p>
  <p>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?</p>
  
Tags: <terraform><github><aws-codepipeline>
Title: Can I define a CodePipeline with Terraform that deploys my Terraform resources?
UserDisplayName: Jed
ThreadText: # Can I define a CodePipeline with Terraform that deploys my Terraform resources?
  
  (Asked by: username_0 on 2022-10-18)
  
  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?
  
  **Tags:** terraform, github, aws-codepipeline
  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_1 on 2022-10-19. Score: 0
  
  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
  
  > **Comments:**
  > **username_0**: I appreciate the thorough answer, but this seems to me like a step-by-step guide on how to create a Terraform pipeline. It looks like it is defined in the console at that (I'm not sure what the GitHub repo you meant to link does — I'm getting a 404).   I'm more looking for the answer as to whether I can define a pipeline in Terraform and have it deploy itself and other AWS resources.  
  
  ---
  
  