-
Notifications
You must be signed in to change notification settings - Fork 973
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add ability to refer to other project service accounts in Project Factory #2900
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this approach, it's lean and tries incremental matches. I would put own service accounts first, then other projects, then context.
I don't really grasp your TODO though, can you explain it?
The idea is to feed all "local" context into diff --git a/modules/project-factory/main.tf b/modules/project-factory/main.tf
index 736bfb093..1e5416684 100644
--- a/modules/project-factory/main.tf
+++ b/modules/project-factory/main.tf
@@ -20,21 +20,25 @@ locals {
context = {
folder_ids = merge(
var.factories_config.context.folder_ids,
local.hierarchy
)
iam_principals = merge(
var.factories_config.context.iam_principals,
{
for k, v in module.automation-service-accounts :
k => v.iam_email
- }
+ },
+ {
+ for k, v in module.service-accounts :
+ k => v.iam_email
+ },
)
}
}
@@ -112,29 +116,23 @@ module "projects-iam" {
iam = {
for k, v in lookup(each.value, "iam", {}) : k => [
for vv in v : try(
- # other projects service accounts
- module.service-accounts[vv].iam_email,
- # other automation service account
- local.context.iam_principals[vv],
- # project service accounts
- module.service-accounts["${each.key}/${vv}"].iam_email,
- # automation service account
+ # project service account
local.context.iam_principals["${each.key}/${vv}"],
- # other context
+ # other projects and external context
local.context.iam_principals[vv],
# passthrough
vv
)
]
} And replicate above change in other 2 Question is what to do about buckets: module "buckets" {
...
iam = {
for k, v in each.value.iam : k => [
for vv in v : try(
# other projects service accounts
module.service-accounts[vv].iam_email,
module.service-accounts["${each.value.project}/${vv}"].iam_email,
var.factories_config.context.iam_principals[vv],
vv
)
]
} Should this use exactly the same construct, as we use for |
Ok I get it and it makes sense. :)
There's a very delicate balance with dependency cycles. If it's excluded it's usually because I ran into a cycle. I broke up the project module to avoid some, but at some point we need to draw a line. :) Try, and see what you get. We need a "golden set" of patterns in YAML to test against, I don't think we have one for the new approach of using in-project buckets and service accounts. I would not merge without testing though, I can help you compile a set of YAMLs tomorrow if you want. |
bb43d22
to
ca1134e
Compare
9288f33
to
ee3eb98
Compare
96ded3c
to
523845c
Compare
523845c
to
ddaf830
Compare
🎉 |
Nice even number |
shared_vpc_service_config.network_users
(also other projects, just to keep the code the same, though it doesn't make much sense)extra_dirs
for tfvars testsChecklist
I applicable, I acknowledge that I have:
terraform fmt
on all modified filestools/tfdoc.py
Breaking Changes