Closed slime-uk closed 2 years ago
Hi @slime-uk ,
Thank you for opening this issue! Yes, the type
is case-sensitive, and I highly recommended to install this VSCode extension, which will auto-complete the types and allowed properties.
Here's a full example for this case, please notice the diff on "Microsoft.Cdn/profiles/afdEndpoints/routes@2021-06-01"
:
resource "azurerm_resource_group" "test" {
name = "henglu77cdn"
location = "West Europe"
}
resource "azurerm_cdn_frontdoor_profile" "test" {
name = "henglu77cdn"
resource_group_name = azurerm_resource_group.test.name
sku_name = "Standard_AzureFrontDoor"
}
resource "azurerm_cdn_frontdoor_endpoint" "test" {
name = "henglu77cdn"
cdn_frontdoor_profile_id = azurerm_cdn_frontdoor_profile.test.id
}
resource "azapi_resource" "group" {
type = "Microsoft.Cdn/profiles/originGroups@2021-06-01"
name = "henglu77cdn"
parent_id = azurerm_cdn_frontdoor_profile.test.id
body = jsonencode({
properties = {
loadBalancingSettings = {
additionalLatencyInMilliseconds = 100
sampleSize = 100
successfulSamplesRequired = 100
}
}
})
}
resource "azapi_resource" "origin" {
type = "Microsoft.Cdn/profiles/originGroups/origins@2021-06-01"
name = "henglu77cdn"
parent_id = azapi_resource.group.id
body = jsonencode({
properties = {
hostName = "127.0.0.1"
}
})
}
resource "azapi_resource" "test" {
type = "Microsoft.Cdn/profiles/afdEndpoints/routes@2021-06-01"
name = "henglu77cdn"
parent_id = azurerm_cdn_frontdoor_endpoint.test.id
body = jsonencode({
properties = {
originGroup = {
id = azapi_resource.group.id
}
supportedProtocols = [
"Http",
"Https"
]
patternsToMatch = [
"/*"
]
forwardingProtocol = "MatchRequest"
linkToDefaultDomain = "Enabled"
httpsRedirect = "Disabled"
enabledState = "Enabled"
}
})
depends_on = [
azapi_resource.origin
]
}
Thank you for the reply. I did indeed have the vscode extension installed but clearly it was not working correctly! I find installing extensions under vscode not easy!
Have corrected my code, removed the tainted objects from TFC state and re-run - all looks good now.
To help others - maybe you could (when you have time) do a short "installing the extension into vscode" video under the help for the AzAPI provider?
Thanks!
Hi @slime-uk ,
Glad to see it works! And it's a great idea to provide some videos about the azapi extension, I'll do it. Thanks!
Hi,
Using 0.4.0 version of AzAPI provider, and AzureRM provider 3.12.0, I have created a Azure Front Door premium profile and then an endpoint using standard AzureRM definitions. Due to lack of support, I then went on to use the AzAPI provider for required origingroups and origins and finally a route.
The route seemed to create fine (201 status) but now I get the following error during any TF plan.
I searched here under open and closed issues and noticed it can often be a case that the type is case sensitive but I think I have it correct on the route:
Here's my AzAPI TF definition for the AzFD route:
I also noticed that the route is in the TFC state - but with a status of tainted - see extract...
Any ideas please?
Thanks!