Why env0
Solutions
Infrastructure as Code (IaC) Automation Teams and GovernanceManaged Self-Service env0 for the Enterprise
DocumentationPricing
Resources
Case StudiesIn the NewsVideosWebinars
Blog
Login
Get a Demo
FREE TRIALContact us
Jan 30, 2023

Recommendations for Migrating from Terraform Cloud Pari 2

Chris Noon
Sales Engineer

In mid-2021, Tim Davis wrote a blog on migrating the state from TFC (Terraform Cloud) to another IaC management platform.

It does a great job of highlighting how TFC and env0 function in terms of both runs and state, or at least it did. Since this original post, the env0 Platform evolution has been quick and with features and improvements coming out every week, it can be hard to keep up. Let me elaborate…

The original article mentions “env0 does not offer remote state backend capabilities…yet (Stay tuned)”. We do now! env0 recently added remote backend support that stores customer state files in a remote location (per customer, per environment). This now allows our customers to pick between three methods of managing state files.

  • env0 can store the state files “locally” within the env0 infrastructure. Both our SaaS and hybrid deployment options run on Kubernetes, and PVs (persistent volumes) are created and used to store state per customer, per environment.
  • env0 can store the state in any external backend as configured by the client in their code (such as S3).
  • env0 can store state in a dedicated per customer, per environment env0 managed remote backend. This capability allows our customers to have the peace of mind their state is separated from the application all while not having to manage or pay for storage.

The key takeaway here is that these three options allow you as the customer to make design decisions based on your desired solution.

Migrating your remote state

Now with these three options available to our users, we are able to seamlessly migrate both the runs and state to env0 and provide the same governance and compliance for the state.

In these examples, we will assume you are migrating your run and state from TFC to env0.

TFC remote backend to env0 remote backend

This migration method can be somewhat challenging because you have to move the state via a proxy, typically a local machine or jump box/bastion host. It also requires a login to TFC and env0. The below procedure can be used to migrate TFC local state to the env0 local state.

Login to TFC: [.code]terraform login[.code]

[.code]mkdir -p terraform.tfstate.d/tfc-migration[.code]

[.code]terraform state pull > terraform.tfstate.d/tfc-migration/terraform.tfstate[.code]

[.code]mv .terraform/terraform.tfstate .terraform/terraform.tfstate.old[.code]

[.code]cp terraform.tfstate.d/tfc-migration/terraform.tfstate .terraform/terraform.tfstate[.code]

Remove the cloud block in the config (if configured)

[.code]terraform init[.code]

[.code] terraform plan[.code]. No changes should be seen.

Login to env0: [.code]terraform login backend.api.env0.com[.code]

Add the env0 cloud block: https://docs.env0.com/docs/state-migration

[.code]terraform init -migrate-state -force-copy[.code]

Update the env0 template with the correct VCS configuration.

We are working hard to have this scripted. Keep your eyes peeled.

Existing remote state

Possibly the easiest type of migration is when using TFC with a remote state such as s3.  This migrates the run logic while leaving the state untouched.

The only part of the migration that can become troublesome is the replication of variables and environmental variables. To assist in the migration, we have created a script that will pull the data from your TFC workspace and create an equivalent env0 workspace, including moving your variables from one to the other.

TFC remote state to env0 remote state

This method is identical to the “TFC remote state to env0 local state” with one additional step at the end of the procedure. Enable “Use env0 remote backend” in the environment settings and redeploy, moving your state from env0 local to env0 remote backend.

‍

Final Thoughts

These three migration methods allow you to migrate from TFC to env0 and have the state stored in any way that meets your business needs. We want to provide as much flexibility when moving over to env0 and we understand the state is an important part of the conversation.

If you are looking for features around executing remote runs locally, then I suggest you check out another recent post.

If you have any questions about state migration or env0 in general, please reach out to us and our team would be happy to help.

Interested in learning more about env0?
Request a Demo
SHARE
You may also like
Day 0 Environment Creation
Share outputs between IaC stacks
Chris' Corner - March 2023
Go back to blog
CNCF Member Badge
Company
About UsIn the NewsPress ReleasesCase StudiesAdditional ResourcesCareers
Developer and DevOps
APITerraform ProviderTerratag Open Source
Terraform Cloud AlternativeDIY AlternativeAtlantis Alternative
FREE TRIAL
Follow Us
Terms of ServicePrivacy PolicySecuritySystem Status
© Copyright env0 2023
This website uses cookies. We use cookies to ensure that we give you the best experience on our website. Learn More
PreferencesDenyAccept
Privacy Preference Center
When you visit websites, they may store or retrieve data in your browser. This storage is often necessary for the basic functionality of the website. The storage may be used for marketing, analytics, and personalization of the site, such as storing your preferences. Privacy is important to us, so you have the option of disabling certain types of storage that may not be necessary for the basic functioning of the website. Blocking categories may impact your experience on the website.
Reject all cookiesAllow all cookies
Manage Consent Preferences by Category
Essential
Always Active
These items are required to enable basic website functionality.
Marketing
These items are used to deliver advertising that is more relevant to you and your interests. They may also be used to limit the number of times you see an advertisement and measure the effectiveness of advertising campaigns. Advertising networks usually place them with the website operator’s permission.
Personalization
These items allow the website to remember choices you make (such as your user name, language, or the region you are in) and provide enhanced, more personal features. For example, a website may provide you with local weather reports or traffic news by storing data about your current location.
Analytics
These items help the website operator understand how its website performs, how visitors interact with the site, and whether there may be technical issues. This storage type usually doesn’t collect information that identifies a visitor.
Confirm my preferences and close