Monday, 28 January 2019

Terraform - Failed to load backend: Initialization required

I came across this issue the other day and thought I'd share the solution.

Issue

When running terraform plan, you may get the error below:

Backend reinitialization required. Please run "terraform init".
Reason: Initial configuration of the requested backend "azurerm"

The "backend" is the interface that Terraform uses to store state,e,
perform operations, etc. If this message is showing up, it means that theshowing up, it means that the
Terraform configuration you're using is using a custom configuration forthe Terraform backend.

Changes to backend configurations require reinitialization. This allows
Terraform to setup the new configuration, copy existing state, etc. This isonly done during "terraform init". Please run that command now then try again.
If the change reason above is incorrect, please verify your configuration
hasn't changed and try again. At this point, no changes to your existingconfiguration or state have been made.
Failed to load backend: Initialization required. Please see the error message above.


Cause

I found that the cause of the problem was that I had used the backend block in my terraform configuration like below:


This tells terraform to expect some backend configuration however I was just testing and running terraform init without specifying a backend like below:

terraform init -input=false -backend=false

Solution

The solution is pretty simple. Basically, you need to either remove the backend settings from your terraform block but that's not the way you want to go if you want to use remote state. The other option is to specify backend settings when you run terraform init, like this:

terraform init \
-backend-config="storage_account_name=MyStorageAccount" \
-backend-config="container_name=MyStorageContainer" \
-backend-config="key=Terraform.tfstate" \
-backend-config="access_key=MyStorageAccountAccessKey"

You should now be able to run terraform plan.

13 comments:

  1. Great post ! I am pretty much pleased with your good post.You put really very helpful information


    โปรโมชั่นGclub ของทางทีมงานตอนนี้แจกฟรีโบนัส 50%
    เพียงแค่คุณสมัคร Gclub กับทางทีมงานของเราเพียงเท่านั้น
    ร่วมมาเป็นส่วนหนึ่งกับเว็บไซต์คาสิโนออนไลน์ของเราได้เลยค่ะ
    สมัครสล็อตออนไลน์ >>> goldenslot
    สนใจร่วมลงทุนกับเรา สมัครเอเย่น Gclub คลิ๊กได้เลย

    ReplyDelete
    Replies
    1. Great Article Cloud Computing Projects

      Networking Projects

      Final Year Projects for CSE

      JavaScript Training in Chennai

      JavaScript Training in Chennai

      The Angular Training covers a wide range of topics including Components, Angular Directives, Angular Services, Pipes, security fundamentals, Routing, and Angular programmability. The new Angular TRaining will lay the foundation you need to specialise in Single Page Application developer. Angular Training

      Delete
  2. This is really an amazing blog. Your blog is really good and your article has always good thank you for information.

    เว็บไซต์คาสิโนออนไลน์ที่ได้คุณภาพอับดับ 1 ของประเทศ
    เป็นเว็บไซต์การพนันออนไลน์ที่มีคนมา สมัคร Gclub Royal1688
    และยังมีหวยให้คุณได้เล่น สมัครหวยออนไลน์ ได้เลย
    สมัครสมาชิกที่นี่ >>> Gclub Royal1688
    ร่วมลงทุนสมัครเอเย่นคาสิโนกับทีมงานของเราได้เลย

    ReplyDelete
  3. Do you require HP printer setup for your mac operating system? Is your printer driver not suitable for macOS? Then visit the 123.hp.com/setup to get the software and driver for better functioning of your printer. You can also call our expert HP support team for services.

    ReplyDelete
  4. Need a Debt Loan To Pay Off Bills?
    Take control of your debt today
    Available Now Business Expansion Loan Offer?
    Do you need a loan to pay off Bills?
    Do you need a loan?
    Do you need Personal Loan?
    Business Expansion Loan?
    Business Start-up, Education,
    Debt Consolidation Loan
    Hard Money Loans
    Loan for any thing ?
    We offer loan at low interest rate of 3%
    Loan with no credit check,
    Email us: financialserviceoffer876@gmail.com
    Call or add us on what's app +918929509036

    ReplyDelete
  5. My name is Samuel, I was in love with my wife and we were married for eight years with a son his is Liam,I loved my wife so much she had access to all my bank account and even my cash app which my accountant agreed to and said it was a great idea, then it took my wife and my accountant two month to get hold of all my properties,all accounts but I had a cash app which they knew nothing about,I was thrown out of my own house was sleeping in a hotel for weeks she also took possession of my son could only see him once a week then I found out she was in love with my accountant all these while so I went online and I came across a private investigator who help me get all my properties and my accounts back even my company back how he did these I don’t know but I gave all the information he asked for and followed all his instructions and now I’m happy my life’s better now.
    Thanks to premiumhackservices@gmail.com
    I just said I should share my own story here
    Thank you

    ReplyDelete