我正在尝试通过具有多个源地址的 Terraform 为 Azure 中的网络安全组配置网络安全规则。
基于文档 https://www.terraform.io/docs/providers/azurerm/r/network_security_rule.html
但是,我无法使其正常工作,也无法找到任何示例:
https://www.terraform.io/docs/providers/azurerm/r/network_security_rule.html#source_address_prefixes
我收到错误:
错误:azurerm_network_security_rule.test0:“source_address_prefix”:未设置必填字段错误:azurerm_network_security_rule.test0::无效或未知密钥:source_address_prefixes
这是我的示例:
resource "azurerm_network_security_rule" "test0" {
name = "RDP"
priority = 100
direction = "Inbound"
access = "Allow"
protocol = "TCP"
source_port_range = "*"
destination_port_range = "3389"
source_address_prefixes = "{200.160.200.30,200.160.200.60}"
destination_address_prefix = "VirtualNetwork"
network_security_group_name= "${azurerm_network_security_group.test.name}"
resource_group_name = "${azurerm_resource_group.test.name}"
}
Run Code Online (Sandbox Code Playgroud)
请告诉我。
谢谢!
azure azure-virtual-network terraform network-security-groups terraform-provider-azure
我正在尝试在我的 terraform 执行中使用以下内容:
resource "azurerm_virtual_machine_extension" "vmex" {
name = "myVM"
location = "eastus"
resource_group_name = "${azurerm_resource_group.rg.name}"
virtual_machine_name = "${azurerm_virtual_machine.vm.name}"
publisher = "Microsoft.Compute"
type = "CustomScriptExtension"
type_handler_version = "1.9"
settings = <<SETTINGS
{
"fileUris": [
"https://example.com/scripts/test.ps1"
],
"commandToExecute": "powershell -ExecutionPolicy Unrestricted -File 'test.ps1'"
}
SETTINGS
}
Run Code Online (Sandbox Code Playgroud)
当执行时,我得到以下输出:
错误:应用计划时出错:
发生 1 个错误:
azurerm_virtual_machine_extension.vmex:发生 1 个错误:
azurerm_virtual_machine_extension.vmex:长时间运行的操作终止,状态为“失败”:代码 =“VMExtensionProvisioningError”消息 =“VM 在处理扩展“myVM”时报告失败。错误消息:\“已完成执行命令\”。”
Terraform 不会在出现错误时自动回滚。相反,您的 Terraform 状态文件已使用成功完成的所有资源进行了部分更新。请解决上述错误并再次应用以逐步更改您的基础架构。
当我通过 RDP 进入虚拟机时,我可以看到该文件已正确下载到预期的位置,但是,该文件似乎commandToExecute从未执行过。
如果我直接从下载文件夹运行脚本,它就会成功完成。
任何人都可以提供有关如何解决此问题的任何建议吗?
注意:我尝试了尝试引用该文件的各种组合,但所有这些组合似乎都有相同的结果。
更新:按照评论中的建议检查日志后,尝试运行此代码片段时出现的错误是:
"message": "处理 -File ''test.ps1'' 失败,因为该文件没有 '.ps1' 扩展名。请指定有效的 Windows …
我正在 Azure 中的 bash cloud shell 中使用 Terraform。我正在尝试将外部数据源添加到我的 Terraform 配置文件中,该文件将用于az cli查询virtualip模板部署的 Microsoft.Web/hostingEnvironment 上的对象。
AZ CLI 命令行:
az resource show --ids /subscriptions/<subscription Id>/resourceGroups/my-ilbase-rg/providers/Microsoft.Web/hos
tingEnvironments/my-ilbase/capacities/virtualip
从命令行运行时的输出:
{
"additionalProperties": {
"internalIpAddress": "10.10.1.11",
"outboundIpAddresses": [
"52.224.70.119"
],
"serviceIpAddress": "52.224.70.119",
"vipMappings": []
},
"id": null,
"identity": null,
"kind": null,
"location": null,
"managedBy": null,
"name": null,
"plan": null,
"properties": null,
"sku": null,
"tags": null,
"type": null
}
Run Code Online (Sandbox Code Playgroud)
在我的 Terraform 配置中,我为--ids值创建一个变量:
variable ilbase_resourceId {
default = "/subscriptions/<subscription Id>/resourceGroups/my-ilbase-rg/providers/Microsoft.Web/hostingEnvironments/my-ilbase/capacities/virtualip"
}
Run Code Online (Sandbox Code Playgroud)
然后我以这种方式构建数据源:
data …Run Code Online (Sandbox Code Playgroud) 我一直在尝试使用相同的Terraform堆栈在多个Azure订阅中部署资源。还需要在不同订阅中的这些资源之间传递参数。我曾尝试使用多个提供程序,但不支持。
Error: provider.azurerm: multiple configurations present; only one configuration is allowed per provider
Run Code Online (Sandbox Code Playgroud)
如果您有关于完成此操作的方法或想法,请告诉我。
我正在尝试使用 Terraform 脚本在 Azure 中创建 Service Fabric 群集。Terraform 中的Azure 服务提供商发布了“Service Fabric Cluster”(azurerm_service_fabric_cluster)资源。该资源仅创建服务结构管理部分,即不创建 vm 规模集或网络资源。
如何通过 Terraform 创建工作的 SF 集群?
我在我的.tfvars变量中定义了变量
variables.tfvars
address_space = ["10.197.0.0/16"]
Run Code Online (Sandbox Code Playgroud)
build-windows.tf
variable "address_space" {
type = list
}
Run Code Online (Sandbox Code Playgroud)
在build-windows.tf文件中,我收到作为未知令牌标识列表的错误?
不知道我在这里做错了什么,我什至不明白为什么terraform希望我使用列表而不是字符串。当我使用字符串时,在Terraform计划中出现错误,指出必须使用列表。
不去任何地方。
请协助
您之前是否遇到过主题行中提到的错误?,我对此很感兴趣,但无法解决。以下是我为创建服务主体而执行的步骤
az login
-- Gives me a device code to enter in browser
Login to az non-interactively
az account set --subscription="xxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
Check correct account by
az account show
Create a SP
az ad sp create-for-rbac -n "tf-authenticator" --role contributor
Run Code Online (Sandbox Code Playgroud)
运行 terraform 计划,如下所示:
[jim@rhel75 msdn]$ terraform plan
Refreshing Terraform state in-memory prior to plan...
The refreshed state will be used to calculate this plan, but will not be
persisted to local or remote state storage.
azurerm_resource_group.tf-rg-cluster-sql: Refreshing state... os_profile_windows_config.1060902566.enable_automatic_upgrades: "true"
Plan: …Run Code Online (Sandbox Code Playgroud) azure-devops terraform-provider-azure azure-pipelines-release-task
resource "azurerm_monitor_autoscale_setting" "test" {
name = "AutoscaleSetting"
resource_group_name = "${azurerm_resource_group.main.name}"
location = "${azurerm_resource_group.main.location}"
target_resource_id = "${azurerm_app_service_plan.main.id}"
profile {
name = "defaultProfile"
capacity {
default = 1
minimum = 1
maximum = 10
}
rule {
metric_trigger {
metric_name = "Percentage CPU"
metric_resource_id = "${azurerm_app_service_plan.main.id}"
time_grain = "PT1M"
statistic = "Average"
time_window = "PT5M"
time_aggregation = "Average"
operator = "GreaterThan"
threshold = 80
}
scale_action {
direction = "Increase"
type = "ChangeCount"
value = "1"
cooldown = "PT1M"
}
}
rule …Run Code Online (Sandbox Code Playgroud) azure app-service-environment azure-app-service-plans azure-web-app-service terraform-provider-azure
##[error]TypeError: Cannot read property 'match' of null
在 Azure Devops 中将 terraform 提供程序作为管道的一部分运行时,我一直收到错误
消息。奇怪的是,此问题仅发生在我的应用步骤中。还运行提供程序的上一步返回
terraform.exe providers
.
??? provider.azurerm ~> 1.33.0
??? module.acr
? ??? provider.azurerm ~> 1.33.0
??? module.aks
? ??? provider.azurerm ~> 1.33.0
??? module.rg
? ??? provider.azurerm ~> 1.33.0
??? module.sa
? ??? provider.azurerm ~> 1.33.0
??? module.spn
??? provider.azuread
??? provider.azurerm ~> 1.33.0
??? provider.random
Run Code Online (Sandbox Code Playgroud)
这似乎是 Terraform 步骤中引用的路径的问题。将其更改为有效路径已解决该问题。
terraform azure-devops azure-pipelines terraform-provider-azure
从昨晚开始,我在使用 Terraform 将 Web 应用程序部署到 azure 时遇到错误:
Error creating/updating App Service Plan "test-euw-asp" (Resource Group "test-middle-euw-rg"): web.AppServicePlansClient#CreateOrUpdate: Failure sending request: StatusCode=400 -- Original Error: Code="LinkedInvalidPropertyId" Message="Property id '' at path 'properties.hostingEnvironmentProfile.id' is invalid. Expect fully qualified resource Id that start with '/subscriptions/{subscriptionId}' or '/providers/{resourceProviderNamespace}/'."
Run Code Online (Sandbox Code Playgroud)
看起来它正在“hostingEnvironmentProfile”对象中发送一个空的“id”。
2020-02-25T15:31:56.0433755Z 2020-02-25T15:31:56.041Z [DEBUG] plugin.terraform-provider-azurerm_v1.44.0_x4.exe: {"kind":"Windows","location":"westeurope","properties":{"hostingEnvironmentProfile":{"id":""},"perSiteScaling":false,"maximumElasticWorkerCount":1,"reserved":false,"isXenon":false},"sku":{"name":"S1","tier":"standard","size":"S1","capacity":1},"tags":{}}
Run Code Online (Sandbox Code Playgroud)
我确实将提供程序版本设置为 1.44.0
provider "azurerm" {
version = "~>1.44.0"
}
Run Code Online (Sandbox Code Playgroud)
我的地形配置
resource "azurerm_resource_group" "rg" {
name = var.ResourceGroupNameApp
location = "West europe"
}
resource "azurerm_app_service_plan" "asp" {
name = var.asp-name
resource_group_name …Run Code Online (Sandbox Code Playgroud) terraform ×8
azure ×4
azure-devops ×2
azure-pipelines-release-task ×1
azure-rm ×1
subscription ×1