Terraform using : how to fix this issue with detail error"Terraform encountered problems during initialisation"

rain purple 340 Reputation points
2026-08-13T07:31:40.3133333+00:00

Hello, support team:

when use terraform template to create a new storage account in a new subscription through cloud shell in Azure portal, always face an issue in Cloud shell:

--nano main tf

save a file 

--terraform init

feedback: User's image

how to fix this issue? if there's a extra symbol"}", when I delete it, it remains the same error feedback.

Thanks, I'm a new user for the first time to create resource with terraform language.

New user in Azure portal

Azure Storage
Azure Storage

Globally unique resources that provide access to data management services and serve as the parent namespace for the services.

0 comments No comments

1 answer

Sort by: Most helpful
  1. AI answer

    2026-08-13T07:32:11.4866667+00:00

    The error shown is a Terraform syntax error in main.tf, not a Cloud Shell provisioning issue.

    terraform init validates the configuration enough to determine which providers and modules are needed. In this case, Terraform found an unclosed configuration block:

    Error: Unclosed configuration block
    on main.tf line 39, in resource "azurerm_storage_container_immutability_policy" "example":
    39: resource "azurerm_storage_container_immutability_policy" "example" {
    
    There is no closing brace for this block before the end of the file.
    

    Fix it with these steps:

    1. Open main.tf in Cloud Shell.
         nano main.tf
      
    2. Go to the block that starts on line 39:
         resource "azurerm_storage_container_immutability_policy" "example" {
      
    3. Check that every opening { has a matching closing }. The error means this resource block is missing a closing brace before the end of the file, or another block earlier in the file has incorrect brace nesting.
    4. Save the file and run:
         terraform init
      
    5. If the error still points to the same line, review the blocks above line 39 as well. Terraform states that incorrect brace nesting elsewhere in the file can cause the same message.

    For a new Cloud Shell setup, also verify Terraform is available and current:

    terraform version
    

    Cloud Shell updates Terraform automatically, but updates can lag by a couple of weeks. If needed, install the current version in Cloud Shell with:

    curl -O <terraform_download_url>
    unzip <zip_file_downloaded_in_previous_step>
    mkdir bin
    mv terraform bin/
    

    Then close and restart Cloud Shell, and verify again:

    terraform version
    

    Before creating resources in a new subscription, verify the active subscription used by Cloud Shell:

    az account show
    

    Terraform automatically authenticates by using the default Azure subscription shown there.


    AI-generated content may be incorrect. Read our transparency notes for more information.

    Was this answer helpful?

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.