{"id":61741,"date":"2021-06-21T13:51:21","date_gmt":"2021-06-21T12:51:21","guid":{"rendered":"http:\/\/content.n4stack.io\/?p=61741"},"modified":"2021-06-28T12:48:02","modified_gmt":"2021-06-28T11:48:02","slug":"azure-devops-terraform-pipeline-with-checkov-approvals","status":"publish","type":"post","link":"http:\/\/content.n4stack.io\/2021\/06\/21\/azure-devops-terraform-pipeline-with-checkov-approvals\/","title":{"rendered":"Azure DevOps Terraform Pipeline with Checkov & Approvals"},"content":{"rendered":"
[et_pb_section fb_built=”1″ fullwidth=”on” _builder_version=”4.9.1″ _module_preset=”default”][et_pb_fullwidth_post_title categories=”off” comments=”off” featured_image=”off” text_color=”light” _builder_version=”4.9.1″ _module_preset=”default” background_color=”#3d3d3d” custom_padding=”200px||100px||false|false”][\/et_pb_fullwidth_post_title][\/et_pb_section][et_pb_section fb_built=”1″ _builder_version=”4.0.11″ custom_padding=”52px|||||”][et_pb_row _builder_version=”4.9.4″ custom_margin=”||||false|false” hover_enabled=”0″ sticky_enabled=”0″][et_pb_column type=”4_4″ _builder_version=”4.0.11″][et_pb_text _builder_version=”4.9.4″ text_font_size=”18px” header_text_color=”#e05206″ header_2_text_color=”#e05206″ header_3_text_color=”#e05206″ header_5_text_color=”#00a9e0″ hover_enabled=”0″ width=”100%” custom_margin=”|0px|||false|false” sticky_enabled=”0″ module_alignment=”center”]<\/p>\n
It\u2019s been just over a year since I\u00a0first posted about the Azure DevOps Terraform Pipeline I used to use<\/a>, I say used to use because that pipeline is now a little outdated. This post covers the updated Pipeline I am starting to deploy alongside my Terraform code.<\/p>\n <\/p>\n <\/p>\n The pipeline itself has expanded a little and it now not only uses stages but also depending on what Terraform is planning on doing it will trigger a manual approval process should there be any resources being destroyed.<\/p>\n The stages in the pipeline are as follows;<\/p>\n The who<\/span>le workflow can be found below (click on the image for a larger view);<\/p>\n <\/a><\/p>\n Azure DevOps Pipeline Workflow {Source: MediaGlasses<\/a>}<\/p>\n As well as the addition of the stages detailed above, the pipeline has moved to using the\u00a0Terraform Azure DevOps extension from Microsoft DevLabs<\/a>\u00a0to the\u00a0Terraform Azure DevOps extension by Charles Zipp<\/a>.<\/p>\n The reasoning for this is that the extension by\u00a0Charles Zipp<\/a>\u00a0enables a lot of the functionality I needed to enable the two different approval stages without having to code the logic myself \u2014 which I am always a fan of \ud83d\ude09<\/p>\n <\/p>\n Now that we have an idea of what should happen, let\u2019s take a look at what the pipeline looks like.<\/p>\n <\/p>\n <\/p>\n The first stage to run downloads and executes a scan of the Terraform files using\u00a0Checkov<\/a>, you will notice the YAML below that we are pulling the\u00a0Checkov container from Dockerhub<\/a> and running it;<\/p>\n [\/et_pb_text][et_pb_code _builder_version=”4.9.4″]Pipeline Overview<\/h3>\n
\n
terraform validate<\/code>\u00a0command to check that the Terraform files are valid, if there are any problems the pipeline errors.<\/li>\n
terraform plan<\/code>\u00a0command. Depending in the state of resources it finds variables are set which are used to determine the next stage which is executed. The output of the\u00a0
terraform plan<\/code>\u00a0command is also upload to Azure DevOps.<\/li>\n
terraform apply<\/code>\u00a0and effects the change.<\/li>\n
terraform apply<\/code>\u00a0command is executed.<\/li>\n<\/ul>\n
The Stages<\/h3>\n
Stage: Checkov Scan<\/h4>\n