-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
create MI and federated credential for each branch defined in gh_repos (
- Loading branch information
1 parent
5e6ca72
commit 1b68354
Showing
5 changed files
with
39 additions
and
12 deletions.
There are no files selected for viewing
12 changes: 9 additions & 3 deletions
12
terraform/subscriptions/s941/dev/federatedcredential/main.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,15 @@ | ||
locals { | ||
userassignedidentities = local.external_outputs.userassignedidentity.data | ||
gh_repo_branch_combinations = local.external_outputs.global.data.gh_repo_branch_combinations | ||
} | ||
|
||
module "federatedcredential" { | ||
for_each = local.userassignedidentities | ||
source = "../../../modules/federatedcredential" | ||
parent_id = local.external_outputs.userassignedidentity.data.id | ||
parent_id = each.value.data.id | ||
audiences = ["api://AzureADTokenExchange"] | ||
name = "radix-canary-master" | ||
name = each.key | ||
issuer = "https://token.actions.githubusercontent.com" | ||
subject = "repo:equinor/radix-canary:ref:refs/heads/master" | ||
subject = "repo:equinor/${local.gh_repo_branch_combinations[each.key].repo}:ref:refs/heads/${local.gh_repo_branch_combinations[each.key].branch}" | ||
resource_group_name = local.external_outputs.common.data.resource_group | ||
} |
2 changes: 1 addition & 1 deletion
2
terraform/subscriptions/s941/dev/federatedcredential/outputs.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
output "data" { | ||
value = module.federatedcredential.data | ||
value = module.federatedcredential | ||
} |
18 changes: 14 additions & 4 deletions
18
terraform/subscriptions/s941/dev/userassignedidentity/main.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,20 @@ | ||
locals { | ||
aad_radix_group = local.external_outputs.global.data.aad_radix_group | ||
environment = local.external_outputs.clusters.data.enviroment | ||
gh_repo_branch_combinations = local.external_outputs.global.data.gh_repo_branch_combinations | ||
gh_repos = local.external_outputs.global.data.gh_repos | ||
location = local.external_outputs.common.data.location | ||
resource_group = local.external_outputs.common.data.resource_group | ||
} | ||
|
||
data "azuread_group" "radix_group" { | ||
display_name = local.external_outputs.global.data.aad_radix_group | ||
display_name = local.aad_radix_group | ||
} | ||
|
||
module "userassignedidentity" { | ||
for_each = local.gh_repo_branch_combinations | ||
source = "../../../modules/userassignedidentity" | ||
name = "id-radix-github-workflows-1-${local.external_outputs.clusters.data.enviroment}-test" | ||
resource_group_name = "${local.external_outputs.common.data.resource_group}" | ||
location = "${local.external_outputs.common.data.location}" | ||
name = "id-radix-github-workflows-${each.value.name}" | ||
resource_group_name = local.resource_group | ||
location = local.location | ||
} |
2 changes: 1 addition & 1 deletion
2
terraform/subscriptions/s941/dev/userassignedidentity/outputs.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
output "data" { | ||
value = module.userassignedidentity.data | ||
value = module.userassignedidentity | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,23 @@ | ||
locals { | ||
gh_repos = { | ||
"radix-canary" : ["release", "master"] | ||
} | ||
|
||
outputs = { | ||
tenant_id = "3aa4a235-b6e2-48d5-9195-7fcf05b459b0" | ||
subscription_id = "16ede44b-1f74-40a5-b428-46cca9a5741b" | ||
client_id = "f1e6bc52-9aa4-4ca7-a9ac-b7a19d8f0f86" | ||
subscription_shortname = "s941" | ||
aad_radix_group = "radix" | ||
github_repos = { | ||
"radix_canary" : ["release", "master"] | ||
} | ||
gh_repos = local.gh_repos | ||
gh_repo_branch_combinations = { for item in flatten([ | ||
for repo, branches in local.gh_repos : [ | ||
for branch in branches : { | ||
name = "${repo}-${branch}" | ||
repo = repo | ||
branch = branch | ||
} | ||
] | ||
]) : item.name => item } | ||
} | ||
} |