Skip to content

Commit 1dcaad6

Browse files
fix: random suffix for the oidc pool & provider
1 parent 927a23b commit 1dcaad6

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

examples/with-backstage/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ Once you are finished with the reference architecture, you can remove all provis
7676
| github | ~> 5.38 |
7777
| google | ~> 5.1 |
7878
| humanitec | ~> 0.13 |
79+
| random | ~> 3.5 |
7980

8081
### Providers
8182

@@ -84,6 +85,7 @@ Once you are finished with the reference architecture, you can remove all provis
8485
| github | ~> 5.38 |
8586
| google | ~> 5.1 |
8687
| humanitec | ~> 0.13 |
88+
| random | ~> 3.5 |
8789

8890
### Modules
8991

@@ -120,6 +122,7 @@ Once you are finished with the reference architecture, you can remove all provis
120122
| [humanitec_value.backstage_github_org_id](https://registry.terraform.io/providers/humanitec/humanitec/latest/docs/resources/value) | resource |
121123
| [humanitec_value.backstage_humanitec_org](https://registry.terraform.io/providers/humanitec/humanitec/latest/docs/resources/value) | resource |
122124
| [humanitec_value.backstage_humanitec_token](https://registry.terraform.io/providers/humanitec/humanitec/latest/docs/resources/value) | resource |
125+
| [random_string.oidc_suffix](https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/string) | resource |
123126

124127
### Inputs
125128

examples/with-backstage/gcp-github.tf

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,12 @@ locals {
44
cloud_provider = "gcp"
55
}
66

7+
resource "random_string" "oidc_suffix" {
8+
length = 6
9+
special = false
10+
upper = false
11+
}
12+
713
# Create a role for GitHub Actions to push to GAR using OpenID Connect (OIDC) so we don't need to store GCP credentials in GitHub
814
# Reference https://docs.github.com/en/actions/deployment/security-hardening-your-deployments/configuring-openid-connect-in-google-cloud-platform
915

@@ -12,8 +18,8 @@ module "gh_oidc" {
1218
source = "terraform-google-modules/github-actions-runners/google//modules/gh-oidc"
1319
version = "~> 3.1"
1420
project_id = var.project_id
15-
pool_id = "htc-ref-arch"
16-
provider_id = "htc-ref-arch"
21+
pool_id = "htc-ref-arch-${resource.random_string.oidc_suffix.result}"
22+
provider_id = "htc-ref-arch-${resource.random_string.oidc_suffix.result}"
1723
attribute_mapping = {
1824
"google.subject" = "assertion.sub"
1925
"attribute.actor" = "assertion.actor"

examples/with-backstage/provider.tf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ terraform {
1212
source = "integrations/github"
1313
version = "~> 5.38"
1414
}
15+
random = {
16+
source = "hashicorp/random"
17+
version = "~> 3.5"
18+
}
1519
}
1620
required_version = ">= 1.3.0"
1721
}

0 commit comments

Comments
 (0)