Search code examples
terraformterraform-cloud

Terraform API add GPG key


I've created an api token at the organization level and am trying to add a GPG key

{
  "data": {
    "type": "gpg-keys",
    "attributes": {
      "namespace": "abc",
      "ascii-armor": "-----BEGIN PGP PUBLIC KEY BLOCK----- abc -----END PGP PUBLIC KEY BLOCK-----"
    }  }
}

I am providing namespace as the exact organization name (case sensitive) of the org I got the token from.

I am getting this response:

{
    "errors": [
        {
            "status": "403",
            "title": "forbidden",
            "detail": "body namespace not authorized"
        }
    ]
}

I am following this docs: https://developer.hashicorp.com/terraform/cloud-docs/api-docs/private-registry/gpg-keys#add-a-gpg-key


Solution

  • This was actually just user error (or user unawareness?) - we cannot have private providers on the free tier of Terraform cloud.

    A better error message would have made it easier.