【发布时间】:2019-06-08 18:40:58
【问题描述】:
我执行了一个调用 powershell 命令的 terraform 文件。我的想法是,不同的订阅出现在屏幕上并选择其中一个,以便稍后我可以在 Azure 中创建某些资源。
选择后,在所选订阅中正确创建了资源组,但再次执行后,选择另一个订阅后,我没有创建任何其他内容并出现添加和删除消息
provider "azurerm" {
version = "=1.28.0"
}
resource "null_resource" "script1" {
triggers {
build_number = "${timestamp()}"
}
provisioner "local-exec" {
command = <<EOT
Login-AzureRmAccount
$SubscriptionId = (Get-AzureRmSubscription | select Name, State, SubscriptionId, TenantId | Out-GridView -Title "Azure Subscription Selector" -PassThru).SubscriptionId
Get-AzureRmSubscription -SubscriptionId $SubscriptionId | Select-AzureRmSubscription
EOT
interpreter = ["powershell"]
}
}
#variable "subscripcion" {}
resource "azurerm_resource_group" "resources_groups" {
name = "resources_groups"
location = "west europe"
}
申请完成!资源:添加 1 个,更改 0 个,销毁 1 个。
我如何使用此选项,我是否可以使用不同的订阅来创建指定的资源而不删除我已经实现的资源?
谢谢
【问题讨论】:
标签: powershell terraform