Using Spacelift-Hosted Modules Locally
Last updated: November 10, 2024
Steps to Access Spacelift-Hosted Modules Locally
Log in to Spacelift with Terraform
Open your terminal and run the following command:terraform login spacelift.ioThis command will prompt Terraform to open your default web browser, where you’ll be asked to log in to your Spacelift account.
Authorize Terraform
Confirm the login request in your browser to allow Terraform to access Spacelift. After successful login, Terraform will store the necessary credentials locally.Credential Storage
Once logged in, Terraform saves the credentials in the~/.terraform.d/credentials.tfrc.jsonfile. These credentials will be automatically used by Terraform for subsequent commands, enabling access to Spacelift-hosted modules.
The method above requires a web browser which is not always practical, for example on remote server with no GUI. In that case, you can use credentials generated from API keys. The credentials file generated upon the creation of each API key contains a section explaining how a key can be used to set up credentials in the Terraform configuration file (.terraformrc). To learn more about this please refer directly to Terraform documentation.