Generating Your Linode API Key
Before we start using Terraform with Linode, we need to generate an API key. This key will allow Terraform to create and manage resources in your Linode account.
Steps to Create Your API Key
-
Log in to your Linode Cloud Manager (opens in a new tab).
-
Click on your username at the top right, then select API Tokens.
-
Click the Create a Personal Access Token button.
-
In the Label field, enter a name for your token (e.g., "Terraform Access").
-
For expiry, you can choose Never if you want a permanent token, or set a specific duration.
-
Under Public Access, select None.
-
In the Access section, ensure the following permissions are enabled:
- Linodes: Read/Write
- Object Storage: Read/Write
-
Click Create Token.
Important: Your full API key will be displayed only once. Make sure to copy it and store it securely. You'll need this key when configuring Terraform to work with Linode.
Using Your API Key with Terraform
To use this API key with Terraform, you'll typically set it as an environment variable:
export LINODE_TOKEN="your_api_token_here"
Best Practices for API Key Security
- Never share your API key or commit it to your Git repository.
- Use environment variables or secure secret management tools to handle your API key.
- Regularly rotate your API keys, especially if you suspect they might have been compromised.
- Only grant the minimum necessary permissions to your API key.
Next Steps
Now that you have your Linode API key, you're ready to start using Terraform with Linode. In the next section, we'll begin setting up our Terraform configuration files.