Reputation: 366
I have Terraform files in Git-Hub with the following structure...
I have a Azure devOps Build pipeline (yaml file) connected to a Git-Hub repo where the Terraform files are located. This is part of the pipeline.
- task: TerraformTaskV4@4
enabled: true
displayName: 'Terraform : INIT'
inputs:
provider: 'azurerm'
command: 'init'
commandOptions: '-get=true'
workingDirectory: '$(System.DefaultWorkingDirectory)/$(env)'
backendServiceArm: 'spDeployment_ISL-LDS-Test'
backendAzureRmResourceGroupName: '$(statefile-rg-name)'
backendAzureRmStorageAccountName: '$(statefile-sa-name)'
backendAzureRmContainerName: '$(statefile-container-name)'
backendAzureRmKey: '$(statefile-container-name)/$(statefile-name)'
- task: TerraformTaskV4@4
enabled: true
displayName: 'Terraform : VALIDATE'
inputs:
provider: 'azurerm'
command: 'validate'
workingDirectory: '$(System.DefaultWorkingDirectory)/$(env)'
commandOptions:
- task: TerraformTaskV4@4
enabled: true
displayName: 'Terraform : PLAN'
inputs:
provider: 'azurerm'
command: 'plan'
workingDirectory: '$(System.DefaultWorkingDirectory)/$(env)'
commandOptions: '-lock=false -out=plan.out -var "env=$(env)" -var "prefix=$(application-code-prefix)" -var "agentVmIpAddress=[\"$(ipaddressVar)\"]" -var "vnet_address_space=$(vnet-cidr)"'
environmentServiceNameAzureRM: 'spDeployment_ISL-LDS-Test'
The top level Terraform files get downloaded and stored under "artifacts" however I also need the sub-modules to be downloaded.
I did internet search that suggested adding 'commandOptions: '-get=true' to the call to Terraform INIT but this did not work...
There also a task step to copy the Terraform files download to the Azure managed VM - copy the files to the Azure devOps artifacts location.
- task: CopyFiles@2
enabled: true
displayName: 'Copy Terraform Files to: $(Pipeline.Workspace)/s/release/$(env)'
inputs:
SourceFolder: $(Pipeline.Workspace)/s/$(env)
Contents: '*.tf*'
TargetFolder: $(Pipeline.Workspace)/s/release/$(env)
Any suggestions on how to download any Terraform sub-modules reference in the main.tf file?
I have noticed there is a 'built in' task that runs at the beginning of the pipeline that seems to stop check-out of sub-modules...
##[debug]Fetch git repository at: /home/vsts/work/1/s remote: origin. git --config-env=http.extraheader=env_var_http.extraheader fetch --force --no-tags --prune --prune-tags --progress --no-recurse-submodules origin
Upvotes: 0
Views: 522