|
| 1 | +# Implementation Guide (Enterprise) |
| 2 | + |
| 3 | +This guide explains why the stack exists, what each component does, why enterprises adopt this pattern, and the step-by-step implementation flow. |
| 4 | + |
| 5 | +## Why this stack is required |
| 6 | + |
| 7 | +Enterprises adopting Apigee X face the same problems: |
| 8 | + |
| 9 | +- Platform setup is fragmented across scripts, consoles, and partial Terraform examples. |
| 10 | +- Networking prerequisites and service networking peering are easy to misconfigure. |
| 11 | +- Security teams require least-privilege IAM, auditability, and CMEK where available. |
| 12 | +- Platform teams need consistent, repeatable rollouts across dev/test/prod. |
| 13 | + |
| 14 | +This stack addresses those issues by providing a single, opinionated baseline that is: |
| 15 | + |
| 16 | +- Secure-by-default |
| 17 | +- Repeatable across environments |
| 18 | +- Clear about dependencies and ordering |
| 19 | +- Compatible with Stacks or plain Terraform |
| 20 | + |
| 21 | +## What it does (component by component) |
| 22 | + |
| 23 | +### Networking |
| 24 | + |
| 25 | +- Enables required APIs for Apigee and Service Networking. |
| 26 | +- Creates a dedicated VPC for Apigee (or can be adapted for Shared VPC). |
| 27 | +- Reserves a peering range and establishes the Service Networking connection. |
| 28 | + |
| 29 | +### Apigee Organization |
| 30 | + |
| 31 | +- Creates the Apigee org bound to the GCP project. |
| 32 | +- Connects the org to the authorized network (VPC peering) for runtime. |
| 33 | +- Optionally sets CMEK for org runtime DB encryption. |
| 34 | + |
| 35 | +### Instances (runtime) |
| 36 | + |
| 37 | +- Creates Apigee runtime instances in one or more regions. |
| 38 | +- Optionally configures instance-level CMEK. |
| 39 | + |
| 40 | +### Environments and Attachments |
| 41 | + |
| 42 | +- Creates Apigee environments (dev/test/prod). |
| 43 | +- Attaches environments to one or more runtime instances. |
| 44 | + |
| 45 | +### Envgroups and Attachments |
| 46 | + |
| 47 | +- Creates envgroups with hostnames. |
| 48 | +- Attaches environments to envgroups to expose APIs. |
| 49 | + |
| 50 | +### IAM |
| 51 | + |
| 52 | +- Creates service accounts used by platform automation. |
| 53 | +- Binds project-level roles (least privilege by default). |
| 54 | + |
| 55 | +### KMS (CMEK) |
| 56 | + |
| 57 | +- Creates KMS key ring and crypto keys. |
| 58 | +- Optionally binds IAM to allow Apigee to use keys. |
| 59 | + |
| 60 | +## Why enterprises adopt this |
| 61 | + |
| 62 | +- **Compliance:** CMEK support and policy-as-code are mandatory for regulated industries. |
| 63 | +- **Governance:** Stacks and CI pipelines centralize approval gates and drift detection. |
| 64 | +- **Repeatability:** Standard patterns reduce on-call incidents and migration risk. |
| 65 | +- **Security:** Private ingress + least privilege IAM reduces attack surface. |
| 66 | + |
| 67 | +## Step-by-step implementation |
| 68 | + |
| 69 | +### 1) Decide deployment model |
| 70 | + |
| 71 | +- Use **Modules** for local runs and CI pipelines. |
| 72 | +- Use **Stacks** for multi-environment orchestration in Terraform Cloud/Enterprise. |
| 73 | + |
| 74 | +### 2) Select an example |
| 75 | + |
| 76 | +Single-region (recommended first): |
| 77 | + |
| 78 | +``` |
| 79 | +cd examples/single-region |
| 80 | +cp terraform.tfvars.example terraform.tfvars |
| 81 | +``` |
| 82 | + |
| 83 | +Multi-region HA: |
| 84 | + |
| 85 | +``` |
| 86 | +cd examples/multi-region-ha |
| 87 | +cp terraform.tfvars.example terraform.tfvars |
| 88 | +``` |
| 89 | + |
| 90 | +### 3) Configure required inputs |
| 91 | + |
| 92 | +- `project_id`, `region`, `analytics_region` |
| 93 | +- `network_name`, `peering_prefix_length` |
| 94 | +- `instance_name` or `primary_instance_name`/`secondary_instance_name` |
| 95 | +- `envgroup_hostnames` |
| 96 | + |
| 97 | +Optional (enterprise): |
| 98 | + |
| 99 | +- KMS key ring + crypto keys |
| 100 | +- IAM service accounts and project roles |
| 101 | + |
| 102 | +### 4) Run Terraform |
| 103 | + |
| 104 | +``` |
| 105 | +terraform init |
| 106 | +terraform plan |
| 107 | +terraform apply |
| 108 | +``` |
| 109 | + |
| 110 | +### 5) Validate outcomes |
| 111 | + |
| 112 | +- Apigee org exists and is bound to the VPC |
| 113 | +- Instances are active in the target regions |
| 114 | +- Environments are attached to instances |
| 115 | +- Envgroups are created and bound to hostnames |
| 116 | + |
| 117 | +### 6) Extend with runtime stack |
| 118 | + |
| 119 | +- Implement ingress, DNS, and observability in `stacks/runtime/components/*`. |
| 120 | +- Attach ingress to envgroups/hostnames. |
| 121 | + |
| 122 | +## Common pitfalls |
| 123 | + |
| 124 | +- Missing APIs (enable `apigee.googleapis.com` and `servicenetworking.googleapis.com`). |
| 125 | +- VPC peering range conflicts. |
| 126 | +- Missing IAM bindings for CMEK usage. |
| 127 | +- Incorrect attachment ordering (envs must exist before attachments). |
| 128 | + |
| 129 | +## Recommended next steps |
| 130 | + |
| 131 | +- Add CI pipelines (GitHub Actions or GitLab) using templates in `ci-templates/`. |
| 132 | +- Add policy gates with Conftest/OPA. |
| 133 | +- Split state per environment to reduce blast radius. |
0 commit comments