【发布时间】:2021-07-29 06:11:39
【问题描述】:
在 Azure DevOps 中,我们有以下 YAML 管道,它从 CmdLine 任务应用 Terraform 配置。
输出任务应在 Terraform 部署后返回 Data Factory 的 ObjectId。
我想使用该 ObjectId 并将其作为参数传递给下一个 Azure Powershell Task,以便我可以将该 Id 作为成员添加到 AzureADGroup。
如何在下一个 Powershell 任务中使用名为“Terraform output”的步骤的输出?
- task: CmdLine@2
displayName: Terraform Apply
enabled: False
inputs:
script: terraform apply -auto-approve -input=false tfplan
workingDirectory: infrastructure/tf_scripts/dev
- task: CmdLine@2
displayName: Terraform output
enabled: False
inputs:
script: |
terraform output adf_objectid
workingDirectory: infrastructure/tf_scripts/dev
- task: AzurePowerShell@4
displayName: 'Azure PowerShell script: InlineScript'
inputs:
azureSubscription: 'a6cb1cd3-8d5e-4db6-8af5-bcb66492d5cc'
ScriptType: 'InlineScript'
Inline: |
$spn=(terraform output adf_objectid)
Connect-AzureAD -AadAccessToken $aadToken -AccountId $context.Account.Id -TenantId $context.tenant.id -MsAccessToken $graphToken
Add-AzureADGroupMember -ObjectId xxxxx-xxxxx-xxxxx -RefObjectId $spn
workingDirectory: wd/scripts/dev
azurePowerShellVersion: 'LatestVersion'
【问题讨论】:
标签: azure azure-devops yaml terraform