-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(deploy): add eks-repo-creator buildspec; fix partition refs in IA…
…M policies Adds deploy/buildspec-eks-repo-creator.yml — the CodeBuild buildspec for the eks-terragrunt-repo-creator project, versioned alongside the Terraform that manages it rather than referencing terraform-eks-deployment. Currently points at REPO_BRANCH=test_cluster (PR #16 under review) — must be updated to 'main' once PR #16 merges. Also fixes all IAM policy ARN constructions to use data.aws_partition.current instead of data.aws_caller_identity.current (caller_identity has no .partition attribute in this provider version).
- Loading branch information
Dave Arnold
committed
Apr 21, 2026
1 parent
f37b6c6
commit 237ab9b
Showing
2 changed files
with
97 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,89 @@ | ||
| version: 0.2 | ||
| # buildspec-eks-repo-creator.yml | ||
| # | ||
| # Used by the CodeBuild project eks-terragrunt-repo-creator, which is triggered | ||
| # by the Lambda (eks-terragrunt-repo-gen-template-automation) to create an EKS | ||
| # cluster GitHub repository. | ||
| # | ||
| # Required environment variables (injected by the Lambda as overrides): | ||
| # TF_VAR_name — cluster / repo name | ||
| # TF_VAR_environment — environment (dev / nonprod / prod) | ||
| # TF_VAR_region — AWS region (e.g. us-gov-west-1) | ||
| # TF_VAR_cluster_config — JSON object with account_name, aws_account_id, etc. | ||
| # TF_VAR_finops — JSON object with finops project_name / project_number | ||
| # GITHUB_TOKEN — GitHub PAT (passed from Lambda's Secrets Manager read) | ||
| # GITHUB_OWNER — GitHub org (default: SCT-Engineering) | ||
| # GITHUB_BASE_URL — GHE base URL (e.g. https://github.e.it.census.gov) | ||
|
|
||
| env: | ||
| variables: | ||
| TF_VERSION: "1.9.1" | ||
| ASSETS_BUCKET: "csvd-packer-pipeline-assets" | ||
| REPO_HOST: "github.e.it.census.gov" | ||
| REPO_ORG: "SCT-Engineering" | ||
| REPO_NAME: "terraform-eks-deployment" | ||
| REPO_BRANCH: "test_cluster" # PR #16 — switch back to main after merge | ||
| # Disable TLS verification for Census GHE (Census CA cert not trusted by default) | ||
| GIT_SSL_NO_VERIFY: "true" | ||
| TF_VAR_run_in_codebuild: "true" | ||
| TF_CLI_ARGS: "-no-color" | ||
| # Census proxy — required for registry.terraform.io provider downloads | ||
| HTTPS_PROXY: "http://proxy.tco.census.gov:3128" | ||
| HTTP_PROXY: "http://proxy.tco.census.gov:3128" | ||
| # Exclude AWS-internal endpoints and Census GHE from the proxy | ||
| NO_PROXY: "169.254.169.254,169.254.170.2,s3.us-gov-west-1.amazonaws.com,s3.amazonaws.com,.amazonaws.com,.us-gov-west-1.amazonaws.com,github.e.it.census.gov" | ||
|
|
||
| phases: | ||
| install: | ||
| commands: | ||
| # ── Install Census Bureau CA certificate ────────────────────────────── | ||
| # The Census GHE TLS cert is issued by the Census Bureau CA which is not | ||
| # trusted by the CodeBuild Amazon Linux 2 trust store by default. | ||
| - | | ||
| aws s3 cp "s3://${ASSETS_BUCKET}/certs/census-ca.pem" \ | ||
| /etc/pki/ca-trust/source/anchors/census-ca.pem 2>/dev/null \ | ||
| && update-ca-trust \ | ||
| && echo "Census CA cert installed" \ | ||
| || echo "WARNING: could not install Census CA cert (continuing anyway)" | ||
| # ── Install Terraform ───────────────────────────────────────────────── | ||
| - | | ||
| if ! command -v terraform &>/dev/null; then | ||
| TF_ZIP="terraform_${TF_VERSION}_linux_amd64.zip" | ||
| echo "Installing Terraform ${TF_VERSION}..." | ||
| aws s3 cp "s3://${ASSETS_BUCKET}/terraform/${TF_ZIP}" /tmp/${TF_ZIP} 2>/dev/null \ | ||
| || curl -fsSL "https://releases.hashicorp.com/terraform/${TF_VERSION}/${TF_ZIP}" -o /tmp/${TF_ZIP} | ||
| unzip -oq /tmp/${TF_ZIP} -d /usr/local/bin/ | ||
| chmod +x /usr/local/bin/terraform | ||
| rm /tmp/${TF_ZIP} | ||
| fi | ||
| - terraform version | ||
|
|
||
| # ── Install Python dependencies for post-apply scripts ─────────────── | ||
| - pip3 install --quiet httpx rich | ||
|
|
||
| # ── Clone terraform-eks-deployment ─────────────────────────────────── | ||
| - | | ||
| git config --global credential.helper \ | ||
| "!f() { echo username=x-access-token; echo password=${GITHUB_TOKEN}; }; f" | ||
| git clone --depth 1 --branch "${REPO_BRANCH}" \ | ||
| "https://${REPO_HOST}/${REPO_ORG}/${REPO_NAME}.git" \ | ||
| /tmp/eks-deploy | ||
| - echo "Cloned ${REPO_ORG}/${REPO_NAME} @ $(git -C /tmp/eks-deploy rev-parse --short HEAD)" | ||
|
|
||
| build: | ||
| commands: | ||
| - cd /tmp/eks-deploy | ||
| - echo "=== terraform init ===" | ||
| - terraform init -no-color | ||
| - echo "=== terraform apply ===" | ||
| - terraform apply -auto-approve -no-color | ||
|
|
||
| post_build: | ||
| commands: | ||
| - | | ||
| if [ "${CODEBUILD_BUILD_SUCCEEDING}" = "0" ]; then | ||
| echo "Build FAILED — check logs above" | ||
| else | ||
| echo "Build SUCCEEDED — repository created" | ||
| fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters