Skip to main content
In this lesson, you’ll learn how to configure AWS credentials in Spacelift for a demo deployment. While several authentication methods are available, we begin with the simplest approach. If the AWS provider is not configured correctly, you may encounter an error similar to the following:
The same methods for configuring the AWS provider in Spacelift also apply when working on your local machine or within any containerized environment.

Sample Terraform Configuration

Below is an example Terraform configuration that sets up the AWS provider and creates a Virtual Private Cloud (VPC). In your environment, you can pass your AWS Access Key ID and AWS Secret Access Key as environment variables:

Passing Environment Variables to the Spacelift Runner

Before running Terraform, export your AWS credentials and region in your terminal:
After performing these steps, navigate to your stack’s environment settings in Spacelift and select “Edit” to add or update the necessary variables. To confirm your current AWS credential configuration, run:
The credentials file may also include Terraform output blocks that display resource attributes after provisioning. For instance:
After you verify and commit your changes, push them to your repository with:
The terminal output should resemble the following, indicating a successful commit:

Managing AWS Credentials in Spacelift

When configuring your environment variables in Spacelift, you have two options for storing AWS credentials:
Always store sensitive credentials as secrets in Spacelift. This ensures that your AWS credentials remain hidden and secure, protecting them from unauthorized access.
When stored as plain text, the values are visible and can be edited by anyone with access to Spacelift. Therefore, for security reasons, always mark your AWS credentials as secrets.
The image shows a web interface for managing environment variables in a Spacelift stack, with options to edit or delete variables. The stack is labeled as "failed," and various environment variables are listed with options to override.
By following these guidelines, you can efficiently manage your AWS credentials in Spacelift while ensuring your Terraform projects are configured securely and correctly.

Watch Video