The Terraform credential helper is a great way to authenticate to external Terraform services when using Scalr. By default, Scalr will use the credentials within the context of the account Terraform is running in, but sometimes you may need to call out to something like an external module registry.
The main use case we normally hear is that a customer is migrating into Scalr, but as part of the migration process, they will need to use an external module registry while migrating to the Scalr private module registry.
In the example in this blog, I am using two separate Scalr accounts to demonstrate the same concept. The two accounts have separate users, module registries, tokens etc. I will be migrating from my “docs.scalr.io” account into the “scalr-demo.scalr.io” account. I have a very basic Terraform example that is pulling a module from the module registry in docs.scalr.io, while the run is actually executing in scalr-demo.scalr.io
The first thing you’ll want to do is to add the following in your .terraformrc file:
Then, you’ll want to add the credential helper script to your workspace, specifically the plugins directory:
This is just an example, any third party helpers can be used in place of this.
Once you run terraform init, you will see that it can access the remote registry from the external source.
That’s it! It is as simple as that to plug into external services while executing your workflows in Scalr.