Last active
March 15, 2024 05:42
-
-
Save tristanmorgan/ac541f5689272a34e6135977c2bdf8ad to your computer and use it in GitHub Desktop.
Terraform Cloud Token Helper (save into macOS keychain)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
disable_checkpoint = true | |
credentials_helper helper { | |
args = [] | |
} | |
# save this in home. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
set -e | |
case $1 in | |
store) | |
security add-generic-password -U -a "TF-$USER" -c "htfm" -C "htfm" -D "Hashicorp Terraform" -s "$2" -w "$(jq -r .token)" | |
;; | |
get) | |
/bin/echo -n "{\"token\": \"$(security find-generic-password -g -a "TF-$USER" -s "$2" -w)\"}" | |
;; | |
forget) | |
security delete-generic-password -a "TF-$USER" -s "$2" | |
;; | |
*) | |
echo "Usage: $0 get|forget|store" | |
;; | |
esac | |
# save this into your ~/.terraform.d/plugins/ folder. |
The API is unchanged. Optional flags can be included before get/store/forget.
updated gist to use JQ to extract the token during the store action.
Read: I hadn't tested terraform login with it before.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
and the API changed....terraform-credentials-credstore --host=credstore.example.com store app.terraform.io
for example.