-
Notifications
You must be signed in to change notification settings - Fork 724
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
use remote state to read data from previous steps #782
Changes from all commits
58184da
3f1164f
ec1427e
d909f5b
3eb48ef
7bd8f35
3a20bdf
e56803e
c9ffd76
15da669
c107e82
375a85b
a352703
4077aa3
8bb1a44
64ae323
13dd1f5
432dbfa
ba40a20
dbc360e
58db361
51bc453
9d15021
2886dba
df858ea
c96d661
7d2647a
05e567a
03ecd12
5378ee2
c8ec10c
28d7f94
8d17600
c763021
5f44161
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -67,6 +67,21 @@ locals { | |
"roles/compute.xpnAdmin", | ||
], | ||
} | ||
|
||
granular_sa_seed_project = { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's add a comment here this will allow individual stages to access state for all other stages (incase users want to restrict this) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Good catch. actually, these roles are redundant with the role to be able to revoke the access of the others service accounts to one of the state buckets, we will need to:
@bharathkkb should we do this change? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I see, I think we can keep this in the PR now and track it in a separate PR. My hope with the workspace module was in the future we can split this out for more granular permissions. |
||
"org" = [ | ||
"roles/storage.objectAdmin", | ||
], | ||
"env" = [ | ||
"roles/storage.objectAdmin" | ||
], | ||
"net" = [ | ||
"roles/storage.objectAdmin", | ||
], | ||
"proj" = [ | ||
"roles/storage.objectAdmin", | ||
], | ||
} | ||
} | ||
|
||
resource "google_service_account" "terraform-env-sa" { | ||
|
@@ -97,6 +112,16 @@ module "parent_iam_member" { | |
roles = each.value | ||
} | ||
|
||
module "project_iam_member" { | ||
source = "./modules/parent-iam-member" | ||
for_each = local.granular_sa_seed_project | ||
|
||
member = "serviceAccount:${google_service_account.terraform-env-sa[each.key].email}" | ||
parent_type = "project" | ||
parent_id = module.seed_bootstrap.seed_project_id | ||
roles = each.value | ||
} | ||
|
||
resource "google_billing_account_iam_member" "tf_billing_user" { | ||
for_each = local.granular_sa | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
/** | ||
* Copyright 2022 Google LLC | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
// These values are retrieved from the saved terraform state of the execution | ||
// of step 0-bootstrap using the terraform_remote_state data source. | ||
// These values can be overridden here if needed. | ||
// Some values, like org_id, parent_folder, and parent, must be consistent in all steps. | ||
locals { | ||
daniel-cit marked this conversation as resolved.
Show resolved
Hide resolved
|
||
org_id = data.terraform_remote_state.bootstrap.outputs.common_config.org_id | ||
parent_folder = data.terraform_remote_state.bootstrap.outputs.common_config.parent_folder | ||
parent = data.terraform_remote_state.bootstrap.outputs.common_config.parent_id | ||
billing_account = data.terraform_remote_state.bootstrap.outputs.common_config.billing_account | ||
default_region = data.terraform_remote_state.bootstrap.outputs.common_config.default_region | ||
project_prefix = data.terraform_remote_state.bootstrap.outputs.common_config.project_prefix | ||
folder_prefix = data.terraform_remote_state.bootstrap.outputs.common_config.folder_prefix | ||
} | ||
|
||
data "terraform_remote_state" "bootstrap" { | ||
backend = "gcs" | ||
|
||
config = { | ||
bucket = var.backend_bucket | ||
prefix = "terraform/bootstrap/state" | ||
} | ||
} |
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.
nit: After this is merged lets update docs to call out how we will use this common config created here though out the rest of SFB.