https://github.com/oxplot/terraform-credentials-gpg
Terraform Cloud GPG Credentials Helper
https://github.com/oxplot/terraform-credentials-gpg
Last synced: about 1 month ago
JSON representation
Terraform Cloud GPG Credentials Helper
- Host: GitHub
- URL: https://github.com/oxplot/terraform-credentials-gpg
- Owner: oxplot
- License: bsd-3-clause
- Created: 2020-11-11T04:07:56.000Z (almost 5 years ago)
- Default Branch: main
- Last Pushed: 2022-11-25T11:26:30.000Z (almost 3 years ago)
- Last Synced: 2025-06-22T00:03:51.941Z (5 months ago)
- Language: Shell
- Size: 6.84 KB
- Stars: 1
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: Readme.md
- License: LICENSE
Awesome Lists containing this project
README
Store your Terraform Cloud API token encrypted by GPG.
## Requirements
- GPG tools
- terraform CLI tool
- A key pair
- Terraform Cloud account with org and a workspace setup
## Getting started
Get a copy of the code:
```
cd ~
git clone https://github.com/oxplot/terraform-credentials-gpg
cd terraform-credentials-gpg
```
Copy or link to `terraform-credentials-gpg` in your terraform plugins
directory:
```
cp terraform-credentials-gpg ~/.terraform.d/plugins/
#ln -s ~/terraform-credentials-gpg/terraform-credentials-gpg ~/.terraform.d/plugins/
```
Configure your terraform to use the GPG credential helper:
```
cat <> ~/.terraformrc
credentials_helper "gpg" {
args = ["1122334455667788", "/home/bobby/.terraform-cloud-token"]
}
EOF
```
*`1122334455667788` is your key ID. Alternatively, you can use the email
address associated with that key.*
*`.terraform-cloud-token` will store gpg encrypted token*
Login to terraform:
```
terraform login
```
Setup a new terraform project:
```
cd ~
mkdir tf-cloud-test
cd tf-cloud-test
cat < backend.tf
terraform {
backend "remote" {
organization = "your-org-name"
workspaces {
name = "your-workspace"
}
}
}
EOF
```
Init it:
```
terraform init
```
above command should pop up the password dialog to decrypt your token file - (or may do so automatically if you have your GPG agent running).