|
| 1 | +# GCP reference architecture with Backstage |
| 2 | + |
| 3 | +Provisions the GCP reference architecture connected to Humanitec and installs Backstage. |
| 4 | + |
| 5 | +## Prerequisites |
| 6 | + |
| 7 | +* The same prerequisites as the [base reference architecture](../../README.md#prerequisites), plus the following items. |
| 8 | +* A GitHub organization and permission to create new repositories in it. Go to https://github.com/account/organizations/new to create a new org (the "Free" option is fine). Note: is has to be an organization, a free account is not sufficient. |
| 9 | +* Create a classic github personal access token with `repo`, `workflow`, `delete_repo` and `admin:org` scope [here](https://github.com/settings/tokens). |
| 10 | +* Set the `GITHUB_TOKEN` environment variable to your token. |
| 11 | + ``` |
| 12 | + export GITHUB_TOKEN="my-github-token" |
| 13 | + ``` |
| 14 | +* Set the `GITHUB_ORG_ID` environment variable to your GitHub organization ID. |
| 15 | + ``` |
| 16 | + export GITHUB_ORG_ID="my-github-org-id" |
| 17 | + ``` |
| 18 | +* [Node.js](https://nodejs.org) installed locally. |
| 19 | +* Install the GitHub App for Backstage into your GitHub organization using `node create-gh-app/index.js`. Follow the instructions. |
| 20 | + * “All repositories” ~> Install |
| 21 | + * “Okay, […] was installed on the […] account.” ~> You can close the window and server. |
| 22 | + |
| 23 | +## Usage |
| 24 | + |
| 25 | +Follow the same steps as for the [base layer](../../README.md#usage), applying these modifications: |
| 26 | +* Execute `cd ./examples/with-backstage` after cloning the repo. Execute all subsequent commands in this directory. |
| 27 | +* In particular, use the `./examples/with-backstage/terraform.tfvars.example` file as the basis for your `terraform.tfvars` file. It defines additional variables needed to setup and configure Backstage. |
| 28 | + |
| 29 | +## Verify your result |
| 30 | + |
| 31 | +Check for the existence of key elements of the backstage module. This is a subset of all elements only. For a complete list of what was installed, review the Terraform code. |
| 32 | + |
| 33 | +1. Perform the [verification steps of the base installation](../../README.md) if you have not already done so. |
| 34 | +2. Verify the existence of the Backstage Application in your Humanitec Organization: |
| 35 | + ``` |
| 36 | + curl -s https://api.humanitec.io/orgs/${HUMANITEC_ORG}/apps/backstage \ |
| 37 | + --header "Authorization: Bearer ${HUMANITEC_TOKEN}" |
| 38 | + ``` |
| 39 | + This should output a JSON formatted representation of the Application like so: |
| 40 | + ``` |
| 41 | + {"id":"backstage","name":"backstage","created_at":"2023-10-02T13:44:27Z","created_by":"s-d3e94a0e-8b53-29f9-b666-27548b7e06e0","envs":[{"id":"development","name":"Development","type":"development"}]} |
| 42 | + ``` |
| 43 | + You can also check for the Application in the [Humanitec Platform Orchestrator UI](https://app.humanitec.io). |
| 44 | + |
| 45 | +3. Connect to your GKE cluster via `kubectl`. See the [GKE documentation](https://cloud.google.com/kubernetes-engine/docs/how-to/cluster-access-for-kubectl) or use this command: |
| 46 | + ``` |
| 47 | + gcloud container clusters get-credentials --location <my-gcp-region> --name ref-arch |
| 48 | + ``` |
| 49 | +4. Get the elements in the newly created Kubernetes namespace: |
| 50 | + ``` |
| 51 | + kubectl get all -n backstage-development |
| 52 | + ``` |
| 53 | + You should see |
| 54 | + - a `deployment`, `replicaset`, running `pod`, and `service` for Backstage |
| 55 | + - a `statefulset`, running `pod`, and `service` for PostgreSQL database used by Backstage. |
| 56 | + |
| 57 | + Note: it may take up to ten minutes after the `terraform apply` completed until you actually see those resources. The Backstage application needs to built and deployed via a GitHub action out of the newly created repository in your GitHub organization. |
| 58 | + |
| 59 | + |
| 60 | +## Cleaning up |
| 61 | + |
| 62 | +Once you are finished with the reference architecture, you can remove all provisioned infrastructure and the resource definitions created in Humanitec with the following: |
| 63 | + |
| 64 | +1. Delete all Humanitec applications scaffolded using Backstage, but not the `backstage` app itself. |
| 65 | + |
| 66 | +2. Follow the [base reference architecture cleanup instructions](../../README.md#cleaning-up). |
| 67 | + |
| 68 | +## Terraform docs |
| 69 | + |
| 70 | +<!-- BEGIN_TF_DOCS --> |
| 71 | +### Requirements |
| 72 | + |
| 73 | +| Name | Version | |
| 74 | +|------|---------| |
| 75 | +| terraform | >= 1.3.0 | |
| 76 | +| github | ~> 5.38 | |
| 77 | +| google | ~> 5.1 | |
| 78 | +| humanitec | ~> 0.13 | |
| 79 | + |
| 80 | +### Providers |
| 81 | + |
| 82 | +| Name | Version | |
| 83 | +|------|---------| |
| 84 | +| github | ~> 5.38 | |
| 85 | +| google | ~> 5.1 | |
| 86 | +| google-beta | n/a | |
| 87 | +| humanitec | ~> 0.13 | |
| 88 | + |
| 89 | +### Modules |
| 90 | + |
| 91 | +| Name | Source | Version | |
| 92 | +|------|--------|---------| |
| 93 | +| backstage\_mysql | git::https://github.com/humanitec-architecture/resource-packs-in-cluster.git//humanitec-resource-defs/mysql/basic | n/a | |
| 94 | +| backstage\_postgres | git::https://github.com/humanitec-architecture/resource-packs-in-cluster.git//humanitec-resource-defs/postgres/basic | n/a | |
| 95 | +| base | ../../modules/base | n/a | |
| 96 | + |
| 97 | +### Resources |
| 98 | + |
| 99 | +| Name | Type | |
| 100 | +|------|------| |
| 101 | +| [github_actions_organization_secret.backstage_humanitec_token](https://registry.terraform.io/providers/integrations/github/latest/docs/resources/actions_organization_secret) | resource | |
| 102 | +| [github_actions_organization_variable.backstage_cloud_provider](https://registry.terraform.io/providers/integrations/github/latest/docs/resources/actions_organization_variable) | resource | |
| 103 | +| [github_actions_organization_variable.backstage_gcp_gar_host](https://registry.terraform.io/providers/integrations/github/latest/docs/resources/actions_organization_variable) | resource | |
| 104 | +| [github_actions_organization_variable.backstage_gcp_gar_name](https://registry.terraform.io/providers/integrations/github/latest/docs/resources/actions_organization_variable) | resource | |
| 105 | +| [github_actions_organization_variable.backstage_gcp_service_account](https://registry.terraform.io/providers/integrations/github/latest/docs/resources/actions_organization_variable) | resource | |
| 106 | +| [github_actions_organization_variable.backstage_gcp_workload_identity_provider](https://registry.terraform.io/providers/integrations/github/latest/docs/resources/actions_organization_variable) | resource | |
| 107 | +| [github_actions_organization_variable.backstage_humanitec_org_id](https://registry.terraform.io/providers/integrations/github/latest/docs/resources/actions_organization_variable) | resource | |
| 108 | +| [github_repository.backstage](https://registry.terraform.io/providers/integrations/github/latest/docs/resources/repository) | resource | |
| 109 | +| [google-beta_google_iam_workload_identity_pool.main](https://registry.terraform.io/providers/hashicorp/google-beta/latest/docs/resources/google_iam_workload_identity_pool) | resource | |
| 110 | +| [google-beta_google_iam_workload_identity_pool_provider.main](https://registry.terraform.io/providers/hashicorp/google-beta/latest/docs/resources/google_iam_workload_identity_pool_provider) | resource | |
| 111 | +| [google_artifact_registry_repository.repo](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/artifact_registry_repository) | resource | |
| 112 | +| [google_project_iam_member.project](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/project_iam_member) | resource | |
| 113 | +| [google_service_account.sa](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/service_account) | resource | |
| 114 | +| [google_service_account_iam_member.wif-sa](https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/service_account_iam_member) | resource | |
| 115 | +| [humanitec_application.backstage](https://registry.terraform.io/providers/humanitec/humanitec/latest/docs/resources/application) | resource | |
| 116 | +| [humanitec_resource_definition_criteria.backstage_mysql](https://registry.terraform.io/providers/humanitec/humanitec/latest/docs/resources/resource_definition_criteria) | resource | |
| 117 | +| [humanitec_resource_definition_criteria.backstage_postgres](https://registry.terraform.io/providers/humanitec/humanitec/latest/docs/resources/resource_definition_criteria) | resource | |
| 118 | +| [humanitec_value.backstage_cloud_provider](https://registry.terraform.io/providers/humanitec/humanitec/latest/docs/resources/value) | resource | |
| 119 | +| [humanitec_value.backstage_github_app_client_id](https://registry.terraform.io/providers/humanitec/humanitec/latest/docs/resources/value) | resource | |
| 120 | +| [humanitec_value.backstage_github_app_client_secret](https://registry.terraform.io/providers/humanitec/humanitec/latest/docs/resources/value) | resource | |
| 121 | +| [humanitec_value.backstage_github_app_id](https://registry.terraform.io/providers/humanitec/humanitec/latest/docs/resources/value) | resource | |
| 122 | +| [humanitec_value.backstage_github_app_private_key](https://registry.terraform.io/providers/humanitec/humanitec/latest/docs/resources/value) | resource | |
| 123 | +| [humanitec_value.backstage_github_app_webhook_secret](https://registry.terraform.io/providers/humanitec/humanitec/latest/docs/resources/value) | resource | |
| 124 | +| [humanitec_value.backstage_github_org_id](https://registry.terraform.io/providers/humanitec/humanitec/latest/docs/resources/value) | resource | |
| 125 | +| [humanitec_value.backstage_humanitec_org](https://registry.terraform.io/providers/humanitec/humanitec/latest/docs/resources/value) | resource | |
| 126 | +| [humanitec_value.backstage_humanitec_token](https://registry.terraform.io/providers/humanitec/humanitec/latest/docs/resources/value) | resource | |
| 127 | + |
| 128 | +### Inputs |
| 129 | + |
| 130 | +| Name | Description | Type | Default | Required | |
| 131 | +|------|-------------|------|---------|:--------:| |
| 132 | +| github\_org\_id | GitHub org id | `string` | n/a | yes | |
| 133 | +| humanitec\_ci\_service\_user\_token | Humanitec CI Service User Token | `string` | n/a | yes | |
| 134 | +| humanitec\_org\_id | Humanitec Organization ID | `string` | n/a | yes | |
| 135 | +| project\_id | GCP Project ID to provision resources in. | `string` | n/a | yes | |
| 136 | +| region | GCP Region to provision resources in. | `string` | n/a | yes | |
| 137 | +| registry\_location | Region of the Google Artifact Registry. | `string` | n/a | yes | |
| 138 | +| environment | The environment to associate the reference architecture with. | `string` | `null` | no | |
| 139 | +| environment\_type | The environment type to associate the reference architecture with. | `string` | `"development"` | no | |
| 140 | +| humanitec\_prefix | A prefix that will be attached to all IDs created in Humanitec. | `string` | `"htc-ref-arch-"` | no | |
| 141 | +<!-- END_TF_DOCS --> |
0 commit comments