skip to Main Content

I am learning Terraform, so just added the provider config, ad config and the resource group config in my main.tf file. While trying to run the plan command "terraform plan -out main.tfplan", I am getting
No changes. Your infrastructure matches the configuration.

Terraform has compared your real infrastructure against your configuration and found no differences, so no changes are needed.

even on running the terraform init command there is no lock file or the terraform folder is getting created in my package structure.

I was expecting the lock file and a terraform folder getting created on running the init command and the changes that I have made(added a Resource group) should be reflected on running the plan command

2

Answers


  1. Need to check below:

    Firstly, check you are executing the terraform file in the directory where it has been created.

    If you are viewing "No changes. Your infrastructure matches the configuration" means it indicates the terraform has verified your infrastructure with the configured provider and it already aligns with the resources specified in your filename.tf file.

    Also, if you are executing in Azure CLI, make sure that you saved all the changes using :wq command as shown below.

    enter image description here

    And it doesn’t not necessarily needed to have a terraform Lock file for each and every terraform project. It is completely related to remote backends.
    Make sure that the terraform state file has created successfully with the given configuration.

    I tried to deploy a resource group and was able to perform all the operations successfully.

    provider "azurerm" {
      features {}
    }
    resource "azurerm_resource_group" "example" {
      name     = "myresources"
      location = "West Europe"
    }
    

    Output:

    enter image description here

    enter image description here

    enter image description here

    If still the issue persists, enable debugging which is detailed here in the doc.

    Login or Signup to reply.
  2. A ‘ no changes ‘ by Terraform seems to me is due to few scenarios :

    1. There is a problem with your Terraform configuration and the scope that your Terraform configuration is supposed to manage. I would advise you to review the Terraform setup and config files
    2. You are applying ‘Terraform init’ while forgetting to save your new configuration in the Terraform file. Always make sure to save all the changes that you made on your Terraform files before executing a ‘Terraform Plan’
    3. Your configuration file is corrupt. Therefore, you’ll need to use The ‘terraform init -reconfigure’ command. Read more about it in this article How to Migrate Terraform State Between Different Backends
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search