需要通过Terraform创建Azure资源并将其链接到APIM,如应用程序洞察、密钥库和日志分析。我浏览了Terraform文档和其他网站,但没有找到任何示例。以下是我的Terraform脚本,用于初始化资源组下的资源,但不包括APIM和应用程序洞察,登录Azure门户后需要链接密钥保管库和日志分析。我期待创建要链接的资源,避免在Azure门户中手动链接。
terraform {
required_providers {
azurerm = {
source = "hashicorp/azurerm"
version = "~> 3.0.2"
}
}
required_version = ">= 1.1.0"
}
provider "azurerm" {
features {}
}
data "azurerm_client_config" "current" {}
#APIM Resource
resource "azurerm_resource_group" "TerraformPOC-DevResourceGroup" {
name = "TerraformPOC-DevResourceGroup"
location = "WestEurope"
}
resource "azurerm_application_insights" "TerraformPOC-Application-Insights" {
name = "TerraformPOC-Application-Insights"
location = azurerm_resource_group.TerraformPOC-DevResourceGroup.location
resource_group_name = azurerm_resource_group.TerraformPOC-DevResourceGroup.name
application_type = "other"
}
resource "azurerm_api_management" "TerraformPOC-APIManagement" {
name = "TerraformPOC-APIManagement"
location = azurerm_resource_group.TerraformPOC-DevResourceGroup.location
resource_group_name = azurerm_resource_group.TerraformPOC-DevResourceGroup.name
publisher_name = "TestDemo"
publisher_email = "pradeep.mathada@amadeus.com"
sku_name = "Developer_1"
}
resource "azurerm_log_analytics_workspace" "TerraformPOC-Log-Analytics" {
name = "TerraformPOC-Log-Analytics"
location = azurerm_resource_group.TerraformPOC-DevResourceGroup.location
resource_group_name = azurerm_resource_group.TerraformPOC-DevResourceGroup.name
retention_in_days = 30
}
1条答案
按热度按时间hc8w905p1#
我尝试在我的环境中重现该方案:
我使用下面的代码将日志分析工作区链接到azure keyvalt:
并能成功创造
同样,您可以使用以下代码将Azure应用洞察链接到APIM
代码: