cloud-foundation-fabric/foundations/environments/README.md

65 lines
4.6 KiB
Markdown
Raw Normal View History

Organization sample: environments (Almanac bootstrap port) * add gitignore file * data and infra skeletons * org skeleton * org environments sample skeleton * Organization teams sample skeleton. * Organization env sample GCS for tf state. * org env: service accounts and GCS roles * org env: folders * org env: audit export * org env: shared project * org env: switch to released 3.1.0 project module version * rename organization top-level folder to organization-bootstrap * org env: use folders module with better outputs, module outputs * org env: switch the service accounts module to v2.0.0. * Merge ludo's branch from forked repo (#2) * org env: update gcs, sa, project modules * Use correct folder ID in format without prefix * org env: update folders module version, improve comments * org env: initial work on README, diagram, add variable for xpn roles * org env: update roles in README, backend file * org env: README changes * org env: README changes * org env: README changes * org env: README changes * org env: add IAM variables for audit and shared projects * org env: address README TODOs * org env: minor README changes * org env: minor README changes * org env: minor README changes * org env: simplify the sample's README by moving general considerations into the section README * Org examples README changes * org env: simplify initial state management, add comment for shared folder * org env: change state instructions to copy and rename instead of renaming backend file * org env: add a section in the README file to explain shared services, and detail options * fix comment for shared services project
2019-09-06 20:44:24 -07:00
# Environment-based organizational sample
This sample creates an organizational layout with a single level, where each folder is usually mapped to one infrastructure environment (test, dev, etc.). It also sets up all prerequisites for automation (GCS state buckets, service accounts, etc.), and the correct roles on those to enforce separation of duties at the environment level.
This layout is well suited for medium-sized infrastructures managed by a small set of teams, where the complexity in application resource ownership and access roles is mostly dealt with at the project level, and/or in the individual services (GKE, Cloud SQL, etc.). Its simplicity also makes it a good starting point for more complex or specialized layouts.
![High-level diagram](diagram.png "High-level diagram")
Refer to the [section-level README](../README.md) for general considerations about this type of samples, and usage instructions.
## Managed resources and services
This sample creates several distinct groups of resources:
- one folder per environment
- one top-level project to hold Terraform-related resources
- one top-level project to set up and host centralized audit log exports (optional)
- one top-level shared services project
The number of resources in this sample is kept to a minimum so as to make it more generally applicable, further resources can be easily added by leveraging the full array of [Cloud Foundation Toolkit modules](https://github.com/terraform-google-modules), especially in the shared services project.
## Shared services project
This sample contains a single, top-level project used to host services shared across environments (eg GCS, GCR, KMS, Cloud Build, etc.). In our experience, that is enough for many customers, especially those using this organizational layout.
For more complex setups where multiple shared services projects are needed to encapsulate a larger number of resources, shared services should be treated as an extra environment so that they can be managed by a dedicated set of Terraform files, using a separate service account and GCS bucket, with a folder to contain shared projects.
If no shared services are needed, the shared service project module can of course be removed from `main.tf`.
<!-- BEGINNING OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
## Inputs
| Name | Description | Type | Default | Required |
|------|-------------|:----:|:-----:|:-----:|
| audit\_viewers | Audit project viewers, in IAM format. | list | `<list>` | no |
| billing\_account\_id | Billing account id used as default for new projects. | string | n/a | yes |
| environments | Environment short names. | list(string) | n/a | yes |
| gcs\_location | GCS bucket location. | string | `"EU"` | no |
| generate\_service\_account\_keys | Generate and store service account keys in the state file. | string | `"false"` | no |
| grant\_xpn\_folder\_roles | Grant roles needed for Shared VPC creation to service accounts at the environment folder level. | string | `"true"` | no |
| grant\_xpn\_org\_roles | Grant roles needed for Shared VPC creation to service accounts at the organization level. | string | `"false"` | no |
Organization sample: environments (Almanac bootstrap port) * add gitignore file * data and infra skeletons * org skeleton * org environments sample skeleton * Organization teams sample skeleton. * Organization env sample GCS for tf state. * org env: service accounts and GCS roles * org env: folders * org env: audit export * org env: shared project * org env: switch to released 3.1.0 project module version * rename organization top-level folder to organization-bootstrap * org env: use folders module with better outputs, module outputs * org env: switch the service accounts module to v2.0.0. * Merge ludo's branch from forked repo (#2) * org env: update gcs, sa, project modules * Use correct folder ID in format without prefix * org env: update folders module version, improve comments * org env: initial work on README, diagram, add variable for xpn roles * org env: update roles in README, backend file * org env: README changes * org env: README changes * org env: README changes * org env: README changes * org env: add IAM variables for audit and shared projects * org env: address README TODOs * org env: minor README changes * org env: minor README changes * org env: minor README changes * org env: simplify the sample's README by moving general considerations into the section README * Org examples README changes * org env: simplify initial state management, add comment for shared folder * org env: change state instructions to copy and rename instead of renaming backend file * org env: add a section in the README file to explain shared services, and detail options * fix comment for shared services project
2019-09-06 20:44:24 -07:00
| organization\_id | Organization id. | string | n/a | yes |
| prefix | Prefix used for resources that need unique names. | string | n/a | yes |
| project\_services | Service APIs enabled by default in new projects. | list | `<list>` | no |
| root\_node | Root node for the new hierarchy, either 'organizations/org_id' or 'folders/folder_id'. | string | n/a | yes |
| shared\_bindings\_members | List of comma-delimited IAM-format members for the additional shared project bindings. | list | `<list>` | no |
| shared\_bindings\_roles | List of roles for additional shared project bindings. | list | `<list>` | no |
| terraform\_owners | Terraform project owners, in IAM format. | list | `<list>` | no |
## Outputs
| Name | Description |
|------|-------------|
| audit\_logs\_bq\_dataset | Bigquery dataset for the audit logs export. |
| audit\_logs\_project | Project that holds the audit logs export resources. |
| bootstrap\_tf\_gcs\_bucket | GCS bucket used for the bootstrap Terraform state. |
| environment\_folders | Top-level environment folders. |
| environment\_service\_account\_keys | Service account keys used to run each environment Terraform modules. |
| environment\_service\_accounts | Service accounts used to run each environment Terraform modules. |
| environment\_tf\_gcs\_buckets | GCS buckets used for each environment Terraform state. |
| shared\_resources\_project | Project that holdes resources shared across environments. |
| terraform\_project | Project that holds the base Terraform resources. |
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->