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

azurerm_windows_function_app_slot now requires a globally unique name for the slot itself #16305

Closed
1 task done
bdorplatt opened this issue Apr 8, 2022 · 10 comments · Fixed by #16410
Closed
1 task done
Labels
Milestone

Comments

@bdorplatt
Copy link

bdorplatt commented Apr 8, 2022

Is there an existing issue for this?

  • I have searched the existing issues

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 Version

0.15.4

AzureRM Provider Version

3.0.2

Affected Resource(s)/Data Source(s)

azurerm_windows_function_app_slot

Terraform Configuration Files

resource "azurerm_windows_function_app" "function_app" {
  service_plan_id             = var.asp_id
  location                    = var.region
  name                        = testapp-azf"
  resource_group_name         = var.resource_group_name
  storage_account_access_key  = var.sa_primary_access_key
  storage_account_name        = var.sa_name
  functions_extension_version = var.fa_extensions_version
  builtin_logging_enabled     = var.fa_builtin_logging_enabled

resource "azurerm_windows_function_app_slot" "function_app_slot" {
  name                        = "dev"
  function_app_id             = var.fa_id
  storage_account_access_key  = var.sa_primary_access_key
  storage_account_name        = var.sa_name
  functions_extension_version = var.fa_extensions_version
  builtin_logging_enabled     = var.fa_builtin_logging_enabled

Debug Output/Panic Output

│ Error: the Site Name "testapp-azf" failed the availability check: Hostname 'dev' already exists. Please select a different name.
│ 
│   with module.fa_slot.azurerm_windows_function_app_slot.function_app_slot,
│   on .terraform/modules/fa_slot/main.tf line 1, in resource "azurerm_windows_function_app_slot" "function_app_slot":
│    1: resource "azurerm_windows_function_app_slot" "function_app_slot" {
│ 
│ the Site Name "testapp-azf" failed the availability check:
│ Hostname 'dev' already exists. Please select a different name.

Expected Behaviour

The slot would be created with the Function app name and the slot name appended with a forward slash and would be globally unique.
Example:
testapp-azf/dev

Actual Behaviour

Error is thrown: Hostname 'dev' already exists.
The slot will only deploy if it is given its own globally unique name.

Steps to Reproduce

Run a plan with the slot named something common that wouldn't be globally unique on its own.

Important Factoids

This works as expected with the new resource: azurerm_windows_web_app_slot and previously worked correctly with the azurerm_function_app_slot resource

References

No response

@bdorplatt bdorplatt added the bug label Apr 8, 2022
@github-actions github-actions bot removed the bug label Apr 8, 2022
@AaldertVanWijk-TomTom
Copy link
Contributor

Hi @bdorplatt does this issue occur for you when recreating the slot (because it was deleted either by terraform of ui)
I'm actually having an extremely similar problem. When I try to add a slot that previously existed Azure complains that it cannot create the slot.
There actually is a workaround.
you can first create the slot in the UI and afterwards import it into terraform:
tg import azurerm_windows_function_app_slot.this <azurerm_windows_function_app_slot.id>/slots/alt

@bdorplatt
Copy link
Author

Hello @AaldertVanWijk-TomTom, We have only tested this as net new as we hadn't previously used this resource to deploy a slot. All previous deployments used the now-deprecated azurerm_function_app_slot resource.

I'd be curious if running the Terraform code again against the imported resource would try to destroy and re-create the slot. Have you tested that scenario with the workaround?

@AaldertVanWijk-TomTom
Copy link
Contributor

@bdorplatt In my case after the import there are a lot of changes to the slot but there is no delete/create cycle

@aasier
Copy link

aasier commented Apr 22, 2022

Hello all,

We are having the same issue when we are creating the "staging" slot with the latest provider version,

module.sfo_azure_function_node.azurerm_windows_function_app_slot.sfo_function_app_slot_staging,
│ on .terraform\modules\sfo_azure_function_node\azure\function\app_func.tf line 144, in resource "azurerm_windows_function_app_slot" "sfo_function_app_slot_staging":
│ 144: resource "azurerm_windows_function_app_slot" "sfo_function_app_slot_staging" { # SLOT STAGING
│
│ the Site Name "xxx-xxx" failed the availability check: Hostname 'staging' already exists. Please select a different name.
$ terraform version
Terraform v1.0.9
on windows_amd64
+ provider registry.terraform.io/hashicorp/azurerm v3.3.0
+ provider registry.terraform.io/hashicorp/local v2.1.0
+ provider registry.terraform.io/hashicorp/null v3.1.0
+ provider registry.terraform.io/hashicorp/random v3.1.0

Could someone help here?

Thanks!! in advance,

@bdorplatt
Copy link
Author

There is a PR for this now so hopefully it makes it into the next release: #16410

@AaldertVanWijk-TomTom
Copy link
Contributor

@aasier
I know of two work arounds,

  1. manual creation and import as explained above
  2. choose a more complex alt-slot name the issue only occurs with names that already happen to be used: "alt", "staging" "second", etc.

@aasier
Copy link

aasier commented Apr 28, 2022

Thanks! @AaldertVanWijk-TomTom for your suggestions,
Finally, I did a null_resource to run a shell script with some az-cli commands.
I´m interested about when is gonna be available the new release with this fix. #16410

jackofallops added a commit that referenced this issue May 24, 2022
@github-actions github-actions bot added this to the v3.8.0 milestone May 24, 2022
@rgrace-puck
Copy link

I'm also seeing the same behavior in azurerm_linux_function_app_slot on version 3.7.0

@github-actions
Copy link

This functionality has been released in v3.8.0 of the Terraform Provider. Please see the Terraform documentation on provider versioning or reach out if you need any assistance upgrading.

For further feature requests or bug reports with this functionality, please create a new GitHub issue following the template. Thank you!

@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 Jun 30, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants