[
  {
    "path": ".github/CODEOWNERS",
    "content": "* @humanitec-architecture/humanitec\n"
  },
  {
    "path": ".github/workflows/ci.yaml",
    "content": "name: CI\non:\n  push:\n    branches: [main]\n  pull_request:\n    branches: [main]\njobs:\n  test:\n    runs-on: ubuntu-latest\n    steps:\n      - uses: actions/checkout@v4\n\n      - uses: hashicorp/setup-terraform@v2\n        with:\n          terraform_version: ~1.5\n\n      - name: Terraform Version\n        run: terraform -version\n\n      - name: Install terraform-docs\n        run: |\n          WORK_DIR=$(mktemp -d)\n          curl -Lo ${WORK_DIR}/terraform-docs.tar.gz https://github.com/terraform-docs/terraform-docs/releases/download/v0.18.0/terraform-docs-v0.18.0-$(uname)-amd64.tar.gz\n          cd ${WORK_DIR}\n          tar -xzf terraform-docs.tar.gz\n          chmod +x terraform-docs\n          mv terraform-docs /usr/local/bin/terraform-docs\n      - name: Generate docs\n        run: make docs\n\n      - name: Check git diff is clean (all files generated should be committed)\n        run: git diff --exit-code\n\n      - uses: terraform-linters/setup-tflint@v4\n        with:\n          tflint_version: v0.51.1\n      - name: Terraform Lint\n        run: make lint\n\n      - name: Terraform Validate\n        run: make validate\n"
  },
  {
    "path": ".gitignore",
    "content": ".idea\n.terraform\n.terraform.lock.hcl\n*.tfstate\n*.tfstate.*\n*.tfplan\n*.terraformrc\n*.tfvars\nterraform.rc\ngithub-app-credentials.json\n**/.DS_Store\n"
  },
  {
    "path": ".tflint.hcl",
    "content": "plugin \"terraform\" {\n  enabled = true\n  preset  = \"recommended\"\n}\n\nplugin \"aws\" {\n  enabled = true\n  version = \"0.31.0\"\n  source  = \"github.com/terraform-linters/tflint-ruleset-aws\"\n}\n"
  },
  {
    "path": "LICENSE",
    "content": "                                 Apache License\n                           Version 2.0, January 2004\n                        http://www.apache.org/licenses/\n\n   TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION\n\n   1. Definitions.\n\n      \"License\" shall mean the terms and conditions for use, reproduction,\n      and distribution as defined by Sections 1 through 9 of this document.\n\n      \"Licensor\" shall mean the copyright owner or entity authorized by\n      the copyright owner that is granting the License.\n\n      \"Legal Entity\" shall mean the union of the acting entity and all\n      other entities that control, are controlled by, or are under common\n      control with that entity. For the purposes of this definition,\n      \"control\" means (i) the power, direct or indirect, to cause the\n      direction or management of such entity, whether by contract or\n      otherwise, or (ii) ownership of fifty percent (50%) or more of the\n      outstanding shares, or (iii) beneficial ownership of such entity.\n\n      \"You\" (or \"Your\") shall mean an individual or Legal Entity\n      exercising permissions granted by this License.\n\n      \"Source\" form shall mean the preferred form for making modifications,\n      including but not limited to software source code, documentation\n      source, and configuration files.\n\n      \"Object\" form shall mean any form resulting from mechanical\n      transformation or translation of a Source form, including but\n      not limited to compiled object code, generated documentation,\n      and conversions to other media types.\n\n      \"Work\" shall mean the work of authorship, whether in Source or\n      Object form, made available under the License, as indicated by a\n      copyright notice that is included in or attached to the work\n      (an example is provided in the Appendix below).\n\n      \"Derivative Works\" shall mean any work, whether in Source or Object\n      form, that is based on (or derived from) the Work and for which the\n      editorial revisions, annotations, elaborations, or other modifications\n      represent, as a whole, an original work of authorship. For the purposes\n      of this License, Derivative Works shall not include works that remain\n      separable from, or merely link (or bind by name) to the interfaces of,\n      the Work and Derivative Works thereof.\n\n      \"Contribution\" shall mean any work of authorship, including\n      the original version of the Work and any modifications or additions\n      to that Work or Derivative Works thereof, that is intentionally\n      submitted to Licensor for inclusion in the Work by the copyright owner\n      or by an individual or Legal Entity authorized to submit on behalf of\n      the copyright owner. For the purposes of this definition, \"submitted\"\n      means any form of electronic, verbal, or written communication sent\n      to the Licensor or its representatives, including but not limited to\n      communication on electronic mailing lists, source code control systems,\n      and issue tracking systems that are managed by, or on behalf of, the\n      Licensor for the purpose of discussing and improving the Work, but\n      excluding communication that is conspicuously marked or otherwise\n      designated in writing by the copyright owner as \"Not a Contribution.\"\n\n      \"Contributor\" shall mean Licensor and any individual or Legal Entity\n      on behalf of whom a Contribution has been received by Licensor and\n      subsequently incorporated within the Work.\n\n   2. Grant of Copyright License. Subject to the terms and conditions of\n      this License, each Contributor hereby grants to You a perpetual,\n      worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n      copyright license to reproduce, prepare Derivative Works of,\n      publicly display, publicly perform, sublicense, and distribute the\n      Work and such Derivative Works in Source or Object form.\n\n   3. Grant of Patent License. Subject to the terms and conditions of\n      this License, each Contributor hereby grants to You a perpetual,\n      worldwide, non-exclusive, no-charge, royalty-free, irrevocable\n      (except as stated in this section) patent license to make, have made,\n      use, offer to sell, sell, import, and otherwise transfer the Work,\n      where such license applies only to those patent claims licensable\n      by such Contributor that are necessarily infringed by their\n      Contribution(s) alone or by combination of their Contribution(s)\n      with the Work to which such Contribution(s) was submitted. If You\n      institute patent litigation against any entity (including a\n      cross-claim or counterclaim in a lawsuit) alleging that the Work\n      or a Contribution incorporated within the Work constitutes direct\n      or contributory patent infringement, then any patent licenses\n      granted to You under this License for that Work shall terminate\n      as of the date such litigation is filed.\n\n   4. Redistribution. You may reproduce and distribute copies of the\n      Work or Derivative Works thereof in any medium, with or without\n      modifications, and in Source or Object form, provided that You\n      meet the following conditions:\n\n      (a) You must give any other recipients of the Work or\n          Derivative Works a copy of this License; and\n\n      (b) You must cause any modified files to carry prominent notices\n          stating that You changed the files; and\n\n      (c) You must retain, in the Source form of any Derivative Works\n          that You distribute, all copyright, patent, trademark, and\n          attribution notices from the Source form of the Work,\n          excluding those notices that do not pertain to any part of\n          the Derivative Works; and\n\n      (d) If the Work includes a \"NOTICE\" text file as part of its\n          distribution, then any Derivative Works that You distribute must\n          include a readable copy of the attribution notices contained\n          within such NOTICE file, excluding those notices that do not\n          pertain to any part of the Derivative Works, in at least one\n          of the following places: within a NOTICE text file distributed\n          as part of the Derivative Works; within the Source form or\n          documentation, if provided along with the Derivative Works; or,\n          within a display generated by the Derivative Works, if and\n          wherever such third-party notices normally appear. The contents\n          of the NOTICE file are for informational purposes only and\n          do not modify the License. You may add Your own attribution\n          notices within Derivative Works that You distribute, alongside\n          or as an addendum to the NOTICE text from the Work, provided\n          that such additional attribution notices cannot be construed\n          as modifying the License.\n\n      You may add Your own copyright statement to Your modifications and\n      may provide additional or different license terms and conditions\n      for use, reproduction, or distribution of Your modifications, or\n      for any such Derivative Works as a whole, provided Your use,\n      reproduction, and distribution of the Work otherwise complies with\n      the conditions stated in this License.\n\n   5. Submission of Contributions. Unless You explicitly state otherwise,\n      any Contribution intentionally submitted for inclusion in the Work\n      by You to the Licensor shall be under the terms and conditions of\n      this License, without any additional terms or conditions.\n      Notwithstanding the above, nothing herein shall supersede or modify\n      the terms of any separate license agreement you may have executed\n      with Licensor regarding such Contributions.\n\n   6. Trademarks. This License does not grant permission to use the trade\n      names, trademarks, service marks, or product names of the Licensor,\n      except as required for reasonable and customary use in describing the\n      origin of the Work and reproducing the content of the NOTICE file.\n\n   7. Disclaimer of Warranty. Unless required by applicable law or\n      agreed to in writing, Licensor provides the Work (and each\n      Contributor provides its Contributions) on an \"AS IS\" BASIS,\n      WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or\n      implied, including, without limitation, any warranties or conditions\n      of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A\n      PARTICULAR PURPOSE. You are solely responsible for determining the\n      appropriateness of using or redistributing the Work and assume any\n      risks associated with Your exercise of permissions under this License.\n\n   8. Limitation of Liability. In no event and under no legal theory,\n      whether in tort (including negligence), contract, or otherwise,\n      unless required by applicable law (such as deliberate and grossly\n      negligent acts) or agreed to in writing, shall any Contributor be\n      liable to You for damages, including any direct, indirect, special,\n      incidental, or consequential damages of any character arising as a\n      result of this License or out of the use or inability to use the\n      Work (including but not limited to damages for loss of goodwill,\n      work stoppage, computer failure or malfunction, or any and all\n      other commercial damages or losses), even if such Contributor\n      has been advised of the possibility of such damages.\n\n   9. Accepting Warranty or Additional Liability. While redistributing\n      the Work or Derivative Works thereof, You may choose to offer,\n      and charge a fee for, acceptance of support, warranty, indemnity,\n      or other liability obligations and/or rights consistent with this\n      License. However, in accepting such obligations, You may act only\n      on Your own behalf and on Your sole responsibility, not on behalf\n      of any other Contributor, and only if You agree to indemnify,\n      defend, and hold each Contributor harmless for any liability\n      incurred by, or claims asserted against, such Contributor by reason\n      of your accepting any such warranty or additional liability.\n\n   END OF TERMS AND CONDITIONS\n\n   APPENDIX: How to apply the Apache License to your work.\n\n      To apply the Apache License to your work, attach the following\n      boilerplate notice, with the fields enclosed by brackets \"[]\"\n      replaced with your own identifying information. (Don't include\n      the brackets!)  The text should be enclosed in the appropriate\n      comment syntax for the file format. We also recommend that a\n      file or class name and description of purpose be included on the\n      same \"printed page\" as the copyright notice for easier\n      identification within third-party archives.\n\n   Copyright [yyyy] [name of copyright owner]\n\n   Licensed under the Apache License, Version 2.0 (the \"License\");\n   you may not use this file except in compliance with the License.\n   You may obtain a copy of the License at\n\n       http://www.apache.org/licenses/LICENSE-2.0\n\n   Unless required by applicable law or agreed to in writing, software\n   distributed under the License is distributed on an \"AS IS\" BASIS,\n   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n   See the License for the specific language governing permissions and\n   limitations under the License.\n"
  },
  {
    "path": "Makefile",
    "content": "TF_DIRS = $(patsubst %/main.tf, %, $(shell find . -type d -name .terraform -prune -o -name 'main.tf' -print))\nVALIDATE_TF_DIRS = $(addprefix validate-,$(TF_DIRS))\nLINT_TF_DIRS = $(addprefix lint-,$(TF_DIRS))\nDOCS_TF_DIRS = $(addprefix docs-,$(TF_DIRS))\n\n# Generate docs for a terraform directories\n$(DOCS_TF_DIRS): docs-%:\n\t@echo \"Docs $*\"\n\tterraform-docs --config docs/.terraform-docs.yaml $*\n\tterraform-docs --config docs/.terraform-docs-example.yaml $*\n\n# Generate docs\n.PHONY: docs\ndocs: $(DOCS_TF_DIRS)\n\t@echo \"All docs generated\"\n\n# Format all terraform files\nfmt:\n\tterraform fmt -recursive\n\n# Check if all terraform files are formatted\nfmt-check:\n\tterraform fmt -recursive -check\n\n# Validate a terraform directories\n$(VALIDATE_TF_DIRS): validate-%:\n\t@echo \"Validate $*\"\n\tterraform -chdir=\"$*\" init -upgrade\n\tterraform -chdir=\"$*\" validate\n\n# Validate all terraform directories\nvalidate: $(VALIDATE_TF_DIRS)\n\t@echo \"All validated\"\n\n# Lint a terraform directories\n$(LINT_TF_DIRS): lint-%:\n\t@echo \"Lint $*\"\n\ttflint --config \"$(PWD)/.tflint.hcl\" --chdir=\"$*\"\n\n# Initialize tflint\nlint-init:\n\ttflint --init\n\n# Lint all terraform directories\nlint: lint-init $(LINT_TF_DIRS) fmt-check\n\t@echo \"All linted\"\n"
  },
  {
    "path": "README.md",
    "content": "# Deprecation notice\n\n⚠️ The present reference architecture implementation for AWS has been deprecated. It will continue to be available at this location for some time, but not receive further updates.\n\nThe deprecation only affects the reference implementation contained in this repository, not the underlying conceptual architectures and supplementary materials shown on the [Humanitec website](https://humanitec.com/reference-architectures).\n\n# Humanitec AWS Reference Architecture\n\n> TL;DR\n>\n> Skip the theory? Go [here](README.md#how-to-spin-up-your-humanitec-aws-reference-architecture) to spin up your Humanitec AWS Reference Architecture Implementation.\n>\n> [Follow this learning path to master your Internal Developer Platform](https://developer.humanitec.com/training/master-your-internal-developer-platform/introduction/).\n>\n\nBuilding an Internal Developer Platform (IDP) can come with many challenges. To give you a head start, we’ve created a set of [reference architectures](https://humanitec.com/reference-architectures) based on hundreds of real-world setups. These architectures described in code provide a starting point to build your own IDP within minutes, along with customization capabilities to ensure your platform meets the unique needs of your users (developers).\n\nThe initial version of this reference architecture has been presented by Mike Gatto, Sr. DevOps Engineer, McKinsey and Stephan Schneider, Digital Expert Associate Partner, McKinsey at [PlartformCon 2023](https://www.youtube.com/watch?v=AimSwK8Mw-U).\n\n## What is an Internal Developer Platform (IDP)?\n\nAn [Internal Developer Platform (IDP)](https://humanitec.com/blog/what-is-an-internal-developer-platform) is the sum of all the tech and tools that a platform engineering team binds together to pave golden paths for developers. IDPs lower cognitive load across the engineering organization and enable developer self-service, without abstracting away context from developers or making the underlying tech inaccessible. Well-designed IDPs follow a Platform as a Product approach, where a platform team builds, maintains, and continuously improves the IDP, following product management principles and best practices.\n\n## Understanding the different planes of the IDP reference architecture\n\nWhen McKinsey originally [published the reference architecture](https://www.youtube.com/watch?v=AimSwK8Mw-U) they proposed five planes that describe the different parts of a modern Internal Developer Platform (IDP).\n\n![AWS reference architecture Humanitec](docs/images/AWS-reference-architecture-Humanitec.png)\n\n### Developer Control Plane\n\nThis plane is the primary configuration layer and interaction point for the platform users. It harbors the following components:\n\n* A **Version Control System**. GitHub is a prominent example, but this can be any system that contains two types of repositories:\n  * Application Source Code\n  * Platform Source Code, e.g. using Terraform\n* **Workload specifications**. The reference architecture uses [Score](https://developer.humanitec.com/score/overview/).\n* A **portal** for developers to interact with. It can be the Humanitec Portal, but you might also use [Backstage](https://backstage.io/) or any other portal on the market.\n\n### Integration and Delivery Plane\n\nThis plane is about building and storing the image, creating app and infra configs from the abstractions provided by the developers, and deploying the final state. It’s where the domains of developers and platform engineers meet.\n\nThis plane usually contains four different tools:\n\n* A **CI pipeline**. It can be Github Actions or any CI tooling on the market.\n* The **image registry** holding your container images. Again, this can be any registry on the market.\n* An **orchestrator** which in our example, is the Humanitec Platform Orchestrator.\n* The **CD system**, which can be the Platform Orchestrator’s deployment pipeline capabilities — an external system triggered by the Orchestrator using a webhook, or a setup in tandem with GitOps operators like ArgoCD.\n\n### Monitoring and Logging Plane\n\nThe integration of monitoring and logging systems varies greatly depending on the system. This plane however is not a focus of the reference architecture.\n\n### Security Plane\n\nThe security plane of the reference architecture is focused on the secrets management system. The secrets manager stores configuration information such as database passwords, API keys, or TLS certificates needed by an Application at runtime. It allows the Platform Orchestrator to reference the secrets and inject them into the Workloads dynamically. You can learn more about secrets management and integration with other secrets management [here](https://developer.humanitec.com/platform-orchestrator/security/overview).\n\nThe reference architecture sample implementations use the secrets store attached to the Humanitec SaaS system.\n\n### Resource Plane\n\nThis plane is where the actual infrastructure exists including clusters, databases, storage, or DNS services. The configuration of the Resources is managed by the Platform Orchestrator which dynamically creates app and infrastructure configurations with every deployment and creates, updates, or deletes dependent Resources as required.\n\n## How to spin up your Humanitec AWS Reference Architecture\n\nThis repo contains an implementation of part of the Humanitec Reference Architecture for an Internal Developer Platform, including Backstage as optional Portal solution.\n\nThis repo covers the base layer of the implementation for AWS.\n\nBy default, the following will be provisioned:\n\n* VPC\n* EKS Cluster\n* IAM User to access the cluster\n* Ingress NGINX in the cluster\n* Resource Definitions in Humanitec for:\n  * Kubernetes Cluster\n\n### Prerequisites\n\n* A Humanitec account with the `Administrator` role in an Organization. Get a [free trial](https://app.humanitec.io/auth/signup) if you are just starting.\n* An AWS account\n* [AWS CLI](https://aws.amazon.com/cli/) installed locally\n* [terraform](https://www.terraform.io/) installed locally\n* (Optional) [Humanitec CLI](https://developer.humanitec.com/platform-orchestrator/cli/) installed locally\n* (Optional) [GitHub CLI](https://cli.github.com/) installed locally\n\n### Usage\n\n**Note: Using this Reference Architecture Implementation will incur costs for your AWS project.**\n\nIt is recommended that you fully review the code before you run it to ensure you understand the impact of provisioning this infrastructure.\nHumanitec does not take responsibility for any costs incurred or damage caused when using the Reference Architecture Implementation.\n\nThis reference architecture implementation uses Terraform. You will need to do the following:\n\n1. [Fork this GitHub repo](https://github.com/humanitec-architecture/reference-architecture-aws/fork), clone it to your local machine and navigate to the root of the repository.\n\n2. Set the required input variables. (see [Required input variables](#required-input-variables))\n\n3. Ensure you are logged in with `aws`. (Follow the [quickstart](https://docs.aws.amazon.com/cli/latest/userguide/getting-started-quickstart.html) if you aren't)\n\n4.\n   1. Login to Humanitec (your user needs to have the `Administrator` role on the Humanitec Organization)\n\n      ```shell\n      humctl login\n      ```\n\n   2. Alternatively: Set the `HUMANITEC_TOKEN` environment variable to an appropriate [Humanitec API token](https://developer.humanitec.com/platform-orchestrator/security/service-users/#generate-an-api-token-from-a-service-user) with the `Administrator` role on the Humanitec Organization.\n\n   For example:\n\n   ```shell\n   export HUMANITEC_TOKEN=\"my-humanitec-api-token\"\n   ```\n\n5. Run terraform:\n\n   ```shell\n   terraform init\n   terraform plan\n   terraform apply\n   ```\n\n#### Required input variables\n\nTerraform reads variables by default from a file called `terraform.tfvars`. You can create your own file by renaming the `terraform.tfvars.example` file in the root of the repo and then filling in the missing values.\n\nYou can see find a details about each of those variables and additional supported variables under [Inputs](#inputs).\n\n### Verify your result\n\nCheck for the existence of key elements of the reference architecture. This is a subset of all elements only. For a complete list of what was installed, review the Terraform code.\n\n1. Set the `HUMANITEC_ORG` environment variable to the ID of your Humanitec Organization (must be all lowercase):\n\n   ```shell\n   export HUMANITEC_ORG=\"my-humanitec-org\"\n   ```\n\n2. Verify the existence of the Resource Definition for the EKS cluster in your Humanitec Organization:\n\n   ```shell\n   curl -s https://api.humanitec.io/orgs/${HUMANITEC_ORG}/resources/defs/ref-arch \\\n     --header \"Authorization: Bearer ${HUMANITEC_TOKEN}\" \\\n     | jq .id,.type\n   ```\n\n   This should output:\n\n   ```shell\n   \"ref-arch\"\n   \"k8s-cluster\"\n   ```\n\n3. Verify the existence of the newly created EKS cluster:\n\n   ```shell\n   aws eks list-clusters --region <your-region>\n   ```\n\n   This should output:\n\n   ```json\n   {\n       \"clusters\": [\n           \"ref-arch\",\n           \"[more previously existing clusters here]\"\n       ]\n   }\n   ```\n\n### Enable a portal (optional)\n\n#### Portal Prerequisites\n\nBackstage requires a GitHub connection, which in turn needs:\n\n* 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.\n\n* Configured GitHub access\n  * Either using the GitHub CLI:\n\n    ```shell\n    gh auth login --scopes repo,workflow,admin:org,delete_repo\n    ```\n\n  * Or using a token:\n    * Create a classic github personal access token with `repo`, `workflow`, `delete_repo` and `admin:org` scope [here](https://github.com/settings/tokens).\n    * Set the `GITHUB_TOKEN` environment variable to your token.\n\n      ```shell\n      export GITHUB_TOKEN=\"my-github-token\"\n      ```\n\n* Set the `GITHUB_ORG_ID` environment variable to your GitHub organization ID.\n\n  ```shell\n  export GITHUB_ORG_ID=\"my-github-org-id\"\n  ```\n\n* Install the GitHub App for Backstage into your GitHub organization\n  * Run `docker run --rm -it -e GITHUB_ORG_ID -v $(pwd):/pwd -p 127.0.0.1:3000:3000 ghcr.io/humanitec-architecture/create-gh-app` ([image source](https://github.com/humanitec-architecture/create-gh-app/)) and follow the instructions:\n    * “All repositories” ~> Install\n    * “Okay, […] was installed on the […] account.” ~> You can close the window and server.\n\n#### Portal Usage\n\n* Enable `with_backstage` inside your `terraform.tfvars` and configure the additional variables that a required for Backstage.\n* Perform another `terraform apply`\n\n#### Verify portal setup\n\n* [Fetch the DNS entry](https://developer.humanitec.com/score/getting-started/get-dns/) of the Humanitec Application `backstage`, Environment `development`.\n* Open the host in your browser.\n* Click the \"Create\" button and scaffold your first application.\n\n### Cleaning up\n\nOnce you are finished with the reference architecture, you can remove all provisioned infrastructure and the resource definitions created in Humanitec with the following:\n\n1. Delete all Humanitec Applications scaffolded using the Portal, if you used one, but not the `backstage` app itself.\n\n2. Ensure you are (still) logged in with `aws`.\n\n3. Ensure you still have the `HUMANITEC_TOKEN` environment variable set to an appropriate Humanitec API token with the `Administrator` role on the Humanitec Organization.\n\n4. Run terraform:\n\n   ```shell\n   terraform destroy\n   ```\n\n## Terraform docs\n\n<!-- BEGIN_TF_DOCS -->\n### Requirements\n\n| Name | Version |\n|------|---------|\n| terraform | >= 1.3.0 |\n| aws | ~> 5.17 |\n| github | ~> 5.38 |\n| helm | ~> 2.12 |\n| humanitec | ~> 1.0 |\n| kubernetes | ~> 2.25 |\n| random | ~> 3.5 |\n\n### Providers\n\n| Name | Version |\n|------|---------|\n| humanitec | ~> 1.0 |\n\n### Modules\n\n| Name | Source | Version |\n|------|--------|---------|\n| base | ./modules/base | n/a |\n| github | ./modules/github | n/a |\n| github\\_app | github.com/humanitec-architecture/shared-terraform-modules//modules/github-app | v2024-06-12 |\n| portal\\_backstage | ./modules/portal-backstage | n/a |\n\n### Resources\n\n| Name | Type |\n|------|------|\n| [humanitec_service_user_token.deployer](https://registry.terraform.io/providers/humanitec/humanitec/latest/docs/resources/service_user_token) | resource |\n| [humanitec_user.deployer](https://registry.terraform.io/providers/humanitec/humanitec/latest/docs/resources/user) | resource |\n\n### Inputs\n\n| Name | Description | Type | Default | Required |\n|------|-------------|------|---------|:--------:|\n| aws\\_account\\_id | AWS Account (ID) to use | `string` | n/a | yes |\n| aws\\_region | AWS region | `string` | n/a | yes |\n| disk\\_size | Disk size in GB to use for EKS nodes | `number` | `20` | no |\n| github\\_org\\_id | GitHub org id (required for Backstage) | `string` | `null` | no |\n| humanitec\\_org\\_id | Humanitec Organization ID (required for Backstage) | `string` | `null` | no |\n| instance\\_types | List of EC2 instances types to use for EKS nodes | `list(string)` | <pre>[<br>  \"t3.large\"<br>]</pre> | no |\n| with\\_backstage | Deploy Backstage | `bool` | `false` | no |\n<!-- END_TF_DOCS -->\n\n## Learn more\n\nExpand your knowledge by heading over to our learning path, and discover how to:\n\n* Deploy the Humanitec reference architecture using a cloud provider of your choice\n* Deploy and manage Applications using the Humanitec Platform Orchestrator and Score\n* Provision additional Resources and connect to them\n* Achieve standardization by design\n* Deal with special scenarios\n\n[Master your Internal Developer Platform](https://developer.humanitec.com/training/master-your-internal-developer-platform/introduction/)\n\n* [Introduction](https://developer.humanitec.com/training/master-your-internal-developer-platform/introduction/)\n* [Design principles](https://developer.humanitec.com/training/master-your-internal-developer-platform/design-principles/)\n* [Structure and integration points](https://developer.humanitec.com/training/master-your-internal-developer-platform/structure-and-integration-points/)\n* [Dynamic Configuration Management](https://developer.humanitec.com/training/master-your-internal-developer-platform/dynamic-config-management/)\n* [Tutorial: Set up the reference architecture in your cloud](https://developer.humanitec.com/training/master-your-internal-developer-platform/setup-ref-arch-in-your-cloud/)\n* [Theory on developer workflows](https://developer.humanitec.com/training/master-your-internal-developer-platform/theory-on-dev-workflows/)\n* [Tutorial: Scaffold a new Workload and create staging and prod Environments](https://developer.humanitec.com/training/master-your-internal-developer-platform/scaffolding-a-new-workload/)\n* [Tutorial: Deploy an Amazon S3 Resource to production](https://developer.humanitec.com/training/master-your-internal-developer-platform/deploy-a-resource/)\n* [Tutorial: Perform daily developer activities (debug, rollback, diffs, logs)](https://developer.humanitec.com/training/master-your-internal-developer-platform/daily-activities/)\n* [Tutorial: Deploy ephemeral Environments](https://developer.humanitec.com/training/master-your-internal-developer-platform/deploy-ephemeral-environments/)\n* [Theory on platform engineering workflows](https://developer.humanitec.com/training/master-your-internal-developer-platform/theory-on-pe-workflows/)\n* [Resource management theory](https://developer.humanitec.com/training/master-your-internal-developer-platform/resource-management-theory/)\n* [Tutorial: Provision a Redis cluster on AWS using Terraform](https://developer.humanitec.com/training/master-your-internal-developer-platform/provision-redis-aws/)\n* [Tutorial: Update Resource Definitions for related Applications](https://developer.humanitec.com/training/master-your-internal-developer-platform/update-resource-definitions-for-related-applications/)\n"
  },
  {
    "path": "docs/.terraform-docs-example.yaml",
    "content": "formatter: \"tfvars hcl\"\n\noutput:\n  file: \"./terraform.tfvars.example\"\n  mode: replace\n  template: \"{{ .Content }}\"\n\nsettings:\n  description: true\n"
  },
  {
    "path": "docs/.terraform-docs.yaml",
    "content": "formatter: \"markdown table\"\n\noutput:\n  file: \"./README.md\"\n\nsort:\n  enabled: true\n  by: required\n\n\nsettings:\n  anchor: false\n  indent: 3\n  hide-empty: true\n  lockfile: false\n"
  },
  {
    "path": "main.tf",
    "content": "# AWS reference architecture\n\nmodule \"base\" {\n  source = \"./modules/base\"\n\n  region         = var.aws_region\n  instance_types = var.instance_types\n  disk_size      = var.disk_size\n}\n\n# User used for scaffolding and deploying apps\n\nresource \"humanitec_user\" \"deployer\" {\n  count = var.with_backstage ? 1 : 0\n\n  name = \"deployer\"\n  role = \"administrator\"\n  type = \"service\"\n}\n\nresource \"humanitec_service_user_token\" \"deployer\" {\n  count = var.with_backstage ? 1 : 0\n\n  id          = \"deployer\"\n  user_id     = humanitec_user.deployer[0].id\n  description = \"Used by scaffolding and deploying\"\n}\n\nmodule \"github\" {\n  count = var.with_backstage ? 1 : 0\n\n  source = \"./modules/github\"\n\n  humanitec_org_id                = var.humanitec_org_id\n  humanitec_ci_service_user_token = humanitec_service_user_token.deployer[0].token\n  aws_region                      = var.aws_region\n  github_org_id                   = var.github_org_id\n\n  depends_on = [module.base]\n}\n\n# Configure GitHub variables & secrets for Backstage itself and for all scaffolded apps\n\nlocals {\n  github_app_credentials_file = \"github-app-credentials.json\"\n}\n\nmodule \"github_app\" {\n  count = var.with_backstage ? 1 : 0\n\n  source = \"github.com/humanitec-architecture/shared-terraform-modules//modules/github-app?ref=v2024-06-12\"\n\n  credentials_file = \"${path.module}/${local.github_app_credentials_file}\"\n}\n\n# Deploy Backstage as Portal\n\nmodule \"portal_backstage\" {\n  count = var.with_backstage ? 1 : 0\n\n  source = \"./modules/portal-backstage\"\n\n  humanitec_org_id                = var.humanitec_org_id\n  humanitec_ci_service_user_token = humanitec_service_user_token.deployer[0].token\n\n  github_org_id            = var.github_org_id\n  github_app_client_id     = module.github_app[0].client_id\n  github_app_client_secret = module.github_app[0].client_secret\n  github_app_id            = module.github_app[0].app_id\n  github_app_private_key   = module.github_app[0].private_key\n  github_webhook_secret    = module.github_app[0].webhook_secret\n\n  depends_on = [module.github]\n}\n"
  },
  {
    "path": "modules/base/.terraform-docs.yaml",
    "content": "formatter: \"markdown table\"\n\noutput:\n  file: \"./README.md\"\n\nsort:\n  enabled: true\n  by: required\n\nsettings:\n  hide-empty: true\n"
  },
  {
    "path": "modules/base/README.md",
    "content": "# base\n\nModule that provides the reference architecture.\n\n## Terraform docs\n\n<!-- BEGIN_TF_DOCS -->\n### Requirements\n\n| Name | Version |\n|------|---------|\n| terraform | >= 1.3.0 |\n| aws | >= 4.50 |\n| helm | ~> 2.12 |\n| humanitec | ~> 1.0 |\n| kubernetes | >= 2.0.3 |\n| random | ~> 3.5 |\n\n### Providers\n\n| Name | Version |\n|------|---------|\n| aws | >= 4.50 |\n| helm | ~> 2.12 |\n| humanitec | ~> 1.0 |\n| kubernetes | >= 2.0.3 |\n| random | ~> 3.5 |\n\n### Modules\n\n| Name | Source | Version |\n|------|--------|---------|\n| aws\\_eks | terraform-aws-modules/eks/aws | ~> 20.2 |\n| aws\\_vpc | terraform-aws-modules/vpc/aws | ~> 5.1 |\n| default\\_mysql | github.com/humanitec-architecture/resource-packs-in-cluster//humanitec-resource-defs/mysql/basic | v2024-06-05 |\n| default\\_postgres | github.com/humanitec-architecture/resource-packs-in-cluster//humanitec-resource-defs/postgres/basic | v2024-06-05 |\n| ebs\\_csi\\_irsa\\_role | terraform-aws-modules/iam/aws//modules/iam-role-for-service-accounts-eks | ~> 5.30 |\n\n### Resources\n\n| Name | Type |\n|------|------|\n| [aws_iam_role.humanitec_svc](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role) | resource |\n| [aws_iam_role_policy_attachment.humanitec_svc](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_role_policy_attachment) | resource |\n| [helm_release.ingress_nginx](https://registry.terraform.io/providers/hashicorp/helm/latest/docs/resources/release) | resource |\n| [humanitec_resource_account.cluster_account](https://registry.terraform.io/providers/humanitec/humanitec/latest/docs/resources/resource_account) | resource |\n| [humanitec_resource_definition.emptydir_volume](https://registry.terraform.io/providers/humanitec/humanitec/latest/docs/resources/resource_definition) | resource |\n| [humanitec_resource_definition.k8s_cluster_driver](https://registry.terraform.io/providers/humanitec/humanitec/latest/docs/resources/resource_definition) | resource |\n| [humanitec_resource_definition.k8s_namespace](https://registry.terraform.io/providers/humanitec/humanitec/latest/docs/resources/resource_definition) | resource |\n| [humanitec_resource_definition_criteria.default_mysql](https://registry.terraform.io/providers/humanitec/humanitec/latest/docs/resources/resource_definition_criteria) | resource |\n| [humanitec_resource_definition_criteria.default_postgres](https://registry.terraform.io/providers/humanitec/humanitec/latest/docs/resources/resource_definition_criteria) | resource |\n| [humanitec_resource_definition_criteria.emptydir_volume](https://registry.terraform.io/providers/humanitec/humanitec/latest/docs/resources/resource_definition_criteria) | resource |\n| [humanitec_resource_definition_criteria.k8s_cluster_driver](https://registry.terraform.io/providers/humanitec/humanitec/latest/docs/resources/resource_definition_criteria) | resource |\n| [humanitec_resource_definition_criteria.k8s_namespace](https://registry.terraform.io/providers/humanitec/humanitec/latest/docs/resources/resource_definition_criteria) | resource |\n| [random_password.external_id](https://registry.terraform.io/providers/hashicorp/random/latest/docs/resources/password) | resource |\n| [aws_elb_hosted_zone_id.main](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/elb_hosted_zone_id) | data source |\n| [aws_iam_policy_document.instance_assume_role_policy](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/iam_policy_document) | data source |\n| [aws_region.current](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/data-sources/region) | data source |\n| [kubernetes_service.ingress_nginx_controller](https://registry.terraform.io/providers/hashicorp/kubernetes/latest/docs/data-sources/service) | data source |\n\n### Inputs\n\n| Name | Description | Type | Default | Required |\n|------|-------------|------|---------|:--------:|\n| additional\\_k8s\\_access\\_entries | Additional access entries add to the k8s aws-auth configmap | <pre>list(object({<br>    id            = string<br>    principal_arn = string<br>    groups        = list(string)<br>  }))</pre> | `[]` | no |\n| capacity\\_type | Defines whether to use ON\\_DEMAND or SPOT EC2 instances for EKS nodes | `string` | `\"ON_DEMAND\"` | no |\n| cluster\\_name | Name for the EKS cluster | `string` | `\"ref-arch\"` | no |\n| cluster\\_version | Version of the EKS cluster to deploy | `string` | `null` | no |\n| disk\\_size | Disk size in GB to use for EKS nodes | `number` | `20` | no |\n| eks\\_public\\_access\\_cidrs | List of CIDRs that can access the EKS cluster's public endpoint | `list(string)` | <pre>[<br>  \"0.0.0.0/0\"<br>]</pre> | no |\n| environment | Name of the environment to be deployed into | `string` | `\"development\"` | no |\n| iam\\_role\\_name | Name of the IAM user to create for Humanitec EKS access | `string` | `\"svc-humanitec\"` | no |\n| ingress\\_nginx\\_min\\_unavailable | Number of allowed unavaiable replicas for the ingress-nginx controller | `number` | `1` | no |\n| ingress\\_nginx\\_replica\\_count | Number of replicas for the ingress-nginx controller | `number` | `2` | no |\n| instance\\_types | List of EC2 instances types to use for EKS nodes | `list(string)` | <pre>[<br>  \"t3.large\"<br>]</pre> | no |\n| node\\_group\\_desired\\_size | Desired number of nodes for the EKS node group | `number` | `3` | no |\n| node\\_group\\_max\\_size | Maximum number of nodes for the EKS node group | `number` | `3` | no |\n| node\\_group\\_min\\_size | Minimum number of nodes for the EKS node group | `number` | `2` | no |\n| region | AWS Region to deploy into | `string` | `\"us-east-1\"` | no |\n| vpc\\_name | AWS VPC name | `string` | `\"ref-arch\"` | no |\n\n### Outputs\n\n| Name | Description |\n|------|-------------|\n| eks\\_cluster\\_certificate\\_authority\\_data | Base64 encoded certificate data required to communicate with the cluster |\n| eks\\_cluster\\_endpoint | Endpoint for your Kubernetes API server |\n| eks\\_cluster\\_name | The name of the EKS cluster |\n| eks\\_oidc\\_provider | The OpenID Connect identity provider (issuer URL without leading `https://`) |\n| eks\\_oidc\\_provider\\_arn | The ARN of the OIDC Provider |\n| environment | Name of the environment to be deployed into |\n| humanitec\\_resource\\_account\\_id | Humanitec resource account id for the cluster |\n| ingress\\_nginx\\_external\\_dns | External DNS entry for the Nginx ingress controller |\n| vpc\\_id | VPC id |\n<!-- END_TF_DOCS -->\n"
  },
  {
    "path": "modules/base/humanitec.tf",
    "content": "\nlocals {\n  res_def_prefix = \"default-\"\n}\n\n# Configure default resources for example apps\n\n\nlocals {\n  ingress_address = data.kubernetes_service.ingress_nginx_controller.status[0].load_balancer[0].ingress[0].hostname\n}\n\ndata \"aws_elb_hosted_zone_id\" \"main\" {}\n\n# k8s-cluster\n\nresource \"humanitec_resource_account\" \"cluster_account\" {\n  id   = var.cluster_name\n  name = var.cluster_name\n  type = \"aws-role\"\n\n  credentials = jsonencode({\n    aws_role    = aws_iam_role.humanitec_svc.arn\n    external_id = random_password.external_id.result\n  })\n\n  depends_on = [aws_iam_role_policy_attachment.humanitec_svc]\n}\n\nresource \"humanitec_resource_definition\" \"k8s_cluster_driver\" {\n  driver_type = \"humanitec/k8s-cluster-eks\"\n  id          = var.cluster_name\n  name        = var.cluster_name\n  type        = \"k8s-cluster\"\n\n  driver_account = humanitec_resource_account.cluster_account.id\n  driver_inputs = {\n    values_string = jsonencode({\n      \"name\"                     = module.aws_eks.cluster_name\n      \"loadbalancer\"             = local.ingress_address\n      \"loadbalancer_hosted_zone\" = data.aws_elb_hosted_zone_id.main.id\n      \"region\"                   = var.region\n    })\n  }\n}\n\nresource \"humanitec_resource_definition_criteria\" \"k8s_cluster_driver\" {\n  resource_definition_id = humanitec_resource_definition.k8s_cluster_driver.id\n  env_type               = var.environment\n}\n\n# k8s-namespace\n\nresource \"humanitec_resource_definition\" \"k8s_namespace\" {\n  driver_type = \"humanitec/echo\"\n  id          = \"default-namespace\"\n  name        = \"default-namespace\"\n  type        = \"k8s-namespace\"\n\n  driver_inputs = {\n    values_string = jsonencode({\n      \"namespace\" = \"$${context.app.id}-$${context.env.id}\"\n    })\n  }\n}\n\nresource \"humanitec_resource_definition_criteria\" \"k8s_namespace\" {\n  resource_definition_id = humanitec_resource_definition.k8s_namespace.id\n}\n\n\n# in-cluster postgres\n\nmodule \"default_postgres\" {\n  source = \"github.com/humanitec-architecture/resource-packs-in-cluster//humanitec-resource-defs/postgres/basic?ref=v2024-06-05\"\n\n  prefix = local.res_def_prefix\n}\n\nresource \"humanitec_resource_definition_criteria\" \"default_postgres\" {\n  resource_definition_id = module.default_postgres.id\n  env_type               = var.environment\n}\n\nmodule \"default_mysql\" {\n  source = \"github.com/humanitec-architecture/resource-packs-in-cluster//humanitec-resource-defs/mysql/basic?ref=v2024-06-05\"\n\n  prefix = local.res_def_prefix\n}\n\nresource \"humanitec_resource_definition_criteria\" \"default_mysql\" {\n  resource_definition_id = module.default_mysql.id\n  env_type               = var.environment\n}\n\nresource \"humanitec_resource_definition\" \"emptydir_volume\" {\n  driver_type = \"humanitec/template\"\n  id          = \"volume-emptydir\"\n  name        = \"volume-emptydir\"\n  type        = \"volume\"\n  driver_inputs = {\n    values_string = jsonencode({\n      \"templates\" = {\n        \"manifests\" = {\n          \"emptydir.yaml\" = {\n            \"location\" = \"volumes\"\n            \"data\"     = <<END_OF_TEXT\nname: $${context.res.guresid}-emptydir\nemptyDir:\n  sizeLimit: 1024Mi\nEND_OF_TEXT\n          }\n        }\n      }\n    })\n  }\n}\n\nresource \"humanitec_resource_definition_criteria\" \"emptydir_volume\" {\n  resource_definition_id = humanitec_resource_definition.emptydir_volume.id\n  env_type               = var.environment\n\n  force_delete = true\n}\n"
  },
  {
    "path": "modules/base/main.tf",
    "content": "locals {\n  admin_policy_arn   = \"arn:aws:iam::aws:policy/AdministratorAccess\"\n  humanitec_user_arn = \"arn:aws:iam::767398028804:user/humanitec\"\n  tags = {\n    Terraform   = \"true\"\n    Environment = var.environment\n  }\n}\n\nresource \"random_password\" \"external_id\" {\n  length  = 16\n  special = false\n}\n\ndata \"aws_iam_policy_document\" \"instance_assume_role_policy\" {\n  statement {\n    actions = [\"sts:AssumeRole\"]\n\n    principals {\n      type        = \"AWS\"\n      identifiers = [local.humanitec_user_arn]\n    }\n\n    condition {\n      test     = \"StringEquals\"\n      variable = \"sts:ExternalId\"\n      values   = [random_password.external_id.result]\n    }\n  }\n}\n\n\n# User for Humanitec to access the EKS cluster\nresource \"aws_iam_role\" \"humanitec_svc\" {\n  name = var.iam_role_name\n\n  assume_role_policy = data.aws_iam_policy_document.instance_assume_role_policy.json\n}\n\nresource \"aws_iam_role_policy_attachment\" \"humanitec_svc\" {\n  role       = aws_iam_role.humanitec_svc.name\n  policy_arn = local.admin_policy_arn\n}\n\n# VPC and EKS cluster\n\ndata \"aws_region\" \"current\" {}\n\nmodule \"aws_vpc\" {\n  source  = \"terraform-aws-modules/vpc/aws\"\n  version = \"~> 5.1\"\n\n  name = var.vpc_name\n  cidr = \"10.0.0.0/16\"\n\n  azs             = formatlist(\"${data.aws_region.current.name}%s\", [\"a\", \"b\", \"c\"])\n  private_subnets = [\"10.0.1.0/24\", \"10.0.2.0/24\", \"10.0.3.0/24\"]\n  public_subnets  = [\"10.0.101.0/24\", \"10.0.102.0/24\", \"10.0.103.0/24\"]\n\n  enable_nat_gateway = true\n\n  tags = local.tags\n}\n\nlocals {\n  default_k8s_access_entries = [\n    {\n      id            = aws_iam_role.humanitec_svc.name\n      principal_arn = aws_iam_role.humanitec_svc.arn\n      groups        = [\"system:masters\"]\n    }\n  ]\n  k8s_access_entries = concat(local.default_k8s_access_entries, var.additional_k8s_access_entries)\n}\n\nmodule \"ebs_csi_irsa_role\" {\n  source  = \"terraform-aws-modules/iam/aws//modules/iam-role-for-service-accounts-eks\"\n  version = \"~> 5.30\"\n\n  role_name             = \"ebs-csi\"\n  attach_ebs_csi_policy = true\n\n  oidc_providers = {\n    ex = {\n      provider_arn               = module.aws_eks.oidc_provider_arn\n      namespace_service_accounts = [\"kube-system:ebs-csi-controller-sa\"]\n    }\n  }\n\n  tags = local.tags\n}\n\nmodule \"aws_eks\" {\n  source  = \"terraform-aws-modules/eks/aws\"\n  version = \"~> 20.2\"\n\n  cluster_name    = var.cluster_name\n  cluster_version = var.cluster_version\n\n  cluster_endpoint_public_access       = true\n  cluster_endpoint_public_access_cidrs = var.eks_public_access_cidrs\n\n  vpc_id     = module.aws_vpc.vpc_id\n  subnet_ids = module.aws_vpc.private_subnets\n\n  eks_managed_node_groups = {\n    green = {\n      min_size     = var.node_group_min_size\n      max_size     = var.node_group_max_size\n      desired_size = var.node_group_desired_size\n\n      instance_types = var.instance_types\n      capacity_type  = var.capacity_type\n\n      disk_size                  = var.disk_size\n      use_custom_launch_template = false\n    }\n  }\n\n  cluster_addons = {\n    aws-ebs-csi-driver = {\n      most_recent              = true\n      service_account_role_arn = module.ebs_csi_irsa_role.iam_role_arn\n    }\n    eks-pod-identity-agent = {\n      most_recent = true\n    }\n  }\n\n  enable_cluster_creator_admin_permissions = true\n\n  access_entries = {\n    for s in local.k8s_access_entries : s.id => {\n      kubernetes_groups = []\n      principal_arn     = s.principal_arn\n\n      policy_associations = {\n        cluster_admin = {\n          policy_arn = \"arn:aws:eks::aws:cluster-access-policy/AmazonEKSClusterAdminPolicy\"\n          access_scope = {\n            namespaces = []\n            type       = \"cluster\"\n          }\n        }\n      }\n    }\n  }\n\n  # required for ingress-nginx see https://github.com/terraform-aws-modules/terraform-aws-eks/issues/2513\n  node_security_group_additional_rules = {\n    ingress_self_all = {\n      description = \"Node to node all ports/protocols\"\n      protocol    = \"-1\"\n      from_port   = 0\n      to_port     = 0\n      type        = \"ingress\"\n      self        = true\n    }\n  }\n\n  tags = local.tags\n}\n\n\n# Ingress controller\n\nresource \"helm_release\" \"ingress_nginx\" {\n  name             = \"ingress-nginx\"\n  namespace        = \"ingress-nginx\"\n  create_namespace = true\n  repository       = \"https://kubernetes.github.io/ingress-nginx\"\n\n  chart   = \"ingress-nginx\"\n  version = \"4.12.1\"\n  wait    = true\n  timeout = 600\n\n  set {\n    type  = \"string\"\n    name  = \"controller.replicaCount\"\n    value = var.ingress_nginx_replica_count\n  }\n\n  set {\n    type  = \"string\"\n    name  = \"controller.minAvailable\"\n    value = var.ingress_nginx_min_unavailable\n  }\n\n  set {\n    name  = \"controller.containerSecurityContext.runAsUser\"\n    value = 101\n  }\n\n  set {\n    name  = \"controller.containerSecurityContext.runAsGroup\"\n    value = 101\n  }\n\n  set {\n    name  = \"controller.containerSecurityContext.allowPrivilegeEscalation\"\n    value = false\n  }\n\n  set {\n    name  = \"controller.containerSecurityContext.readOnlyRootFilesystem\"\n    value = false\n  }\n\n  set {\n    name  = \"controller.containerSecurityContext.runAsNonRoot\"\n    value = true\n  }\n\n  set_list {\n    name  = \"controller.containerSecurityContext.capabilities.drop\"\n    value = [\"ALL\"]\n  }\n\n  set_list {\n    name  = \"controller.containerSecurityContext.capabilities.add\"\n    value = [\"NET_BIND_SERVICE\"]\n  }\n\n  depends_on = [module.aws_eks.eks_managed_node_groups]\n}\n"
  },
  {
    "path": "modules/base/meta.tf",
    "content": "data \"kubernetes_service\" \"ingress_nginx_controller\" {\n  metadata {\n    name      = \"ingress-nginx-controller\"\n    namespace = \"ingress-nginx\"\n  }\n  depends_on = [helm_release.ingress_nginx]\n}\n"
  },
  {
    "path": "modules/base/outputs.tf",
    "content": "# General outputs\n\noutput \"environment\" {\n  description = \"Name of the environment to be deployed into\"\n  value       = var.environment\n}\n\n# VPC outputs\n\noutput \"vpc_id\" {\n  description = \"VPC id\"\n  value       = module.aws_vpc.vpc_id\n}\n\n# EKS outputs\n\noutput \"eks_oidc_provider\" {\n  description = \"The OpenID Connect identity provider (issuer URL without leading `https://`)\"\n  value       = module.aws_eks.oidc_provider\n}\n\noutput \"eks_oidc_provider_arn\" {\n  description = \"The ARN of the OIDC Provider\"\n  value       = module.aws_eks.oidc_provider_arn\n}\n\noutput \"eks_cluster_endpoint\" {\n  description = \"Endpoint for your Kubernetes API server\"\n  value       = module.aws_eks.cluster_endpoint\n}\n\noutput \"eks_cluster_certificate_authority_data\" {\n  description = \"Base64 encoded certificate data required to communicate with the cluster\"\n  value       = module.aws_eks.cluster_certificate_authority_data\n}\n\noutput \"eks_cluster_name\" {\n  description = \"The name of the EKS cluster\"\n  value       = module.aws_eks.cluster_name\n}\n\n# Ingress outputs\n\noutput \"ingress_nginx_external_dns\" {\n  description = \"External DNS entry for the Nginx ingress controller\"\n  value       = local.ingress_address\n}\n\n\n# Humanitec\n\noutput \"humanitec_resource_account_id\" {\n  description = \"Humanitec resource account id for the cluster\"\n  value       = humanitec_resource_account.cluster_account.id\n}\n"
  },
  {
    "path": "modules/base/providers.tf",
    "content": "terraform {\n  required_providers {\n    aws = {\n      source  = \"hashicorp/aws\"\n      version = \">= 4.50\"\n    }\n    kubernetes = {\n      source  = \"hashicorp/kubernetes\"\n      version = \">= 2.0.3\"\n    }\n    helm = {\n      source  = \"hashicorp/helm\"\n      version = \"~> 2.12\"\n    }\n    humanitec = {\n      source  = \"humanitec/humanitec\"\n      version = \"~> 1.0\"\n    }\n    random = {\n      source  = \"hashicorp/random\"\n      version = \"~> 3.5\"\n    }\n  }\n  required_version = \">= 1.3.0\"\n}\n"
  },
  {
    "path": "modules/base/terraform.tfvars.example",
    "content": "\n# Additional access entries add to the k8s aws-auth configmap\nadditional_k8s_access_entries = []\n\n# Defines whether to use ON_DEMAND or SPOT EC2 instances for EKS nodes\ncapacity_type = \"ON_DEMAND\"\n\n# Name for the EKS cluster\ncluster_name = \"ref-arch\"\n\n# Version of the EKS cluster to deploy\ncluster_version = \"\"\n\n# Disk size in GB to use for EKS nodes\ndisk_size = 20\n\n# List of CIDRs that can access the EKS cluster's public endpoint\neks_public_access_cidrs = [\n  \"0.0.0.0/0\"\n]\n\n# Name of the environment to be deployed into\nenvironment = \"development\"\n\n# Name of the IAM user to create for Humanitec EKS access\niam_role_name = \"svc-humanitec\"\n\n# Number of allowed unavaiable replicas for the ingress-nginx controller\ningress_nginx_min_unavailable = 1\n\n# Number of replicas for the ingress-nginx controller\ningress_nginx_replica_count = 2\n\n# List of EC2 instances types to use for EKS nodes\ninstance_types = [\n  \"t3.large\"\n]\n\n# Desired number of nodes for the EKS node group\nnode_group_desired_size = 3\n\n# Maximum number of nodes for the EKS node group\nnode_group_max_size = 3\n\n# Minimum number of nodes for the EKS node group\nnode_group_min_size = 2\n\n# AWS Region to deploy into\nregion = \"us-east-1\"\n\n# AWS VPC name\nvpc_name = \"ref-arch\""
  },
  {
    "path": "modules/base/variables.tf",
    "content": "variable \"eks_public_access_cidrs\" {\n  description = \"List of CIDRs that can access the EKS cluster's public endpoint\"\n  type        = list(string)\n  default     = [\"0.0.0.0/0\"]\n}\n\nvariable \"region\" {\n  description = \"AWS Region to deploy into\"\n  type        = string\n  default     = \"us-east-1\"\n}\n\nvariable \"vpc_name\" {\n  description = \"AWS VPC name\"\n  type        = string\n  default     = \"ref-arch\"\n}\n\nvariable \"environment\" {\n  description = \"Name of the environment to be deployed into\"\n  type        = string\n  default     = \"development\"\n}\n\nvariable \"cluster_name\" {\n  description = \"Name for the EKS cluster\"\n  type        = string\n  default     = \"ref-arch\"\n}\n\nvariable \"cluster_version\" {\n  description = \"Version of the EKS cluster to deploy\"\n  type        = string\n  default     = null\n}\n\nvariable \"node_group_min_size\" {\n  description = \"Minimum number of nodes for the EKS node group\"\n  type        = number\n  default     = 2\n}\n\nvariable \"node_group_max_size\" {\n  description = \"Maximum number of nodes for the EKS node group\"\n  type        = number\n  default     = 3\n}\n\nvariable \"node_group_desired_size\" {\n  description = \"Desired number of nodes for the EKS node group\"\n  type        = number\n  default     = 3\n}\n\nvariable \"instance_types\" {\n  description = \"List of EC2 instances types to use for EKS nodes\"\n  type        = list(string)\n  default = [\n    \"t3.large\"\n  ]\n}\n\nvariable \"capacity_type\" {\n  description = \"Defines whether to use ON_DEMAND or SPOT EC2 instances for EKS nodes\"\n  type        = string\n  default     = \"ON_DEMAND\"\n}\n\nvariable \"iam_role_name\" {\n  description = \"Name of the IAM user to create for Humanitec EKS access\"\n  type        = string\n  default     = \"svc-humanitec\"\n}\n\nvariable \"additional_k8s_access_entries\" {\n  description = \"Additional access entries add to the k8s aws-auth configmap\"\n  type = list(object({\n    id            = string\n    principal_arn = string\n    groups        = list(string)\n  }))\n  default = []\n}\n\nvariable \"ingress_nginx_replica_count\" {\n  description = \"Number of replicas for the ingress-nginx controller\"\n  type        = number\n  default     = 2\n}\n\nvariable \"ingress_nginx_min_unavailable\" {\n  description = \"Number of allowed unavaiable replicas for the ingress-nginx controller\"\n  type        = number\n  default     = 1\n}\n\nvariable \"disk_size\" {\n  description = \"Disk size in GB to use for EKS nodes\"\n  type        = number\n  default     = 20\n}\n"
  },
  {
    "path": "modules/github/README.md",
    "content": "# GitHub\n\nThis module prepares a GitHub Organization to be used for scaffolding using a Portal.\n\n## Terraform docs\n\n<!-- BEGIN_TF_DOCS -->\n### Requirements\n\n| Name | Version |\n|------|---------|\n| terraform | >= 1.3.0 |\n| aws | ~> 5.17 |\n| github | ~> 5.38 |\n\n### Providers\n\n| Name | Version |\n|------|---------|\n| aws | ~> 5.17 |\n| github | ~> 5.38 |\n\n### Modules\n\n| Name | Source | Version |\n|------|--------|---------|\n| iam\\_github\\_oidc\\_provider | terraform-aws-modules/iam/aws//modules/iam-github-oidc-provider | ~> 5.30 |\n| iam\\_github\\_oidc\\_role | terraform-aws-modules/iam/aws//modules/iam-github-oidc-role | ~> 5.30 |\n\n### Resources\n\n| Name | Type |\n|------|------|\n| [aws_iam_policy.ecr_push_policy](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/iam_policy) | resource |\n| [github_actions_organization_secret.backstage_humanitec_token](https://registry.terraform.io/providers/integrations/github/latest/docs/resources/actions_organization_secret) | resource |\n| [github_actions_organization_variable.backstage_aws_region](https://registry.terraform.io/providers/integrations/github/latest/docs/resources/actions_organization_variable) | resource |\n| [github_actions_organization_variable.backstage_aws_role_arn](https://registry.terraform.io/providers/integrations/github/latest/docs/resources/actions_organization_variable) | resource |\n| [github_actions_organization_variable.backstage_cloud_provider](https://registry.terraform.io/providers/integrations/github/latest/docs/resources/actions_organization_variable) | resource |\n| [github_actions_organization_variable.backstage_humanitec_org_id](https://registry.terraform.io/providers/integrations/github/latest/docs/resources/actions_organization_variable) | resource |\n\n### Inputs\n\n| Name | Description | Type | Default | Required |\n|------|-------------|------|---------|:--------:|\n| aws\\_region | AWS region | `string` | n/a | yes |\n| github\\_org\\_id | GitHub org id | `string` | n/a | yes |\n| humanitec\\_ci\\_service\\_user\\_token | Humanitec CI Service User Token | `string` | n/a | yes |\n| humanitec\\_org\\_id | Humanitec Organization ID | `string` | n/a | yes |\n<!-- END_TF_DOCS -->\n"
  },
  {
    "path": "modules/github/aws.tf",
    "content": "locals {\n  name = \"gha-ecr-push\"\n}\n\n# Create a role for GitHub Actions to push to ECR using OpenID Connect (OIDC) so we don't need to store AWS credentials in GitHub\n# Reference https://docs.github.com/en/actions/deployment/security-hardening-your-deployments/configuring-openid-connect-in-amazon-web-services\n\n# Source https://github.com/terraform-aws-modules/terraform-aws-iam\nmodule \"iam_github_oidc_provider\" {\n  source  = \"terraform-aws-modules/iam/aws//modules/iam-github-oidc-provider\"\n  version = \"~> 5.30\"\n}\n\nmodule \"iam_github_oidc_role\" {\n  source  = \"terraform-aws-modules/iam/aws//modules/iam-github-oidc-role\"\n  version = \"~> 5.30\"\n\n  name = local.name\n\n  subjects = [\n    \"${var.github_org_id}/*\",\n  ]\n\n  policies = {\n    ecr_push_policy = aws_iam_policy.ecr_push_policy.arn\n  }\n}\n\n# Reference https://docs.aws.amazon.com/AmazonECR/latest/userguide/image-push.html#image-push-iam\nresource \"aws_iam_policy\" \"ecr_push_policy\" {\n  name        = local.name\n  description = \"GitHub Actions ECR Push Policy\"\n\n  policy = jsonencode({\n    Version = \"2012-10-17\"\n    Statement = [\n      {\n        Action = [\n          \"ecr:CompleteLayerUpload\",\n          \"ecr:GetAuthorizationToken\",\n          \"ecr:UploadLayerPart\",\n          \"ecr:InitiateLayerUpload\",\n          \"ecr:BatchCheckLayerAvailability\",\n          \"ecr:PutImage\",\n          \"ecr:DescribeRepositories\",\n          \"ecr:CreateRepository\"\n        ]\n        Effect   = \"Allow\"\n        Resource = \"*\"\n      },\n    ]\n  })\n}\n"
  },
  {
    "path": "modules/github/main.tf",
    "content": "locals {\n  cloud_provider = \"aws\"\n}\n\n# Configure GitHub variables & secrets for all scaffolded apps\n\nresource \"github_actions_organization_variable\" \"backstage_cloud_provider\" {\n  variable_name = \"CLOUD_PROVIDER\"\n  visibility    = \"all\"\n  value         = local.cloud_provider\n}\n\nresource \"github_actions_organization_variable\" \"backstage_aws_region\" {\n  variable_name = \"AWS_REGION\"\n  visibility    = \"all\"\n  value         = var.aws_region\n}\n\nresource \"github_actions_organization_variable\" \"backstage_aws_role_arn\" {\n  variable_name = \"AWS_ROLE_ARN\"\n  visibility    = \"all\"\n  value         = module.iam_github_oidc_role.arn\n}\n\nresource \"github_actions_organization_variable\" \"backstage_humanitec_org_id\" {\n  variable_name = \"HUMANITEC_ORG_ID\"\n  visibility    = \"all\"\n  value         = var.humanitec_org_id\n}\n\nresource \"github_actions_organization_secret\" \"backstage_humanitec_token\" {\n  secret_name     = \"HUMANITEC_TOKEN\"\n  visibility      = \"all\"\n  plaintext_value = var.humanitec_ci_service_user_token\n}\n"
  },
  {
    "path": "modules/github/providers.tf",
    "content": "terraform {\n  required_providers {\n    aws = {\n      source  = \"hashicorp/aws\"\n      version = \"~> 5.17\"\n    }\n    github = {\n      source  = \"integrations/github\"\n      version = \"~> 5.38\"\n    }\n  }\n  required_version = \">= 1.3.0\"\n}\n"
  },
  {
    "path": "modules/github/terraform.tfvars.example",
    "content": "\n# AWS region\naws_region = \"\"\n\n# GitHub org id\ngithub_org_id = \"\"\n\n# Humanitec CI Service User Token\nhumanitec_ci_service_user_token = \"\"\n\n# Humanitec Organization ID\nhumanitec_org_id = \"\""
  },
  {
    "path": "modules/github/variables.tf",
    "content": "variable \"aws_region\" {\n  description = \"AWS region\"\n  type        = string\n}\n\nvariable \"humanitec_org_id\" {\n  description = \"Humanitec Organization ID\"\n  type        = string\n\n  validation {\n    condition     = var.humanitec_org_id != null\n    error_message = \"Humanitec Organization ID must not be empty\"\n  }\n}\n\nvariable \"humanitec_ci_service_user_token\" {\n  description = \"Humanitec CI Service User Token\"\n  type        = string\n  sensitive   = true\n\n  validation {\n    condition     = var.humanitec_ci_service_user_token != null\n    error_message = \"Humanitec CI Service User Token must not be empty\"\n  }\n}\n\nvariable \"github_org_id\" {\n  description = \"GitHub org id\"\n  type        = string\n\n  validation {\n    condition     = var.github_org_id != null\n    error_message = \"GitHub org id must not be empty\"\n  }\n}\n"
  },
  {
    "path": "modules/portal-backstage/README.md",
    "content": "# Portal: Backstage\n\nThis module deploys the [Humanitec Reference Architecture Backstage](https://github.com/humanitec-architecture/backstage) as Application into a specific Humanitec Organization.\n\n## Terraform docs\n\n<!-- BEGIN_TF_DOCS -->\n### Requirements\n\n| Name | Version |\n|------|---------|\n| terraform | >= 1.3.0 |\n| humanitec | ~> 1.0 |\n\n### Providers\n\n| Name | Version |\n|------|---------|\n| humanitec | ~> 1.0 |\n\n### Modules\n\n| Name | Source | Version |\n|------|--------|---------|\n| backstage\\_postgres | github.com/humanitec-architecture/resource-packs-in-cluster//humanitec-resource-defs/postgres/basic | v2024-06-05 |\n| portal\\_backstage | github.com/humanitec-architecture/shared-terraform-modules//modules/portal-backstage | v2024-06-12 |\n\n### Resources\n\n| Name | Type |\n|------|------|\n| [humanitec_application.backstage](https://registry.terraform.io/providers/humanitec/humanitec/latest/docs/resources/application) | resource |\n| [humanitec_resource_definition_criteria.backstage_postgres](https://registry.terraform.io/providers/humanitec/humanitec/latest/docs/resources/resource_definition_criteria) | resource |\n\n### Inputs\n\n| Name | Description | Type | Default | Required |\n|------|-------------|------|---------|:--------:|\n| github\\_app\\_client\\_id | GitHub App Client ID | `string` | n/a | yes |\n| github\\_app\\_client\\_secret | GitHub App Client Secret | `string` | n/a | yes |\n| github\\_app\\_id | GitHub App ID | `string` | n/a | yes |\n| github\\_app\\_private\\_key | GitHub App Private Key | `string` | n/a | yes |\n| github\\_org\\_id | GitHub org id | `string` | n/a | yes |\n| github\\_webhook\\_secret | GitHub Webhook Secret | `string` | n/a | yes |\n| humanitec\\_ci\\_service\\_user\\_token | Humanitec CI Service User Token | `string` | n/a | yes |\n| humanitec\\_org\\_id | Humanitec Organization ID | `string` | n/a | yes |\n<!-- END_TF_DOCS -->\n"
  },
  {
    "path": "modules/portal-backstage/main.tf",
    "content": "resource \"humanitec_application\" \"backstage\" {\n  id   = \"backstage\"\n  name = \"backstage\"\n}\n\nlocals {\n  secrets = {\n    humanitec-token          = var.humanitec_ci_service_user_token\n    github-app-client-id     = var.github_app_client_id\n    github-app-client-secret = var.github_app_client_secret\n    github-app-private-key   = indent(2, var.github_app_private_key)\n    github-webhook-secret    = var.github_webhook_secret\n  }\n\n  secret_refs = {\n    for key, value in local.secrets : key => {\n      value = value\n    }\n  }\n}\n\nmodule \"portal_backstage\" {\n  source = \"github.com/humanitec-architecture/shared-terraform-modules//modules/portal-backstage?ref=v2024-06-12\"\n\n  cloud_provider = \"aws\"\n\n  humanitec_org_id                    = var.humanitec_org_id\n  humanitec_app_id                    = humanitec_application.backstage.id\n  humanitec_ci_service_user_token_ref = local.secret_refs[\"humanitec-token\"]\n\n  github_org_id                = var.github_org_id\n  github_app_client_id_ref     = local.secret_refs[\"github-app-client-id\"]\n  github_app_client_secret_ref = local.secret_refs[\"github-app-client-secret\"]\n  github_app_id                = var.github_app_id\n  github_app_private_key_ref   = local.secret_refs[\"github-app-private-key\"]\n  github_webhook_secret_ref    = local.secret_refs[\"github-webhook-secret\"]\n}\n\n# Configure required resources for backstage\n\nlocals {\n  res_def_prefix = \"backstage-\"\n}\n\n# in-cluster postgres\n\nmodule \"backstage_postgres\" {\n  source = \"github.com/humanitec-architecture/resource-packs-in-cluster//humanitec-resource-defs/postgres/basic?ref=v2024-06-05\"\n\n  prefix = local.res_def_prefix\n}\n\nresource \"humanitec_resource_definition_criteria\" \"backstage_postgres\" {\n  resource_definition_id = module.backstage_postgres.id\n  app_id                 = humanitec_application.backstage.id\n\n  force_delete = true\n}\n"
  },
  {
    "path": "modules/portal-backstage/providers.tf",
    "content": "terraform {\n  required_providers {\n    humanitec = {\n      source  = \"humanitec/humanitec\"\n      version = \"~> 1.0\"\n    }\n  }\n  required_version = \">= 1.3.0\"\n}\n"
  },
  {
    "path": "modules/portal-backstage/terraform.tfvars.example",
    "content": "\n# GitHub App Client ID\ngithub_app_client_id = \"\"\n\n# GitHub App Client Secret\ngithub_app_client_secret = \"\"\n\n# GitHub App ID\ngithub_app_id = \"\"\n\n# GitHub App Private Key\ngithub_app_private_key = \"\"\n\n# GitHub org id\ngithub_org_id = \"\"\n\n# GitHub Webhook Secret\ngithub_webhook_secret = \"\"\n\n# Humanitec CI Service User Token\nhumanitec_ci_service_user_token = \"\"\n\n# Humanitec Organization ID\nhumanitec_org_id = \"\""
  },
  {
    "path": "modules/portal-backstage/variables.tf",
    "content": "variable \"humanitec_org_id\" {\n  description = \"Humanitec Organization ID\"\n  type        = string\n}\n\nvariable \"humanitec_ci_service_user_token\" {\n  description = \"Humanitec CI Service User Token\"\n  type        = string\n  sensitive   = true\n}\n\nvariable \"github_org_id\" {\n  description = \"GitHub org id\"\n  type        = string\n}\n\nvariable \"github_app_client_id\" {\n  description = \"GitHub App Client ID\"\n  type        = string\n}\n\nvariable \"github_app_client_secret\" {\n  description = \"GitHub App Client Secret\"\n  type        = string\n}\n\nvariable \"github_app_id\" {\n  description = \"GitHub App ID\"\n  type        = string\n}\n\nvariable \"github_webhook_secret\" {\n  description = \"GitHub Webhook Secret\"\n  type        = string\n}\n\nvariable \"github_app_private_key\" {\n  description = \"GitHub App Private Key\"\n  type        = string\n}\n"
  },
  {
    "path": "providers.tf",
    "content": "terraform {\n  required_providers {\n    aws = {\n      source  = \"hashicorp/aws\"\n      version = \"~> 5.17\"\n    }\n    github = {\n      source  = \"integrations/github\"\n      version = \"~> 5.38\"\n    }\n    helm = {\n      source  = \"hashicorp/helm\"\n      version = \"~> 2.12\"\n    }\n    humanitec = {\n      source  = \"humanitec/humanitec\"\n      version = \"~> 1.0\"\n    }\n    kubernetes = {\n      source  = \"hashicorp/kubernetes\"\n      version = \"~> 2.25\"\n    }\n    random = {\n      source  = \"hashicorp/random\"\n      version = \"~> 3.5\"\n    }\n  }\n  required_version = \">= 1.3.0\"\n}\n\nprovider \"humanitec\" {\n  org_id = var.humanitec_org_id\n}\n\nprovider \"github\" {\n  owner = var.github_org_id\n}\n\nprovider \"aws\" {\n  region              = var.aws_region\n  allowed_account_ids = [var.aws_account_id]\n}\n\nprovider \"kubernetes\" {\n  host                   = module.base.eks_cluster_endpoint\n  cluster_ca_certificate = base64decode(module.base.eks_cluster_certificate_authority_data)\n\n  exec {\n    api_version = \"client.authentication.k8s.io/v1beta1\"\n    command     = \"aws\"\n    # This requires the awscli to be installed locally where Terraform is executed\n    args = [\"eks\", \"get-token\", \"--cluster-name\", module.base.eks_cluster_name]\n  }\n}\n\nprovider \"helm\" {\n  kubernetes {\n    host                   = module.base.eks_cluster_endpoint\n    cluster_ca_certificate = base64decode(module.base.eks_cluster_certificate_authority_data)\n\n    exec {\n      api_version = \"client.authentication.k8s.io/v1beta1\"\n      command     = \"aws\"\n      # This requires the awscli to be installed locally where Terraform is executed\n      args = [\"eks\", \"get-token\", \"--cluster-name\", module.base.eks_cluster_name]\n    }\n  }\n}\n"
  },
  {
    "path": "terraform.tfvars.example",
    "content": "\n# AWS Account (ID) to use\naws_account_id = \"\"\n\n# AWS region\naws_region = \"\"\n\n# Disk size in GB to use for EKS nodes\ndisk_size = 20\n\n# GitHub org id (required for Backstage)\ngithub_org_id = \"\"\n\n# Humanitec Organization ID (required for Backstage)\nhumanitec_org_id = \"\"\n\n# List of EC2 instances types to use for EKS nodes\ninstance_types = [\n  \"t3.large\"\n]\n\n# Deploy Backstage\nwith_backstage = false"
  },
  {
    "path": "variables.tf",
    "content": "variable \"aws_account_id\" {\n  description = \"AWS Account (ID) to use\"\n  type        = string\n}\n\nvariable \"aws_region\" {\n  description = \"AWS region\"\n  type        = string\n}\n\nvariable \"instance_types\" {\n  description = \"List of EC2 instances types to use for EKS nodes\"\n  type        = list(string)\n  default = [\n    \"t3.large\"\n  ]\n}\n\nvariable \"disk_size\" {\n  description = \"Disk size in GB to use for EKS nodes\"\n  type        = number\n  default     = 20\n}\n\nvariable \"with_backstage\" {\n  description = \"Deploy Backstage\"\n  type        = bool\n  default     = false\n}\n\nvariable \"github_org_id\" {\n  description = \"GitHub org id (required for Backstage)\"\n  type        = string\n  default     = null\n}\n\nvariable \"humanitec_org_id\" {\n  description = \"Humanitec Organization ID (required for Backstage)\"\n  type        = string\n  default     = null\n}\n"
  }
]