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

New version of azurerm_template_spec_version in azurerm_resource_group_template_deployment leads to InvalidDeployment error #24050

Closed
1 task done
vaspoz opened this issue Nov 28, 2023 · 3 comments · Fixed by #24072

Comments

@vaspoz
Copy link

vaspoz commented Nov 28, 2023

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 and review the contribution guide to help.

Terraform Version

1.5.6

AzureRM Provider Version

3.82.0

Affected Resource(s)/Data Source(s)

azurerm_resource_group_template_deployment

Terraform Configuration Files

provider "azurerm" {
  features {}
}

resource "azurerm_resource_group" "rg" {
  name     = "rg-basil-explore-day"
  location = "westeurope"
}

data "azurerm_template_spec_version" "example" {
  name                = "explore-day-storage"
  resource_group_name = "rg-basil-explore-day-templates"
  version             = "0.0.2"
}


resource "azurerm_resource_group_template_deployment" "example" {
  name                = "explore-day-storage-module-deployment"
  resource_group_name = azurerm_resource_group.rg.name
  deployment_mode     = "Incremental"

  template_spec_version_id = data.azurerm_template_spec_version.example.id

  parameters_content = jsonencode({
    "storageAccountName" = {
      value = "basilexplorestorage"
    }
    "location" = {
      value = "westeurope"
    }
  })
}

Debug Output/Panic Output

# azurerm_resource_group_template_deployment.example will be updated in-place
  ~ resource "azurerm_resource_group_template_deployment" "example" {
        id                       = "/subscriptions/02f04294-0bce-45ad-9981-8bd29daee181/resourceGroups/rg-basil-explore-day/providers/Microsoft.Resources/deployments/explore-day-storage-module-deployment"
        name                     = "explore-day-storage-module-deployment"
        tags                     = {}
      ~ template_spec_version_id = "/subscriptions/02f04294-0bce-45ad-9981-8bd29daee181/resourceGroups/rg-basil-explore-day-templates/providers/Microsoft.Resources/templateSpecs/explore-day-storage/versions/0.0.1" -> "/subscriptions/02f04294-0bce-45ad-9981-8bd29daee181/resourceGroups/rg-basil-explore-day-templates/providers/Microsoft.Resources/templateSpecs/explore-day-storage/versions/0.0.2"
        # (5 unchanged attributes hidden)
    }

Plan: 0 to add, 1 to change, 0 to destroy.
azurerm_resource_group_template_deployment.example: Modifying... [id=/subscriptions/02f04294-0bce-45ad-9981-8bd29daee181/resourceGroups/rg-basil-explore-day/providers/Microsoft.Resources/deployments/explore-day-storage-module-deployment]
╷
│ Error: validating Template Deployment "explore-day-storage-module-deployment" (Resource Group "rg-basil-explore-day"): requesting validating: resources.DeploymentsClient#Validate: Failure sending request: StatusCode=400 -- Original Error: Code="InvalidDeployment" Message="The deployment 'explore-day-storage-module-deployment' cannot have both the TemplateLink and Template property set. Please use one or the other. Please see https://aka.ms/arm-module for usage details."
│
│   with azurerm_resource_group_template_deployment.example,
│   on main.tf line 17, in resource "azurerm_resource_group_template_deployment" "example":
│   17: resource "azurerm_resource_group_template_deployment" "example" {
│

Expected Behaviour

The resource behind the template spec v0.0.1 (Azure storage account) in updated with v0.0.2 (in that version I only update the name of the storage account).

Actual Behaviour

Nothing happens with the resource itself, just got the error output.

Steps to Reproduce

Update the version field in data "azurerm_template_spec_version" "example" and run terraform apply again

Important Factoids

nope

References

No response

@github-actions github-actions bot added the v/3.x label Nov 28, 2023
@vaspoz
Copy link
Author

vaspoz commented Nov 28, 2023

Here's version 0.0.1 of the template spec:

@description('Name of the Storage Account')
param storageAccountName string

@description('Location for all resources')
param location string = resourceGroup().location

// Create StorageAccount
resource storageAccount 'Microsoft.Storage/storageAccounts@2021-04-01' = {
  name: '${storageAccountName}111'
  location: location
  properties: {
    allowCrossTenantReplication: false
    supportsHttpsTrafficOnly: true
    minimumTlsVersion: 'TLS1_2'
    allowBlobPublicAccess: false
  }
  kind: 'StorageV2'
  sku: {
    name: 'Standard_LRS'
  }
}

and v 0.0.2:

...
  name: '${storageAccountName}222'
...

@rcskosir
Copy link
Contributor

Thank you for taking the time to open this issue. Please subscribe to PR #24072 created by @teowa for this issue.

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 Apr 29, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.