Ken*_*y_I 2 terraform azure-logic-apps
我想使用 Terraform 部署 Azure 逻辑应用程序。我需要添加 2-3 个自定义操作。我目前正在测试添加 2 个变量。
我希望所有操作都相继运行,但目前操作是并行部署的。我不知道哪个参数决定操作是否应该并行部署或一个接一个地部署。
我已复制并粘贴以下代码:
https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/logic_app_trigger_http_request
https://registry.terraform.io/providers/hashicorp/azurerm/latest/docs/resources/logic_app_action_custom
Run Code Online (Sandbox Code Playgroud)
如何让动作依次部署?
# Define Terraform provider
terraform {
required_version = ">= 0.12"
}
# Configure the Azure provider
provider "azurerm" {
environment = "public"
version = ">= 2.0.0"
features {}
}
resource "azurerm_resource_group" "example" {
name = "my-logicapp-rg"
location = "West Europe"
}
resource "azurerm_logic_app_workflow" "example" {
name = "workflow1"
location = azurerm_resource_group.example.location
resource_group_name = azurerm_resource_group.example.name
}
resource "azurerm_logic_app_trigger_http_request" "example" {
name = "some-http-trigger"
logic_app_id = azurerm_logic_app_workflow.example.id
schema = <<SCHEMA
{
"type": "object",
"properties": {
"hello": {
"type": "string"
}
}
}
SCHEMA
}
resource "azurerm_logic_app_action_custom" "example" {
name = "example-action"
logic_app_id = azurerm_logic_app_workflow.example.id
body = <<BODY
{
"description": "A variable to configure the auto expiration age in days. Configured in negative number. Default is -30 (30 days old).",
"inputs": {
"variables": [
{
"name": "ExpirationAgeInDays",
"type": "Integer",
"value": -30
}
]
},
"runAfter": {},
"type": "InitializeVariable"
}
BODY
}
resource "azurerm_logic_app_action_custom" "example2" {
name = "example-action2"
logic_app_id = azurerm_logic_app_workflow.example.id
body = <<BODY
{
"description": "A variable to configure the auto expiration age in days. Configured in negative number. Default is -30 (30 days old).",
"inputs": {
"variables": [
{
"name": "ExpirationAgeInDays2",
"type": "Integer",
"value": -30
}
]
},
"runAfter": {},
"type": "InitializeVariable"
}
BODY
}
Run Code Online (Sandbox Code Playgroud)
为了使其成为一个流程而不是并行的动作。您需要在先前变量的“runAfter”:{}中添加变量名称。
"runAfter": {
"${azurerm_logic_app_action_custom.example.name}": [
"Succeeded"
]
}
Run Code Online (Sandbox Code Playgroud)
或者
"runAfter": {
"example-action": [
"Succeeded"
]
}
Run Code Online (Sandbox Code Playgroud)
完成更改后,我使用以下代码在我的环境中进行了测试:
# Define Terraform provider
terraform {
required_version = ">= 0.12"
}
# Configure the Azure provider
provider "azurerm" {
environment = "public"
version = ">= 2.0.0"
features {}
}
resource "azurerm_resource_group" "example" {
name = "my-logicapp-rg"
location = "West Europe"
}
resource "azurerm_logic_app_workflow" "example" {
name = "workflow1"
location = azurerm_resource_group.example.location
resource_group_name = azurerm_resource_group.example.name
}
resource "azurerm_logic_app_trigger_http_request" "example" {
name = "some-http-trigger"
logic_app_id = azurerm_logic_app_workflow.example.id
schema = <
<SCHEMA
{
"type": "object",
"properties": {
"hello": {
"type": "string"
}
}
}
SCHEMA
}
resource "azurerm_logic_app_action_custom" "example" {
name = "example-action"
logic_app_id = azurerm_logic_app_workflow.example.id
body = <
<BODY
{
"description": "A variable to configure the auto expiration age in days. Configured in negative number. Default is -30 (30 days old).",
"inputs": {
"variables": [
{
"name": "ExpirationAgeInDays",
"type": "Integer",
"value": -30
}
]
},
"runAfter": {},
"type": "InitializeVariable"
}
BODY
}
resource "azurerm_logic_app_action_custom" "example2" {
name = "example-action2"
logic_app_id = azurerm_logic_app_workflow.example.id
body = <
<BODY
{
"description": "A variable to configure the auto expiration age in days. Configured in negative number. Default is -30 (30 days old).",
"inputs": {
"variables": [
{
"name": "ExpirationAgeInDays2",
"type": "Integer",
"value": -30
}
]
},
"runAfter": {
"${azurerm_logic_app_action_custom.example.name}": [
"Succeeded"
]
},
"type": "InitializeVariable"
}
BODY
}
Run Code Online (Sandbox Code Playgroud)
输出:

| 归档时间: |
|
| 查看次数: |
1718 次 |
| 最近记录: |