Table of Contents
- Workspace-Level Variables
- Organizational Variable Sets
- Terraform CLI & Cloud Integration
- Variable Precedence & Overrides
- Conclusion
- References
Workspace-Level Variables
Workspace-level variables apply only to the workspace where they’re defined. This is ideal for settings that differ per environment.- Sign in to Terraform Cloud and select your workspace (e.g.,
devopsawsmyapp-dev) under the Mastering Terraform Cloud organization. - Navigate to Settings → Variables.
- Add environment variables for your AWS credentials:
AWS_ACCESS_KEY_ID(mark as sensitive)AWS_SECRET_ACCESS_KEY(mark as sensitive)

Always mark AWS credentials as sensitive to prevent them from appearing in logs or the UI.
Organizational Variable Sets
Organizational variable sets let you define a common set of variables once and apply them to multiple workspaces.| Scope | Inheritance | Override Behavior |
|---|---|---|
| Workspace-level | Only that workspace | Highest precedence |
| Organizational variable | Selected or all workspaces | Can be overridden at workspace |
Creating an Org Variable Set
- Go to Organization Settings → Variable Sets.
- Click Create variable set, then enter:
- Name:
AWS-Credentials - Description:
Shared AWS keys for all dev & prod workspaces
- Name:
- Under Workspaces, choose All workspaces or pick specific ones.
- Add the following environment variables:
AWS_ACCESS_KEY_IDAWS_SECRET_ACCESS_KEY(mark as sensitive)
- Save the set.
Terraform CLI & Cloud Integration
To run Terraform commands against Terraform Cloud, authenticate your CLI and initialize the workspace:
Variable Precedence & Overrides
By default, workspace-level variables override those from organizational sets.Order of precedence (highest → lowest):
- CLI
-varflags - Workspace-level variables
- Organizational variable sets
- Terraform defaults
Overriding at the Workspace UI
- Open Settings → Variables in your workspace.
- Add
prefixas an environment variable:- Key:
prefix - Value:
dev-app
- Key:
- Save changes.
Overriding via CLI at Runtime
Conclusion
You have now:- Configured AWS credentials at the workspace level.
- Created and applied an organizational variable set.
- Connected your local CLI to Terraform Cloud.
- Explored variable precedence and override methods.