Updated on May 21 2024
With the recent pricing changes to Terraform Cloud and the Terraform license change from Mozilla to a business source license, there has been a lot of discussion about migrations off of Terraform Cloud. In this blog, we want to provide you with the information to make a decision as well as how to migrate off of Terraform Cloud
A migration from one piece of software to another is never trivial, especially when that software manages all of your cloud infrastructure. Often a cost-benefit analysis is done to see if the effort to migrate is worth the savings that you are receiving with the new software. At Scalr, we believe in being transparent as well as fair, which is why we make it seamless to migrate into as well as out of Scalr. There are two ways of doing this, first is with our Terraform module and second is by updating your Terraform backend or code block.
Another aspect of the migration from Terraform Cloud that you’ll want to take into consideration is the cost of the new solution. At Scalr, the only thing we charge for is Terraform run, nothing else. Terraform Cloud has various pricing tiers which can make it difficult to compare apples to apples, but we’ve created a script (see below) that calls the Terraform Cloud API to pull your Terraform run count.
When deciding to make the switch from Terraform Cloud it is important to understand the lift it will require to migrate. Scalr is the only other Terraform remote operations backend in the market, which means the migration is fairly seamless and you won’t lose the ability to use the Terraform CLI. We have created a blog to help you understand the differences, but also similarities between Terraform Cloud and Scalr.
The first thing to note regarding pricing is that Scalr counts a Terraform plan and a Terraform apply as a run. There are many Terraform runs you are not charged for in the event of an error, for example, any errors at the Terraform init phase. You can find out more about that here.
We have created a script that helps you estimate the number of Terraform runs that you can expect in Scalr. The script will use a Terraform Cloud API token to call the API and pull the number of total runs you have ever executed in Terraform Cloud. Unfortunately, there is not a date filter in the Terraform Cloud API so you’ll have to do some estimation on how many runs were used per month or year. Based on the run count that is pulled from Terraform Cloud, you can now estimate your cost in Scalr with our pricing calculator.
Once you have decided to start a migration, you’ll then want to decide what you want to migrate. Depending on when you started using Terraform Cloud, you may have a single organization with many Terraform Cloud workspaces or many organizations with many workspaces. The big decision to make is whether you are happy with your existing structure or if you want to take the opportunity to redesign the structure to potentially help with workspace isolation. Also, this is a good time to take a look at the existing Terraform Cloud workspaces to determine if they are still needed and if you want to create a new workspace in Scalr.
The Terraform state file must be moved, so there isn’t a question about that, but what about Terraform variables as well as environment variables?
Also, who will do the migration? For smaller teams, it might be more practical for a cloud infrastructure team to be the one to migrate all of the existing state files over using the module, but for larger organizations, it might make more sense for workspace owners to do it at their own pace.
If you are going to have a slower migration, it’s important to note that you can sign up for the Scalr $99 plan and swap workspaces out of Terraform Cloud and into Scalr at your own pace and not have to worry about high costs.
If you’re using Terraform for everything else, then why not use it to migrate from Terraform Cloud to Scalr? Our migration module will use Terraform Cloud and Scalr API tokens to migrate the following objects:
When executing the Terraform module referenced above, the module will create new workspaces and environments in Scalr, there is no need to pre-create these. You will also have the option to do a mass migration at once or choose to do specific workspaces as needed.
If you would rather not migrate with the module mentioned above, the process is straightforward with the Terraform CLI. Before starting, make sure you have stopped all operations in Terraform Cloud as you want to avoid any updates to the existing state while migrating.
You’ll also need to make sure that you have the Terraform CLI installed on your local machines or wherever you intend to run the Terraform commands.
First, you’ll want to use the pull command to pull down the state from Terraform Cloud to your local machine. To do this, you’ll need to ensure you have an API token for Terraform Cloud:
terraform state pull > terraform.state
Next, get the API token from Scalr using the Terraform CLI and Terraform login command:
terraform login <account-name>.scalr.io
Update the Terraform backend configuration and add Scalr as the new cloud backend. Make sure to update the fields below. The Scalr environment ID can be seen on the environment dashboard.
terraform {
cloud {
hostname = "<account-name>.scalr.io"
organization = "<environment-id>"
workspaces {
name = "<workspace-name>"
}
}
}
Execute terraform init
to initialize Scalr as the backend.
Run terraform state push terraform.state
to push the existing state into the Scalr workspaces. Once you log into Scalr, you will see the Terraform state in the Scalr workspace.
Note: This same process can be used to migrate local state files that do not use Terraform Cloud as a backend. In this case, you simply need to add Scalr as the backend to your Terraform code and run Terraform init to create the workspace and upload the state.
As seen from the above, there are various stages when selecting a replacement for Terraform Cloud to manage your cloud infrastructure. The first step is to make sure you are selecting the right tool and to understand the level of effort as well as best practices before deciding to migrate. One of the crucial aspects of this is to understand if your Terraform code will have to change at all or how much your day-to-day operations will change. Scalr makes this very easy as the concept of a Terraform Cloud workspace is the exact same in Scalr.
Once you have a good understanding of the above, you can then start the Terraform state migration whether you do it with the Terraform CLI on a local machine or choose the Scalr Terraform module to automate it.
Interested in trying out Scalr? Sign up today!