Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

serverFarm in IDs is accepted as lowercase 'serverfarm' only #11250

Closed
jwefers opened this issue Apr 8, 2021 · 14 comments
Closed

serverFarm in IDs is accepted as lowercase 'serverfarm' only #11250

jwefers opened this issue Apr 8, 2021 · 14 comments

Comments

@jwefers
Copy link

jwefers commented Apr 8, 2021

I have a terraform config that deploys service-specific resources on top of shared infra defined elsewhere. I want to deploy a functions app and for this, i pass the App service plan ID as variable into terraform:

variable "app_service_plan_id" {
  description = "Azure Resource id of the Azure App service plan for the function app to run on"
  type        = string
}

and i pass in my var file

app_service_plan_id = "/subscriptions/<guid>/resourceGroups/<rg>/providers/Microsoft.Web/serverFarms/<appServicePlanName>"

Terraform plan works, but apply complains:

Error: [ERROR] Unable to parse App Service Plan ID "/subscriptions/<guid>/resourceGroups/<rg>/providers/Microsoft.Web/serverFarms/<appServicePlanName>": ID was missing the `serverfarms` element

passing it as lowercase serverfarms works, but that is not the actual casing of the Azure Resource ID anymore.

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or "me too" comments, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Terraform (and AzureRM Provider) Version

Terraform v0.14.9

  • provider registry.terraform.io/hashicorp/azurerm v2.54.0

Affected Resource(s)

azurerm_function_app

@akamalov
Copy link

akamalov commented May 4, 2021

I can concur that I have exactly the same problem:

Terraform 14.10
azurerm v2.56.0

@akamalov
Copy link

akamalov commented May 9, 2021

Wondering if there is any solution or workaround to this possible problem? I need to move in production but this is holding us up.

@jwefers
Copy link
Author

jwefers commented May 9, 2021

as i wrote, just write "serverfarms". Referencing a plan in rhe same tf config by .id works fine or?

@akamalov
Copy link

Tried both ways:

  • serverfarms
  • serverFarms

In both cases I am getting an error (as shown below for each attempt).

Environment:

Terraform v0.14.10
AzureRM 2.56.0

##########################################################################
With 'serverfarms'
##########################################################################

 ----
module.azurerm_ase_appservice_plan.azurerm_app_service_plan.app_service_plan[0]: Creating...
module.azurerm_ase_appservice.azurerm_storage_account.storage[0]: Creating...
module.azurerm_ase_appservice.azurerm_app_service.app_service_containers[0]: Creating...

Error: rpc error: code = Unavailable desc = transport is closing

Error: rpc error: code = Unavailable desc = transport is closing

Error: rpc error: code = Unavailable desc = transport is closing

panic: runtime error: invalid memory address or nil pointer dereference
2021-05-10T14:16:25.353-0400 [DEBUG] plugin.terraform-provider-azurerm_v2.56.0_x5: [signal SIGSEGV: segmentation violation code=0x1 addr=0x20 pc=0x59e4bef]
2021-05-10T14:16:25.353-0400 [DEBUG] plugin.terraform-provider-azurerm_v2.56.0_x5:
2021-05-10T14:16:25.353-0400 [DEBUG] plugin.terraform-provider-azurerm_v2.56.0_x5: goroutine 167 [running]:
2021-05-10T14:16:25.353-0400 [DEBUG] plugin.terraform-provider-azurerm_v2.56.0_x5: github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/web.resourceAppServiceCreate(0xc00022d810, 0x5d98420, 0xc0003e2900, 0x0, 0x0)
2021-05-10T14:16:25.353-0400 [DEBUG] plugin.terraform-provider-azurerm_v2.56.0_x5:  /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/web/app_service_resource.go:243 +0x5ef
2021-05-10T14:16:25.353-0400 [DEBUG] plugin.terraform-provider-azurerm_v2.56.0_x5: github.com/hashicorp/terraform-plugin-sdk/helper/schema.(*Resource).Apply(0xc00029b320, 0xc0000b9c20, 0xc00181bfe0, 0x5d98420, 0xc0003e2900, 0x5dc5c01, 0xc00195c8b8, 0xc00183aed0)
2021-05-10T14:16:25.353-0400 [DEBUG] plugin.terraform-provider-azurerm_v2.56.0_x5:  /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-azurerm/vendor/github.com/hashicorp/terraform-plugin-sdk/helper/schema/resource.go:310 +0x375
2021-05-10T14:16:25.353-0400 [DEBUG] plugin.terraform-provider-azurerm_v2.56.0_x5: github.com/hashicorp/terraform-plugin-sdk/helper/schema.(*Provider).Apply(0xc00019ce80, 0xc0015d9a38, 0xc0000b9c20, 0xc00181bfe0, 0xc00195c7a0, 0xc0015e5330, 0x5dc83c0)
2021-05-10T14:16:25.354-0400 [DEBUG] plugin.terraform-provider-azurerm_v2.56.0_x5:  /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-azurerm/vendor/github.com/hashicorp/terraform-plugin-sdk/helper/schema/provider.go:294 +0x99
2021-05-10T14:16:25.354-0400 [DEBUG] plugin.terraform-provider-azurerm_v2.56.0_x5: github.com/hashicorp/terraform-plugin-sdk/internal/helper/plugin.(*GRPCProviderServer).ApplyResourceChange(0xc000131c98, 0x6c2ae50, 0xc0015cc480, 0xc00022d180, 0xc000131c98, 0xc0015cc480, 0xc001406ba0)
2021-05-10T14:16:25.354-0400 [DEBUG] plugin.terraform-provider-azurerm_v2.56.0_x5:  /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-azurerm/vendor/github.com/hashicorp/terraform-plugin-sdk/internal/helper/plugin/grpc_provider.go:885 +0x8a5
2021-05-10T14:16:25.354-0400 [DEBUG] plugin.terraform-provider-azurerm_v2.56.0_x5: github.com/hashicorp/terraform-plugin-sdk/internal/tfplugin5._Provider_ApplyResourceChange_Handler(0x6270400, 0xc000131c98, 0x6c2ae50, 0xc0015cc480, 0xc001949200, 0x0, 0x6c2ae50, 0xc0015cc480, 0xc001c29900, 0xc16)
2021-05-10T14:16:25.354-0400 [DEBUG] plugin.terraform-provider-azurerm_v2.56.0_x5:  /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-azurerm/vendor/github.com/hashicorp/terraform-plugin-sdk/internal/tfplugin5/tfplugin5.pb.go:3305 +0x214
2021-05-10T14:16:25.354-0400 [DEBUG] plugin.terraform-provider-azurerm_v2.56.0_x5: google.golang.org/grpc.(*Server).processUnaryRPC(0xc000238fc0, 0x6c6e138, 0xc000313200, 0xc00194a400, 0xc001248990, 0x9eb4880, 0x0, 0x0, 0x0)
2021-05-10T14:16:25.354-0400 [DEBUG] plugin.terraform-provider-azurerm_v2.56.0_x5:  /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-azurerm/vendor/google.golang.org/grpc/server.go:1180 +0x52b
2021-05-10T14:16:25.354-0400 [DEBUG] plugin.terraform-provider-azurerm_v2.56.0_x5: google.golang.org/grpc.(*Server).handleStream(0xc000238fc0, 0x6c6e138, 0xc000313200, 0xc00194a400, 0x0)
2021-05-10T14:16:25.354-0400 [DEBUG] plugin.terraform-provider-azurerm_v2.56.0_x5:  /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-azurerm/vendor/google.golang.org/grpc/server.go:1503 +0xd0c
2021-05-10T14:16:25.354-0400 [DEBUG] plugin.terraform-provider-azurerm_v2.56.0_x5: google.golang.org/grpc.(*Server).serveStreams.func1.2(0xc0011ea970, 0xc000238fc0, 0x6c6e138, 0xc000313200, 0xc00194a400)
2021-05-10T14:16:25.354-0400 [DEBUG] plugin.terraform-provider-azurerm_v2.56.0_x5:  /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-azurerm/vendor/google.golang.org/grpc/server.go:843 +0xab
2021-05-10T14:16:25.354-0400 [DEBUG] plugin.terraform-provider-azurerm_v2.56.0_x5: created by google.golang.org/grpc.(*Server).serveStreams.func1
2021-05-10T14:16:25.354-0400 [DEBUG] plugin.terraform-provider-azurerm_v2.56.0_x5:  /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-azurerm/vendor/google.golang.org/grpc/server.go:841 +0x1fd
2021-05-10T14:16:25.358-0400 [WARN]  plugin.stdio: received EOF, stopping recv loop: err="rpc error: code = Unavailable desc = transport is closing"
2021/05/10 14:16:25 [DEBUG] module.azurerm_ase_appservice.azurerm_app_service.app_service_containers[0]: apply errored, but we're indicating that via the Error pointer rather than returning it: rpc error: code = Unavailable desc = transport is closing
2021/05/10 14:16:25 [DEBUG] module.azurerm_ase_appservice_plan.azurerm_app_service_plan.app_service_plan[0]: apply errored, but we're indicating that via the Error pointer rather than returning it: rpc error: code = Unavailable desc = transport is closing
2021/05/10 14:16:25 [TRACE] EvalMaybeTainted: module.azurerm_ase_appservice.azurerm_app_service.app_service_containers[0] encountered an error during creation, so it is now marked as tainted
2021/05/10 14:16:25 [TRACE] EvalMaybeTainted: module.azurerm_ase_appservice_plan.azurerm_app_service_plan.app_service_plan[0] encountered an error during creation, so it is now marked as tainted
2021/05/10 14:16:25 [TRACE] EvalWriteState: removing state object for module.azurerm_ase_appservice.azurerm_app_service.app_service_containers[0]
2021/05/10 14:16:25 [TRACE] EvalWriteState: removing state object for module.azurerm_ase_appservice_plan.azurerm_app_service_plan.app_service_plan[0]
2021/05/10 14:16:25 [TRACE] EvalApplyProvisioners: azurerm_app_service.app_service_containers[0] has no state, so skipping provisioners
2021/05/10 14:16:25 [TRACE] EvalMaybeTainted: module.azurerm_ase_appservice.azurerm_app_service.app_service_containers[0] encountered an error during creation, so it is now marked as tainted
2021/05/10 14:16:25 [TRACE] EvalWriteState: removing state object for module.azurerm_ase_appservice.azurerm_app_service.app_service_containers[0]
2021/05/10 14:16:25 [TRACE] EvalApplyProvisioners: azurerm_app_service_plan.app_service_plan[0] has no state, so skipping provisioners
2021/05/10 14:16:25 [TRACE] EvalMaybeTainted: module.azurerm_ase_appservice_plan.azurerm_app_service_plan.app_service_plan[0] encountered an error during creation, so it is now marked as tainted
2021/05/10 14:16:25 [TRACE] vertex "module.azurerm_ase_appservice.azurerm_app_service.app_service_containers[0]": visit complete
2021/05/10 14:16:25 [DEBUG] module.azurerm_ase_appservice.azurerm_storage_account.storage[0]: apply errored, but we're indicating that via the Error pointer rather than returning it: rpc error: code = Unavailable desc = transport is closing
2021/05/10 14:16:25 [TRACE] EvalWriteState: removing state object for module.azurerm_ase_appservice_plan.azurerm_app_service_plan.app_service_plan[0]
2021/05/10 14:16:25 [TRACE] EvalMaybeTainted: module.azurerm_ase_appservice.azurerm_storage_account.storage[0] encountered an error during creation, so it is now marked as tainted
2021/05/10 14:16:25 [TRACE] EvalWriteState: removing state object for module.azurerm_ase_appservice.azurerm_storage_account.storage[0]
2021/05/10 14:16:25 [TRACE] EvalApplyProvisioners: azurerm_storage_account.storage[0] has no state, so skipping provisioners
2021/05/10 14:16:25 [TRACE] EvalMaybeTainted: module.azurerm_ase_appservice.azurerm_storage_account.storage[0] encountered an error during creation, so it is now marked as tainted
2021/05/10 14:16:25 [TRACE] vertex "module.azurerm_ase_appservice_plan.azurerm_app_service_plan.app_service_plan[0]": visit complete
2021/05/10 14:16:25 [TRACE] EvalWriteState: removing state object for module.azurerm_ase_appservice.azurerm_storage_account.storage[0]
2021/05/10 14:16:25 [TRACE] vertex "module.azurerm_ase_appservice.azurerm_storage_account.storage[0]": visit complete
2021/05/10 14:16:25 [TRACE] dag/walk: upstream of "module.azurerm_ase_appservice_plan (close)" errored, so skipping
2021/05/10 14:16:25 [TRACE] dag/walk: upstream of "module.azurerm_ase_appservice.azurerm_function_app.function_app[0]" errored, so skipping
2021/05/10 14:16:25 [TRACE] dag/walk: upstream of "module.azurerm_ase_appservice.azurerm_app_service.app_service[0]" errored, so skipping
2021/05/10 14:16:25 [TRACE] dag/walk: upstream of "provider[\"registry.terraform.io/hashicorp/azurerm\"] (close)" errored, so skipping
2021/05/10 14:16:25 [TRACE] dag/walk: upstream of "module.azurerm_ase_appservice (close)" errored, so skipping
2021/05/10 14:16:25 [TRACE] dag/walk: upstream of "meta.count-boundary (EachMode fixup)" errored, so skipping
2021/05/10 14:16:25 [TRACE] dag/walk: upstream of "root" errored, so skipping
2021-05-10T14:16:25.358-0400 [DEBUG] plugin: plugin process exited: path=.terraform/providers/registry.terraform.io/hashicorp/azurerm/2.56.0/darwin_amd64/terraform-provider-azurerm_v2.56.0_x5 pid=48011 error="exit status 2"
2021/05/10 14:16:25 [TRACE] statemgr.Filesystem: creating backup snapshot at terraform.tfstate.backup
2021/05/10 14:16:25 [TRACE] statemgr.Filesystem: state has changed since last snapshot, so incrementing serial to 136
2021/05/10 14:16:25 [TRACE] statemgr.Filesystem: writing snapshot at terraform.tfstate
2021/05/10 14:16:25 [TRACE] statemgr.Filesystem: removing lock metadata file .terraform.tfstate.lock.info
2021/05/10 14:16:25 [TRACE] statemgr.Filesystem: unlocking terraform.tfstate using fcntl flock
2021-05-10T14:16:25.388-0400 [DEBUG] plugin: plugin exited


!!!!!!!!!!!!!!!!!!!!!!!!!!! TERRAFORM CRASH !!!!!!!!!!!!!!!!!!!!!!!!!!!!

Terraform crashed! This is always indicative of a bug within Terraform.
A crash log has been placed at "crash.log" relative to your current
working directory. It would be immensely helpful if you could please
report the crash with Terraform[1] so that we can fix this.

When reporting bugs, please include your terraform version. That
information is available on the first line of crash.log. You can also
get it by running 'terraform --version' on the command line.

SECURITY WARNING: the "crash.log" file that was created may contain
sensitive information that must be redacted before it is safe to share
on the issue tracker.

[1]: https://github.com/hashicorp/terraform/issues

!!!!!!!!!!!!!!!!!!!!!!!!!!! TERRAFORM CRASH !!!!!!!!!!!!!!!!!!!!!!!!!!!!

From the crash.log file:

2021-05-10T14:16:25.230-0400 [DEBUG] plugin.terraform-provider-azurerm_v2.56.0_x5: 
2021-05-10T14:16:25.230-0400 [DEBUG] plugin.terraform-provider-azurerm_v2.56.0_x5: {"error":{"code":"ResourceNotFound","message":"The Resource 'Microsoft.Web/serverFarms/testak001_appservice_plan' under resource group 'testak-001' was not found. For more details please go to https://aka.ms/ARMResourceNotFoundFix"}}
2021-05-10T14:16:25.230-0400 [DEBUG] plugin.terraform-provider-azurerm_v2.56.0_x5: [DEBUG] AzureRM Request: 
2021-05-10T14:16:25.230-0400 [DEBUG] plugin.terraform-provider-azurerm_v2.56.0_x5: PUT /subscriptions/XXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXX/resourceGroups/testak-001/providers/Microsoft.Web/serverfarms/testak001_appservice_plan?api-version=2020-06-01 HTTP/1.1
2021-05-10T14:16:25.230-0400 [DEBUG] plugin.terraform-provider-azurerm_v2.56.0_x5: Host: management.azure.com
2021-05-10T14:16:25.230-0400 [DEBUG] plugin.terraform-provider-azurerm_v2.56.0_x5: User-Agent: Go/go1.16 (amd64-darwin) go-autorest/v14.2.1 Azure-SDK-For-Go/v52.6.0 web/2020-06-01 HashiCorp Terraform/0.14.10 (+https://www.terraform.io) Terraform Plugin SDK/1.16.0 terraform-provider-azurerm/dev pid-222c6c49-1b0a-5959-a213-6608f9eb8820
2021-05-10T14:16:25.230-0400 [DEBUG] plugin.terraform-provider-azurerm_v2.56.0_x5: Content-Length: 459
2021-05-10T14:16:25.230-0400 [DEBUG] plugin.terraform-provider-azurerm_v2.56.0_x5: Content-Type: application/json; charset=utf-8
2021-05-10T14:16:25.230-0400 [DEBUG] plugin.terraform-provider-azurerm_v2.56.0_x5: X-Ms-Correlation-Request-Id: 58eb142d-7e88-f918-8c0f-3db16c04d426
2021-05-10T14:16:25.230-0400 [DEBUG] plugin.terraform-provider-azurerm_v2.56.0_x5: Accept-Encoding: gzip
2021-05-10T14:16:25.230-0400 [DEBUG] plugin.terraform-provider-azurerm_v2.56.0_x5: 
2021-05-10T14:16:25.230-0400 [DEBUG] plugin.terraform-provider-azurerm_v2.56.0_x5: {"kind":"linux","location":"southcentralus","properties":{"isXenon":false,"reserved":true},"sku":{"name":"S1","tier":"Standard","size":"S1","capacity":1},"tags":{"applicationname":"SecEngASEApp","costcenter":"","deploymenttype":"managed-tfe","environment":"nonprod","environmentifo":"N:CloudSecurity;T:Dev","notificationdistlist":"","owner":"","owneremail":"[email protected]","ownerteam":"T:CloudSec","platform":"CloudSec","srcr":"","trproductid":""}}
2021-05-10T14:16:25.351-0400 [DEBUG] plugin.terraform-provider-azurerm_v2.56.0_x5: [DEBUG] AzureRM Response for https://management.azure.com/subscriptions/XXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXX/resourceGroups/testak-001/providers/Microsoft.Web/serverfarms/testak001_appservice_plan?api-version=2020-06-01: 
2021-05-10T14:16:25.351-0400 [DEBUG] plugin.terraform-provider-azurerm_v2.56.0_x5: HTTP/2.0 404 Not Found
2021-05-10T14:16:25.351-0400 [DEBUG] plugin.terraform-provider-azurerm_v2.56.0_x5: Content-Length: 233
2021-05-10T14:16:25.351-0400 [DEBUG] plugin.terraform-provider-azurerm_v2.56.0_x5: Cache-Control: no-cache
2021-05-10T14:16:25.351-0400 [DEBUG] plugin.terraform-provider-azurerm_v2.56.0_x5: Content-Type: application/json; charset=utf-8
2021-05-10T14:16:25.351-0400 [DEBUG] plugin.terraform-provider-azurerm_v2.56.0_x5: Date: Mon, 10 May 2021 18:16:21 GMT
2021-05-10T14:16:25.351-0400 [DEBUG] plugin.terraform-provider-azurerm_v2.56.0_x5: Expires: -1
2021-05-10T14:16:25.351-0400 [DEBUG] plugin.terraform-provider-azurerm_v2.56.0_x5: Pragma: no-cache
2021-05-10T14:16:25.351-0400 [DEBUG] plugin.terraform-provider-azurerm_v2.56.0_x5: Strict-Transport-Security: max-age=31536000; includeSubDomains
2021-05-10T14:16:25.351-0400 [DEBUG] plugin.terraform-provider-azurerm_v2.56.0_x5: X-Content-Type-Options: nosniff
2021-05-10T14:16:25.351-0400 [DEBUG] plugin.terraform-provider-azurerm_v2.56.0_x5: X-Ms-Correlation-Request-Id: 58eb142d-7e88-f918-8c0f-3db16c04d426
2021-05-10T14:16:25.351-0400 [DEBUG] plugin.terraform-provider-azurerm_v2.56.0_x5: X-Ms-Failure-Cause: gateway
2021-05-10T14:16:25.351-0400 [DEBUG] plugin.terraform-provider-azurerm_v2.56.0_x5: X-Ms-Request-Id: 7cef0853-2bc2-4c9e-9378-b423c7630290
2021-05-10T14:16:25.351-0400 [DEBUG] plugin.terraform-provider-azurerm_v2.56.0_x5: X-Ms-Routing-Request-Id: CENTRALUS:20210510T181621Z:7cef0853-2bc2-4c9e-9378-b423c7630290
2021-05-10T14:16:25.351-0400 [DEBUG] plugin.terraform-provider-azurerm_v2.56.0_x5: 
2021-05-10T14:16:25.351-0400 [DEBUG] plugin.terraform-provider-azurerm_v2.56.0_x5: {"error":{"code":"ResourceNotFound","message":"The Resource 'Microsoft.Web/serverFarms/testak001_appservice_plan' under resource group 'testak-001' was not found. For more details please go to https://aka.ms/ARMResourceNotFoundFix"}}
2021-05-10T14:16:25.353-0400 [DEBUG] plugin.terraform-provider-azurerm_v2.56.0_x5: panic: runtime error: invalid memory address or nil pointer dereference
2021-05-10T14:16:25.353-0400 [DEBUG] plugin.terraform-provider-azurerm_v2.56.0_x5: [signal SIGSEGV: segmentation violation code=0x1 addr=0x20 pc=0x59e4bef]
2021-05-10T14:16:25.353-0400 [DEBUG] plugin.terraform-provider-azurerm_v2.56.0_x5: 

...

##########################################################################
With 'serverFarms'
##########################################################################

module.azurerm_ase_appservice_plan.azurerm_app_service_plan.app_service_plan[0]: Creating...
module.azurerm_ase_appservice.azurerm_app_service.app_service_containers[0]: Creating...
module.azurerm_ase_appservice.azurerm_storage_account.storage[0]: Creating...
module.azurerm_ase_appservice_plan.azurerm_app_service_plan.app_service_plan[0]: Creation complete after 10s [id=/subscriptions/XXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXX/resourceGroups/testak-001/providers/Microsoft.Web/serverfarms/testak001_appservice_plan]
module.azurerm_ase_appservice.azurerm_storage_account.storage[0]: Still creating... [10s elapsed]
module.azurerm_ase_appservice.azurerm_storage_account.storage[0]: Still creating... [20s elapsed]
module.azurerm_ase_appservice.azurerm_storage_account.storage[0]: Creation complete after 23s [id=/subscriptions/XXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXX/resourceGroups/testak-001/providers/Microsoft.Storage/storageAccounts/testakstorage001]
module.azurerm_ase_appservice.azurerm_function_app.function_app[0]: Creating...
module.azurerm_ase_appservice.azurerm_app_service.app_service[0]: Creating...
module.azurerm_ase_appservice.azurerm_function_app.function_app[0]: Still creating... [10s elapsed]
module.azurerm_ase_appservice.azurerm_function_app.function_app[0]: Still creating... [20s elapsed]
module.azurerm_ase_appservice.azurerm_function_app.function_app[0]: Still creating... [30s elapsed]
module.azurerm_ase_appservice.azurerm_function_app.function_app[0]: Creation complete after 31s [id=/subscriptions/XXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXX/resourceGroups/testak-001/providers/Microsoft.Web/sites/testak001-appservice]

Error: ID was missing the `serverfarms` element

  on modules/azurerm_ase_appservice/main.tf line 5, in resource "azurerm_app_service" "app_service":
   5: resource "azurerm_app_service" "app_service" {


Error: ID was missing the `serverfarms` element

  on modules/azurerm_ase_appservice/main.tf line 35, in resource "azurerm_app_service" "app_service_containers":
  35: resource "azurerm_app_service" "app_service_containers" {

App Service Plan TF manifest:

File: azurerm-ase/modules/azurerm_ase_appservice_plan/main.tf

################################################
#     Deploy App Service Plan                  #
################################################

resource "azurerm_app_service_plan" "app_service_plan" {
  count = var.ASP ? 1 : 0
  name                = var.app-service-plan-name
  location            = var.location
  resource_group_name = var.resource-group-name
  kind                = var.kind
  reserved            = var.reserved
  #app_service_environment_id = var.int-ase-id
  sku {
    tier = var.asp-tier
    size = var.asp-size
    capacity = var.asp-capacity
  }

  timeouts {
    create = "2h"
  }

  tags = var.tags
#  depends_on = [azurerm_resource_group.resource_group]
}

App Service TF manifest:

File: azurerm-ase/modules/azurerm_ase_appservice/main.tf

################################################
#     Deploy App Service                       #
################################################

resource "azurerm_app_service" "app_service" {
  count = var.webapp ? 1 : 0
  name                = var.app-name
  location            = var.location
  resource_group_name = var.resource-group-name
  https_only          = var.https_only
  #app_service_plan_id = "/subscriptions/${var.subscription_id}/resourceGroups/${var.resource-group-name}/providers/Microsoft.Web/serverFarms/${var.app-service-plan-name}"
  app_service_plan_id = "/subscriptions/${var.subscription_id}/resourceGroups/${var.resource-group-name}/providers/Microsoft.Web/serverfarms/${var.app-service-plan-name}"

  site_config {
    scm_type = "None"
    http2_enabled    =  var.http2_enabled
    dotnet_framework_version = var.dotnet_framework_version
    linux_fx_version = var.kind == "linux" ? var.linux_fx_version : ""

  }
  depends_on = [azurerm_storage_account.storage]
}


################################################
#     Deploy App Service - Containers                    #
################################################

resource "azurerm_app_service" "app_service_containers" {
  count = var.webappC ? 1 : 0
  name                = var.app-name
  location            = var.location
  resource_group_name = var.resource-group-name
  https_only          = var.https_only
  #app_service_plan_id = "/subscriptions/${var.subscription_id}/resourceGroups/${var.resource-group-name}/providers/Microsoft.Web/serverFarms/${var.app-service-plan-name}"
  app_service_plan_id = "/subscriptions/${var.subscription_id}/resourceGroups/${var.resource-group-name}/providers/Microsoft.Web/serverfarms/${var.app-service-plan-name}"

  site_config {
    http2_enabled    =  var.http2_enabled
    linux_fx_version = "DOCKER|${var.docker_image}"
  }

  app_settings = {
       WEBSITES_ENABLE_APP_SERVICE_STORAGE = false
       DOCKER_REGISTRY_SERVER_URL = "https://docker.XXXX.XXXXXXX.com/"
       DOCKER_REGISTRY_SERVER_USERNAME = "XXXXXXX"
       DOCKER_REGISTRY_SERVER_PASSWORD = "XXXXXXX"
      }
}

################################################
#     Deploy Storage Account                   #
################################################

resource "azurerm_storage_account" "storage" {
  count = var.function ? 1 : 0
  name                      = var.storage-name
  resource_group_name       = var.resource-group-name
  location                  = var.location
  account_tier              = "Standard"
  account_replication_type  = "LRS"
}

################################################
#     Deploy Function App                      #
################################################

resource "azurerm_function_app" "function_app" {
  count = var.function ? 1 : 0
  name                      = var.app-name
  location                  = var.location
  resource_group_name       = var.resource-group-name
  https_only                = var.https_only
  app_service_plan_id = "/subscriptions/${var.subscription_id}/resourceGroups/${var.resource-group-name}/providers/Microsoft.Web/serverfarms/${var.app-service-plan-name}"
  storage_account_name       = azurerm_storage_account.storage[0].name
  storage_account_access_key = azurerm_storage_account.storage[0].primary_access_key

  app_settings = {
    WEBSITE_RUN_FROM_PACKAGE = 1
  }
  site_config {
    http2_enabled    =  var.http2_enabled
  }
}

@jwefers
Copy link
Author

jwefers commented May 10, 2021

these are rwo different errors. your lowercase attempt causes a hard crash - something is wrong in your config. first, update terraform and azurerm

@akamalov
Copy link

Hey @jwefers ,

I understand these are two different errors. These two diff.errors caused by just changing letter "F" casing in 'serverfarms'.

I have upgraded to the following:

Terraform 0.15.3
AzureRM 2.58.0

The same result:

With 'serverFarms':

app_service_plan_id = "/subscriptions/${var.subscription_id}/resourceGroups/${var.resource-group-name}/providers/Microsoft.Web/serverFarms/${var.app-service-plan-name}"

Output:

module.azurerm_ase_appservice_plan.azurerm_app_service_plan.app_service_plan[0]: Creating...
module.azurerm_ase_appservice.azurerm_app_service.app_service_containers[0]: Creating...
module.azurerm_ase_appservice.azurerm_storage_account.storage[0]: Creating...
module.azurerm_ase_appservice_plan.azurerm_app_service_plan.app_service_plan[0]: Still creating... [10s elapsed]
module.azurerm_ase_appservice.azurerm_storage_account.storage[0]: Still creating... [10s elapsed]
module.azurerm_ase_appservice_plan.azurerm_app_service_plan.app_service_plan[0]: Creation complete after 14s [id=/subscriptions/XXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX/resourceGroups/testak-001/providers/Microsoft.Web/serverfarms/testak001_appservice_plan]
module.azurerm_ase_appservice.azurerm_storage_account.storage[0]: Still creating... [20s elapsed]
module.azurerm_ase_appservice.azurerm_storage_account.storage[0]: Creation complete after 23s [id=/subscriptions/XXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX/resourceGroups/testak-001/providers/Microsoft.Storage/storageAccounts/testakstorage001]
module.azurerm_ase_appservice.azurerm_app_service.app_service[0]: Creating...
module.azurerm_ase_appservice.azurerm_function_app.function_app[0]: Creating...
module.azurerm_ase_appservice.azurerm_function_app.function_app[0]: Still creating... [10s elapsed]
module.azurerm_ase_appservice.azurerm_function_app.function_app[0]: Still creating... [20s elapsed]
module.azurerm_ase_appservice.azurerm_function_app.function_app[0]: Creation complete after 28s [id=/subscriptions/XXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX/resourceGroups/testak-001/providers/Microsoft.Web/sites/testak001-appservice]
╷
│ Error: ID was missing the `serverfarms` element
│
│   with module.azurerm_ase_appservice.azurerm_app_service.app_service[0],
│   on modules/azurerm_ase_appservice/main.tf line 5, in resource "azurerm_app_service" "app_service":
│    5: resource "azurerm_app_service" "app_service" {
│
╵
╷
│ Error: ID was missing the `serverfarms` element
│
│   with module.azurerm_ase_appservice.azurerm_app_service.app_service_containers[0],
│   on modules/azurerm_ase_appservice/main.tf line 35, in resource "azurerm_app_service" "app_service_containers":
│   35: resource "azurerm_app_service" "app_service_containers" {

With 'serverfarms':

  app_service_plan_id = "/subscriptions/${var.subscription_id}/resourceGroups/${var.resource-group-name}/providers/Microsoft.Web/serverfarms/${var.app-service-plan-name}"

Output:

module.azurerm_ase_appservice_plan.azurerm_app_service_plan.app_service_plan[0]: Creating...
module.azurerm_ase_appservice.azurerm_app_service.app_service_containers[0]: Creating...
module.azurerm_ase_appservice.azurerm_storage_account.storage[0]: Creating...
╷
│ Error: Plugin did not respond
│
│   with module.azurerm_ase_appservice.azurerm_app_service.app_service_containers[0],
│   on modules/azurerm_ase_appservice/main.tf line 35, in resource "azurerm_app_service" "app_service_containers":
│   35: resource "azurerm_app_service" "app_service_containers" {
│
│ The plugin encountered an error, and failed to respond to the plugin.(*GRPCProvider).ApplyResourceChange call. The plugin logs may contain more details.
╵
╷
│ Error: Plugin did not respond
│
│   with module.azurerm_ase_appservice.azurerm_storage_account.storage[0],
│   on modules/azurerm_ase_appservice/main.tf line 62, in resource "azurerm_storage_account" "storage":
│   62: resource "azurerm_storage_account" "storage" {
│
│ The plugin encountered an error, and failed to respond to the plugin.(*GRPCProvider).ApplyResourceChange call. The plugin logs may contain more details.
╵
╷
│ Error: Plugin did not respond
│
│   with module.azurerm_ase_appservice_plan.azurerm_app_service_plan.app_service_plan[0],
│   on modules/azurerm_ase_appservice_plan/main.tf line 5, in resource "azurerm_app_service_plan" "app_service_plan":
│    5: resource "azurerm_app_service_plan" "app_service_plan" {
│
│ The plugin encountered an error, and failed to respond to the plugin.(*GRPCProvider).ApplyResourceChange call. The plugin logs may contain more details.
╵

Stack trace from the terraform-provider-azurerm_v2.58.0_x5 plugin:

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x20 pc=0x5b8a6af]

goroutine 92 [running]:
github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/web.resourceAppServiceCreate(0xc001a602a0, 0x5f428a0, 0xc00122a300, 0x0, 0x0)
  /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-azurerm/azurerm/internal/services/web/app_service_resource.go:243 +0x5ef
github.com/hashicorp/terraform-plugin-sdk/helper/schema.(*Resource).Apply(0xc001271720, 0xc00113e690, 0xc001a33ae0, 0x5f428a0, 0xc00122a300, 0x5f6e901, 0xc001a7ba08, 0xc001a55bc0)
  /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-azurerm/vendor/github.com/hashicorp/terraform-plugin-sdk/helper/schema/resource.go:320 +0x375
github.com/hashicorp/terraform-plugin-sdk/helper/schema.(*Provider).Apply(0xc000139780, 0xc001603a38, 0xc00113e690, 0xc001a33ae0, 0xc001b523e8, 0xc0019fab70, 0x5f70f20)
  /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-azurerm/vendor/github.com/hashicorp/terraform-plugin-sdk/helper/schema/provider.go:294 +0x99
github.com/hashicorp/terraform-plugin-sdk/internal/helper/plugin.(*GRPCProviderServer).ApplyResourceChange(0xc000113b20, 0x6df1a30, 0xc0019ce5d0, 0xc0016e1dc0, 0xc000113b20, 0xc0019ce5d0, 0xc001561ba0)
  /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-azurerm/vendor/github.com/hashicorp/terraform-plugin-sdk/internal/helper/plugin/grpc_provider.go:895 +0x8a5
github.com/hashicorp/terraform-plugin-sdk/internal/tfplugin5._Provider_ApplyResourceChange_Handler(0x6415700, 0xc000113b20, 0x6df1a30, 0xc0019ce5d0, 0xc00150ed80, 0x0, 0x6df1a30, 0xc0019ce5d0, 0xc001219900, 0xc16)
  /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-azurerm/vendor/github.com/hashicorp/terraform-plugin-sdk/internal/tfplugin5/tfplugin5.pb.go:3305 +0x214
google.golang.org/grpc.(*Server).processUnaryRPC(0xc00023ce00, 0x6e35e98, 0xc000682600, 0xc001510200, 0xc001281fb0, 0xa164300, 0x0, 0x0, 0x0)
  /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-azurerm/vendor/google.golang.org/grpc/server.go:1194 +0x52b
google.golang.org/grpc.(*Server).handleStream(0xc00023ce00, 0x6e35e98, 0xc000682600, 0xc001510200, 0x0)
  /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-azurerm/vendor/google.golang.org/grpc/server.go:1517 +0xd0c
google.golang.org/grpc.(*Server).serveStreams.func1.2(0xc000d88540, 0xc00023ce00, 0x6e35e98, 0xc000682600, 0xc001510200)
  /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-azurerm/vendor/google.golang.org/grpc/server.go:859 +0xab
created by google.golang.org/grpc.(*Server).serveStreams.func1
  /opt/teamcity-agent/work/5d79fe75d4460a2f/src/github.com/terraform-providers/terraform-provider-azurerm/vendor/google.golang.org/grpc/server.go:857 +0x1fd

Error: The terraform-provider-azurerm_v2.58.0_x5 plugin crashed!

This is always indicative of a bug within the plugin. It would be immensely
helpful if you could report the crash with the plugin's maintainers so that it
can be fixed. The output above should help diagnose the issue.


@jwefers
Copy link
Author

jwefers commented May 20, 2021

using lowercase "serverfams" for incoming variables works perfectly fine for me

@akamalov
Copy link

I don't know. At this point there is a discrepancy between serverFarms and serverfarms. It's not working for me, unfortunately.

@jackofallops
Copy link
Member

Hi folks. From what I can see here we have 2 issues. serverfarms is the correct casing for the App Service Plan ID according to the spec for example. This is the format we used for ID validation (hence the error message for missing segment)
The second is an underlying bug in the upstream SDK for which we've opened an issue here and @koikonom has created a workaround for in #12518

@jwefers
Copy link
Author

jwefers commented Jul 19, 2021

The issue here is that Azure IDs under the hood are case insensitive - if you click around in the portal, in generated ARM templates, blabh blah, you will encounter any casing (here: camelCase), depending on the backend service you are currently hitting.

Question is, what would happen if the azurerm provider becomes similarly case insensitive?

@tombuildsstuff
Copy link
Contributor

@jwefers

Unfortunately the issue's a little more complex, Resource ID's within Azure are supposed to (per the Azure Resource Manager Specification) be Case Insensitive during Requests but Case Sensitive in Responses - but in practice, almost no Azure API implements that behaviour.

It's worth calling out that since Resource ID's within Azure are URI's, which the HTTP Specification defines those as case sensitive - most custom scripts and third-party integrations also treat these as case sensitive.

We've seen enough issues with things (for example an API returning a provisioning state of succeeded which silently fails) over the years due to incorrect casing - that by definition unless every API and every third party integration is case sensitive (which they're not) - by definition they have to be treated as case sensitive.


Within Terraform we're moving from using the Resource ID's returned in the API response to using Azure Resource ID's computed by Terraform to ensure consistency - that is, rather than using the Resource ID from the HTTP Response, pre-computing the Resource ID from what's defined within the Azure API Definitions and building up an ID for Terraform (for example we know an ASE has the segment /serverFarms (or serverfarms, in this case)).

This approach both allows us to have validation confirming that the Resource ID's match what Azure defines (and thus what we expect at import time, so we can raise an error) - and also means that we are no longer subject to changes in these ID's between different API versions (where these segments can change values entirely - as happens fairly often in the Networking API's - or casing on these).

The Documentation for each Terraform Resource has a section on import showing how to import it and the ID that we're expecting that to be in, for example for an App Service Plan:

terraform import azurerm_app_service_plan.instance1 /subscriptions/00000000-0000-0000-0000-000000000000/resourceGroups/mygroup1/providers/Microsoft.Web/serverfarms/instance1

Taking a look into this, it appears that we're using the Resource ID returned by Azure but validating that it matches what we expect, which'd be the problem here; instead we'll need to switch this over to using a Terraform Managed Resource ID as we've done in some other situations.

It's worth noting that @jackofallops is working through the App Service resources at the moment as can be seen in #12132 - so this will be the case for the newer resources - but we are (gradually) working through the existing resources to make these consistent here.

@jwefers
Copy link
Author

jwefers commented Jul 19, 2021

great explanation, thanks

@tombuildsstuff
Copy link
Contributor

Closing this out since the Terraform side of this is now resolved, there's an upstream issue tracking the Azure SDK bug which once fixed will automatically be fixed in Terraform (with the next SDK upgrade).

@github-actions
Copy link

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 26, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

6 participants