Currently we are mapping manually repos details as below, meaning that we are adding every repos details manually for attribute.repository.
workload_identity_pool_attribute_mapping = {
"google.subject" = "assertion.sub"
"attribute.repository" = <<-EOT
{
"example-github-organization/example-repo": "true",
"example-github-organization/example-repo-1": "true"
}[assertion.repository]
EOT
}
Now we've requirement that want to reuse below output details into another repo to map the string for GCP workload_identity_pool_attribute_mapping.
as we've a Github repo where we're maintaining our github repos centrally and created Output to save those details into terraform output, as below.
{"outputs": {
"git_repos": {
"value": [
"example-repo",
"example-repo-1",
],
"type": [
"tuple",
[
"string",
"string"
]
]
}
}
}
Want to reuse those output details as a input for another repos for mapping.
Tried multiple approach to fill the request but not able to not able fulfill the requirement.
data "google_client_config" "current" {
}
data "terraform_remote_state" "repo" {
backend = "gcs"
config = {
bucket = var.tfstate_bucket
prefix = "example-project"
access_token = data.google_client_config.current.access_token
}
}
Expected result is that if any changes on repos list it has to add newly created repo into attribute.repository. Here example-github-organization is using to same for each repo and all repos name is going to start with example.
workload_identity_pool_attribute_mapping = {
"google.subject" = "assertion.sub"
"attribute.repository" = <<-EOT
{
"example-github-organization/example-repo": "true",
"example-github-organization/example-repo-1": "true"
}[assertion.repository]
EOT
}
I'm new to terraform please forgive me if i didn't follow the right format
Here is the solution which will help you add a string into jsonencode