Introduction
When adding a generated GPG key as described in the documentation, it is common for editors/environments to add empty characters to the key (even when directly copy/pasting) that can interfere with a successful addition of the key.
The following error is indicative of this when using the API:
{
"errors": [
"openpgp: invalid argument: no armored data found"
]
}
The same error can also be seen when adding the GPG keys via the associated UI in Terraform Cloud:
https://registry.terraform.io/settings/gpg-keys
Procedure
-
First, you'll want a
payload.json
file to add the key to (as illustrated here) - Then, use the
jq
utility to insert your GPG key(my-gpg-key.gpg
in the example below) into thepayload.json
file:
> jq --arg armor "$(cat my-gpg-key.gpg)" '.data.attributes."ascii-armor"=$armor' payload.json > gpg-payload.json
- After running this command, add the key using the resulting
payload.json
file as outlined in the documentation:
curl \
--header "Authorization: Bearer $TOKEN" \
--header "Content-Type: application/vnd.api+json" \
--request POST \
--data @payload.json \
https://app.terraform.io/api/registry/private/v2/gpg-keys
Additional Information
-
If you continue to experience issues, please contact Hashicorp Support