AZ-400 · Question #592
Drag and Drop Question You have an Azure DevOps project that contains a repo named Repo1. Repo1 contains Terraform code that defines the infrastructure of an app. You need to create a pipeline named P
The correct answer is - task: TerraformCLI@0 displayName: 'Run terraform init' inputs: command: init workingDirectory: $(terraformWorkingDirectory); - task: TerraformCLI@0 displayName: 'Run terraform validate' inputs: command: validate workingDirectory: $(terraformWorkingDirectory); - task: TerraformCLI@0 displayName: 'Run terraform plan' inputs: command: plan workingDirectory: $(terraformWorkingDirectory) environmentServiceName: $(ServiceConnection) commandOptions: -out=tfplan; - task: DownloadPipelineArtifact@2 inputs: artifact: plan patterns: '**/*tfplan' path: $(terraformWorkingDirectory). The correct sequence for Pipeline1 is: (1) Static Code Analysis using Checkov to immediately fail the pipeline on misconfiguration, (2) Run terraform init to initialize the working directory, (3) Run terraform plan with the -out=tfplan flag to generate a plan file, and (4) Publis
Question
Exhibit
Answer Area
Drag items
Correct arrangement
- task: TerraformCLI@0 displayName: 'Run terraform init' inputs: command: init workingDirectory: $(terraformWorkingDirectory)
- task: TerraformCLI@0 displayName: 'Run terraform validate' inputs: command: validate workingDirectory: $(terraformWorkingDirectory)
- task: TerraformCLI@0 displayName: 'Run terraform plan' inputs: command: plan workingDirectory: $(terraformWorkingDirectory) environmentServiceName: $(ServiceConnection) commandOptions: -out=tfplan
- task: DownloadPipelineArtifact@2 inputs: artifact: plan patterns: '**/*tfplan' path: $(terraformWorkingDirectory)
Explanation
The correct sequence for Pipeline1 is: (1) Static Code Analysis using Checkov to immediately fail the pipeline on misconfiguration, (2) Run terraform init to initialize the working directory, (3) Run terraform plan with the -out=tfplan flag to generate a plan file, and (4) Publish the tfplan as a pipeline artifact. This order ensures that misconfigurations are caught before any Terraform operations run (fail fast principle), then the plan is generated and published as required. The DownloadPipelineArtifact task is incorrect here because this pipeline is responsible for publishing the artifact, not downloading it - downloading would be done in a separate release/apply pipeline. The sequence matters critically: Checkov must run first for immediate failure on misconfiguration, terraform init must precede plan, and publishing must be the final step after the plan file exists.
Topics
Community Discussion
No community discussion yet for this question.
