Azure / terraform-azurerm-avm-res-storage-storageaccount

This Terraform module is designed to create Azure Storage Accounts and its related resources, including blob containers, queues, tables, and file shares. It also supports the creation of a storage account private endpoint which provides secure and direct connectivity to Azure Storage over a private network.
https://registry.terraform.io/modules/Azure/avm-res-storage-storageaccount
MIT License
19 stars 27 forks source link

validation and initialization fail with error "Blocks of type "lifecycle" are not expected here" #155

Closed chopeen closed 1 week ago

chopeen commented 1 week ago

Is there an existing issue for this?

Greenfield/Brownfield provisioning

brownfield

Terraform Version

OpenTofu v1.8.1

Module Version

0.2.5

AzureRM Provider Version

v3.116.0

Affected Resource(s)/Data Source(s)

?

Terraform Configuration Files

module "avm_res_storage_storageaccount" {
  source                          = "Azure/avm-res-storage-storageaccount/azurerm"
  version                         = "0.2.5"
  location                        = data.azurerm_resource_group.rg_X.location
  resource_group_name             = data.azurerm_resource_group.rg_X.name
  name                            = local.storage_account_name
  account_replication_type        = "ZRS"
  account_tier                    = "Standard"
  account_kind                    = "StorageV2"
  allow_nested_items_to_be_public = false
  https_traffic_only_enabled      = true
  enable_telemetry                = false
  public_network_access_enabled   = true
  network_rules = {
    bypass         = ["AzureServices"]
    default_action = "Allow"
  }
  role_assignments = {
...
  }
  diagnostic_settings_storage_account = {
    storage = {
...
    }
  }
  diagnostic_settings_file = {
    file1 = {
...
    }
  }
  diagnostic_settings_blob = {
    blob11 = {
...
    }
  }
  tags = local.common_tags
}

Debug Output/Panic Output

$ gitlab-tofu validate
Initializing modules...
Downloading registry.opentofu.org/Azure/avm-res-storage-storageaccount/azurerm 0.2.5 for avm_res_storage_storageaccount...
- avm_res_storage_storageaccount in .terraform/modules/avm_res_storage_storageaccount
╷
│ Error: Unsupported block type
│ 
│   on .terraform/modules/avm_res_storage_storageaccount/main.deprecated.tf line 3, in removed:
│    3:   lifecycle {
│ 
│ Blocks of type "lifecycle" are not expected here.
╵
╷
│ Error: Unsupported block type
│ 
│   on .terraform/modules/avm_res_storage_storageaccount/main.deprecated.tf line 3, in removed:
│    3:   lifecycle {
│ 
│ Blocks of type "lifecycle" are not expected here.
╵

Expected Behaviour

No response

Actual Behaviour

After upgrading from 0.2.4 -> 0.2.5, both tofu init and tofu validate are failing with error Blocks of type "lifecycle" are not expected here.

Steps to Reproduce

No response

Important Factoids

No response

References

No response

jaredfholgate commented 1 week ago

Hi @chopeen. Azure Verified Modules do not explicitly support OpenTofu and we don't test with OpenTofu. This is the first issue I have seen where there is a difference between the OpenTofu and Terraform CLI implementations that is surfacing as an issue. This is very interesting to see and I will raise with the other AVM leads to get their thoughts. Unfortunately, there is nothing we can do to resolve this in the short term.

CC @matt-FFFFFF @jtracey93

matt-FFFFFF commented 1 week ago

I was going to post exactly what @jaredfholgate did!

I suggest opening an issue on the opentofu repo to support this.

At the moment we are reliant on opentofu's compatibility promises. We will consider as a team if we need to change our position

If we choose to support both then it's a race to the bottom in terms of the features we can use.

chopeen commented 1 week ago

I think you're both right - OpenTofu does support the removed block, but not the lifecycle meta-argument in modules - there is an open feature request https://github.com/opentofu/opentofu/issues/304 for such enhancement.


GitLab has deprecated support for the Terraform templates (see deprecate-terraform-cicd-templates) and stopped updating terraform binaries licensed under BSL; Terraform CI/CD templates will be removed completely in May 2025.

Can you please discuss the possibility of adding support for OpenTofu?