You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As mentioned above, this stage only does the bare minimum required to bootstrap automation, and ensure that base audit and billing exports are in place from the start to provide some measure of accountability, even before the security configurations are applied in a later stage.
@@ -80,7 +102,7 @@ The convention is used in its full form only for specific resources with globall
80
102
81
103
The [Customizations](#names-and-naming-convention) section on names below explains how to configure tokens, or implement a different naming convention.
82
104
83
-
## Workload Identity Federation and CI/CD
105
+
###Workload Identity Federation and CI/CD
84
106
85
107
This stage also implements initial support for two interrelated features
86
108
@@ -124,7 +146,7 @@ To quickly self-grant the above roles, run the following code snippet as the ini
124
146
export FAST_BU=$(gcloud config list --format 'value(core.account)')
125
147
126
148
# find and set your org id
127
-
gcloud organizations list --filter display_name:$partofyourdomain
149
+
gcloud organizations list
128
150
export FAST_ORG_ID=123456
129
151
130
152
# set needed roles
@@ -139,25 +161,6 @@ done
139
161
140
162
Then make sure the same user is also part of the `gcp-organization-admins` group so that impersonating the automation service account later on will be possible.
141
163
142
-
#### Billing account in a different organization
143
-
144
-
If you are using a billing account belonging to a different organization (e.g. in multiple organization setups), some initial configurations are needed to ensure the identities running this stage can assign billing-related roles.
145
-
146
-
If the billing organization is managed by another version of this stage, we leverage the `organizationIamAdmin` role created there, to allow restricted granting of billing roles at the organization level.
147
-
148
-
If that's not the case, an equivalent role needs to exist, or the predefined `resourcemanager.organizationAdmin` role can be used if not managed authoritatively. The role name then needs to be manually changed in the `billing.tf` file, in the `google_organization_iam_binding` resource.
149
-
150
-
The identity applying this stage for the first time also needs two roles in billing organization, they can be removed after the first `apply` completes successfully:
If you are using a standalone billing account, the identity applying this stage for the first time needs to be a billing account administrator:
@@ -187,7 +190,7 @@ Please note that FAST also supports an additional group for users with permissio
187
190
Then make sure you have configured the correct values for the following variables by providing a `terraform.tfvars` file:
188
191
189
192
-`billing_account`
190
-
an object containing `id` as the id of your billing account, derived from the Cloud Console UI or by running `gcloud beta billing accounts list`, and `organization_id` as the id of the organization owning it, or `null` to use the billing account in isolation
193
+
an object containing `id` as the id of your billing account, derived from the Cloud Console UI or by running `gcloud beta billing accounts list`, and the `is_org_level` flag that controls whether organization or account-level bindings are used, and a billing export project and dataset are created
191
194
-`groups`
192
195
the name mappings for your groups, if you're following the default convention you can leave this to the provided default
@@ -202,7 +205,6 @@ You can also adapt the example that follows to your needs:
202
205
# if you have too many accounts, check the Cloud Console :)
203
206
billing_account = {
204
207
id = "012345-67890A-BCDEF0"
205
-
organization_id = 1234567890
206
208
}
207
209
208
210
# use `gcloud organizations list`
@@ -237,18 +239,18 @@ Below is the outline of the output files generated by all stages, which is ident
237
239
```bash
238
240
[path specified in outputs_location]
239
241
├── providers
240
-
│ ├── 00-bootstrap-providers.tf
241
-
│ ├── 01-resman-providers.tf
242
-
│ ├── 02-networking-providers.tf
243
-
│ ├── 02-security-providers.tf
244
-
│ ├── 03-project-factory-dev-providers.tf
245
-
│ ├── 03-project-factory-prod-providers.tf
246
-
│ └── 99-sandbox-providers.tf
242
+
│ ├── 0-bootstrap-providers.tf
243
+
│ ├── 1-resman-providers.tf
244
+
│ ├── 2-networking-providers.tf
245
+
│ ├── 2-security-providers.tf
246
+
│ ├── 3-project-factory-dev-providers.tf
247
+
│ ├── 3-project-factory-prod-providers.tf
248
+
│ └── 9-sandbox-providers.tf
247
249
└── tfvars
248
-
│ ├── 00-bootstrap.auto.tfvars.json
249
-
│ ├── 01-resman.auto.tfvars.json
250
-
│ ├── 02-networking.auto.tfvars.json
251
-
│ └── 02-security.auto.tfvars.json
250
+
│ ├── 0-bootstrap.auto.tfvars.json
251
+
│ ├── 1-resman.auto.tfvars.json
252
+
│ ├── 2-networking.auto.tfvars.json
253
+
│ └── 2-security.auto.tfvars.json
252
254
└── workflows
253
255
└── [optional depending on the configured CI/CD repositories]
254
256
```
@@ -267,17 +269,34 @@ terraform apply \
267
269
268
270
> If you see an error related to project name already exists, please make sure the project name is unique or the project was not deleted recently
269
271
270
-
Once the initial `apply` completes successfully, configure a remote backend using the new GCS bucket, and impersonation on the automation service account for this stage. To do this you can use the generated `providers.tf` file if you have configured output files as described above, or extract its contents from Terraform's output, then migrate state with `terraform init`:
272
+
Once the initial `apply` completes successfully, configure a remote backend using the new GCS bucket, and impersonation on the automation service account for this stage. To do this you can use the generated `providers.tf` file from either
273
+
274
+
- the local filesystem if you have configured output files as described above
275
+
- the GCS bucket where output files are always stored
276
+
- Terraform outputs (not recommended as it's more complex)
277
+
278
+
The following two snippets show how to leverage the `stage-links.sh` script in the root FAST folder to fetch the commands required for output files linking or copying, using either the local output folder configured via Terraform variables, or the GCS bucket which can be derived from the `automation` output.
279
+
280
+
```bash
281
+
../../stage-links.sh ~/fast-config
282
+
283
+
# copy and paste the following commands for '0-bootstrap'
# migrate state to GCS bucket configured in providers file
279
299
terraform init -migrate-state
280
-
# run terraform apply to remove the bootstrap_user iam binding
281
300
terraform apply
282
301
```
283
302
@@ -334,7 +353,7 @@ You can customize organization-level logs through the `log_sinks` variable in tw
334
353
- creating additional log sinks to capture more logs
335
354
- changing the destination of captured logs
336
355
337
-
By default, all logs are exported to Bigquery, but FAST can create sinks to Cloud Logging Buckets, GCS, or PubSub.
356
+
By default, all logs are exported to a log bucket, but FAST can create sinks to BigQuery, GCS, or PubSub.
338
357
339
358
If you need to capture additional logs, please refer to GCP's documentation on [scenarios for exporting logging data](https://cloud.google.com/architecture/exporting-stackdriver-logging-for-security-and-access-analytics), where you can find ready-made filter expressions for different use cases.
Despite its simplicity, this stage implements the basics of a design that we've seen working well for a variety of customers, where the hierarchy is laid out following two conceptually different approaches:
@@ -54,51 +70,49 @@ It's of course possible to run this stage in isolation, but that's outside the s
54
70
55
71
Before running this stage, you need to make sure you have the correct credentials and permissions, and localize variables by assigning values that match your configuration.
56
72
57
-
### Providers configuration
58
-
59
-
The default way of making sure you have the right permissions, is to use the identity of the service account pre-created for this stage during bootstrap, and that you are a member of the group that can impersonate it via provider-level configuration (`gcp-devops` or `organization-admins`).
73
+
### Provider and Terraform variables
60
74
61
-
To simplify setup, the previous stage pre-configures a valid providers file in its output, and optionally writes it to a local file if the `outputs_location` variable is set to a valid path.
75
+
As all other FAST stages, the [mechanism used to pass variable values and pre-built provider files from one stage to the next](../0-bootstrap/README.md#output-files-and-cross-stage-variables)is also leveraged here.
62
76
63
-
If you have set a valid value for `outputs_location`in the bootstrap stage (see the [bootstrap stage README](../0-bootstrap/#output-files-and-cross-stage-variables) for more details), simply link the relevant `providers.tf` file from this stage's folder in the path you specified:
77
+
The commands to link or copy the provider and terraform variable files can be easily derived from the `stage-links.sh` script in the FAST root folder, passing it a single argument with the local outputfiles folder (if configured) or the GCS output bucket in the automation project (derived from stage 0 outputs). The following examples demonstrate both cases, and the resulting commands that then need to be copy/pasted and run.
If you want to continue to rely on `outputs_location` logic, create a `terraform.tfvars` file and configure it as described [here](../0-bootstrap/#output-files-and-cross-stage-variables).
- variables shared by other stages (org id, billing account id, etc.), or derived from a resource managed by a different stage (folder id, automation project id, etc.)
85
-
- variables specific to resources managed by this stage
99
+
### Impersonating the automation service account
86
100
87
-
To avoid the tedious job of filling in the first group of variable with values derived from other stages' outputs, the same mechanism used above for the provider configuration can be used to leverage pre-configured `.tfvars` files.
101
+
The preconfigured provider file uses impersonation to run with this stage's automation service account's credentials. The `gcp-devops` and `organization-admins` groups have the necessary IAM bindings in place to do that, so make sure the current user is a member of one of those groups.
88
102
89
-
If you configured a valid path for `outputs_location` in the bootstrap stage, simply link the relevant `*.auto.tfvars.json` files from the outputs folder. For this stage, you need the `globals.auto.tfvars.json` file containing global values compiled manually for the bootstrap stage, and `0-bootstrap.auto.tfvars.json` containing values derived from resources managed by the bootstrap stage:
Variables in this stage -- like most other FAST stages -- are broadly divided into three separate sets:
106
+
107
+
- variables which refer to global values for the whole organization (org id, billing account id, prefix, etc.), which are pre-populated via the `globals.auto.tfvars.json` file linked or copied above
108
+
- variables which refer to resources managed by previous stage, which are prepopulated here via the `0-bootstrap.auto.tfvars.json` file linked or copied above
109
+
- and finally variables that optionally control this stage's behaviour and customizations, and can to be set in a custom `terraform.tfvars` file
96
110
97
-
A second set of variables is specific to this stage, they are all optional so if you need to customize them, create an extra `terraform.tfvars` file.
111
+
The latter set is explained in the [Customization](#customizations) sections below, and the full list can be found in the [Variables](#variables) table at the bottom of this document.
98
112
99
-
Refer to the [Variables](#variables) table at the bottom of this document, for a full list of variables, their origin (e.g. a stage or specific to this one), and descriptions explaining their meaning. The sections below also describe some of the possible customizations. For billing configurations, refer to the [Bootstrap documentation on billing](../0-bootstrap/README.md#billing-account) as the `billing_account` variable is identical across all stages.
113
+
### Running the stage
100
114
101
-
Once done, you can run this stage:
115
+
Once provider and variable values are in place and the correct user is configured, the stage can be run:
102
116
103
117
```bash
104
118
terraform init
@@ -139,9 +153,9 @@ This allows to centralize the minimum set of resources to delegate control of ea
139
153
140
154
### Organization policies
141
155
142
-
Organization policies are laid out in an explicit manner in the `organization.tf` file, so it's fairly easy to add or remove specific policies.
156
+
Organization policies leverage -- with one exception -- the built-in factory implemented in the organization module, and configured via the yaml files in the `data` folder. To edit organization policies, check and edit the files there.
143
157
144
-
For policies where additional data is needed, a root-level `organization_policy_configs` variable allows passing in specific data. Its built-in use to add additional organizations to the [Domain Restricted Sharing](https://cloud.google.com/resource-manager/docs/organization-policy/restricting-domains) policy, can be taken as an example on how to leverage it for additional customizations.
158
+
The one exception is [Domain Restricted Sharing](https://cloud.google.com/resource-manager/docs/organization-policy/restricting-domains), which is made dynamic and implemented in code so as to auto-add the current organization's customer id. The `organization_policy_configs` variable allow to easily add ids from third party organizations if needed.
0 commit comments