GitHub Codespaces secrets at repository, organization, and user scope — the direct mirror of
terraform-github-dependabot, one scope up to include the user-level secret.
| Resource | Role |
|---|---|
github_codespaces_secret.repo |
for_each map of repository-scoped Codespaces secrets (sensitive). |
github_codespaces_organization_secret.org |
for_each map of organization-scoped Codespaces secrets with visibility (all / private / selected). |
github_codespaces_organization_secret_repositories.allow |
Selected-repository allow-lists for selected-visibility org secrets. |
github_codespaces_user_secret.user |
for_each map of user-scoped Codespaces secrets (sensitive). |
There is no single dominant resource — this is a scope-spanning secrets bundle. Name each collection by role (
repo,org,allow,user); nothis. (Same shape asterraform-github-dependabot.)
github_repository— consumed by name (repo secrets) / numeric id (orgselectedallow-lists) fromterraform-github-repository.github_actions_secret/github_dependabot_secret— different feature, owned byterraform-github-actions-repository/terraform-github-dependabot.
| Input | Type | Source module |
|---|---|---|
repository_secrets[].repository |
string (repo name) | terraform-github-repository (id output) |
organization_secrets[].selected_repository_ids |
list(number) | terraform-github-repository (repo_id output) |
secret_repository_access[].selected_repository_ids |
list(number) | terraform-github-repository (repo_id output) |
user_secrets[].selected_repository_ids |
list(number) | terraform-github-repository (repo_id output) |
| Output | Description | Consumed by |
|---|---|---|
repository_secret_names |
Set of managed repo Codespaces secret names (values never emitted) | Audit / drift detection |
repository_secret_ids |
Map: name → <repo>:<secret> resource id |
Reporting |
organization_secret_names |
Set of managed org Codespaces secret names | Audit |
organization_secret_ids |
Map: name → resource id | Reporting |
user_secret_names |
Set of managed user Codespaces secret names | Audit |
user_secret_ids |
Map: name → resource id | Reporting |
secret_repository_access_ids |
Map: secret name → allow-list resource id | Reporting |
🔒 No secret values are ever output. Only names and resource ids are emitted.
Classic PAT scopes
repo— repository Codespaces secretsadmin:org— organization Codespaces secrets and allow-listscodespace:secrets(user) — user-scoped Codespaces secrets
Fine-grained PAT / GitHub App permissions
- Repository permissions → Codespaces secrets: read/write
- Organization permissions → Codespaces secrets / Organization Codespaces secrets: read/write
- User permissions → Codespaces user secrets: read/write (for the user-scoped resource)
- Metadata: read
⚠️ Auth and the target org (owner/GITHUB_OWNER) are provider concerns — never module variables.
- Codespaces must be enabled for the organization (and billing configured) before org/repo Codespaces secrets can be created.
- Plan / edition: org-level Codespaces secrets require GitHub Team or Enterprise Cloud; user secrets work for any user with Codespaces access. Confirm the org's Codespaces policy permits the targeted repos.
selected-visibility org secrets requireselected_repository_ids(the repo numeric ids — wire fromterraform-github-repository.repo_id).- Rate limit: each secret is one API write plus a public-key fetch for encryption — watch secondary rate limits on large
for_eachmaps. ⚠️ Many regulated orgs disable Codespaces entirely — confirm Codespaces is part of the Casey's GitHub footprint before adopting this module.
- Secret
plaintext_valueis sensitive = true; preferencrypted_valuepre-encrypted with the appropriate Codespaces public key.⚠️ These resources expose nokey_idargument (confirmed againstintegrations/github6.12.1) — unlike some other secret APIs, the provider resolves the public key internally, so supply only the Base64encrypted_value.var.*_secretsmaps aresensitive, somain.tfiteratesnonsensitive(keys(...))to satisfy Terraform's for_each-over-sensitive restriction (same pattern asterraform-github-repository-environment/terraform-github-dependabot). - Org secret
visibilityisall/private/selected;selectedpairs with the allow-list resource — own the allow-list in exactly one place (don't also setselected_repository_idsinline on the secret). - Secret/variable names are stored; values are write-only — the provider cannot detect remote-value drift.
- No tags, no timeouts.
- Boundary = all Codespaces secret scopes behind one module, mirroring
terraform-github-dependabot(repo + org + allow-list) and adding the user scope. Keeping secrets-by-feature consistent across Dependabot / Actions / Codespaces makes the library predictable. - Aggregation shape (no
this) — each scope is an independent role-namedfor_eachcollection defaulting to{}, so a caller enables only the scopes they use.