Skip to content

Commit

Permalink
Create tf stack to apply all capa controller roles CF stacks
Browse files Browse the repository at this point in the history
  • Loading branch information
iuriaranda committed Dec 18, 2024
1 parent d6c1c58 commit bed82ef
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 3 deletions.
46 changes: 46 additions & 0 deletions aws-account-setup/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
locals {
mc_account_flat = flatten([
for mc_name, mc in var.management_clusters : [
for account in mc.aws_account : {
name = mc_name
aws_account = account
oidc_provider_domain = mc.oidc_provider_domain
}
]
])

mc_account_map = {
for i in local.mc_account_flat : "${i.name}-${i.aws_account.account_id}" => i
}
}

provider "aws" {
alias = "main"
region = each.value.aws_account.region
for_each = local.mc_account_map

assume_role {
role_arn = "arn:${each.value.aws_account.aws_partition}:iam::${each.value.aws_account.account_id}:role/GiantSwarmAdmin"
}
}

module "capa_controller_role" {
source = "../capa-controller-role"
for_each = local.mc_account_map
providers = {
aws = aws.main[each.key]
}

installation_name = each.value.name
management_cluster_oidc_provider_domain = each.value.oidc_provider_domain
byovpc = each.value.aws_account.byovpc
# gs_user_account = TODO

# TBD
# additional_policies = each.value.aws_account.additional_policies
# additional_policies_arns = each.value.aws_account.additional_policies_arns
}

output "mc_account_setup" {
value = {for k, v in module.mc_account_setup : k => v}
}
13 changes: 13 additions & 0 deletions aws-account-setup/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
variable "management_clusters" {
type = map(object({
aws_account = list(object({
account_id = string
region = string
aws_partition = string
byovpc = bool
additional_policies = list(string)
additional_policies_arns = list(string)
})),
oidc_provider_domain = string
}))
}
9 changes: 6 additions & 3 deletions capa-controller-role/giantswarm-capa-role.tf
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,12 @@ locals {
}
}

provider "aws" {
ignore_tags {
keys = ["maintainer", "owner", "repo"]
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "5.81.0"
}
}
}

Expand Down

0 comments on commit bed82ef

Please sign in to comment.