Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: CodeBuild+Terraform runtime for EKS repo creation (#17)
* fix: dynamic paths in rendered_files + HTTPS module source for CodeBuild - Replace placeholder paths (environment/region/vpc/cluster/) with var.environment / var.region / var.cluster_config.vpc_name / var.name so managed_extra_files land in the correct Terragrunt hierarchy - Change CSVD/terraform-github-repo source from SSH (git@) to HTTPS (git::https://) to work inside CodeBuild without SSH agent * feat: add buildspec.yml for CodeBuild repo-creator project Buildspec used by the 'eks-terragrunt-repo-creator' CodeBuild project triggered by the Lambda function. Downloads Terraform from S3 assets bucket, clones this repo using GITHUB_TOKEN env var, then runs: terraform init -no-color terraform apply -auto-approve -no-color TF_VAR_* env vars are injected by the Lambda as CodeBuild environment variable overrides. * docs: update callnotes with Step 1-4 DONE status for pivot plan * fix: correct REPO_ORG from CSVD to SCT-Engineering The terraform-eks-deployment repo lives in SCT-Engineering, not CSVD. CSVD would have caused git clone 404 in CodeBuild. * fix: add REPO_BRANCH and use it in git clone - Add REPO_BRANCH env var (currently fix/eca-copilot-instructions-and-callnotes) pointing to the branch with dynamic path fixes and HTTPS module source - Pass --branch to git clone so CodeBuild checks out the right code - Update REPO_BRANCH to 'main' once the fix branch is merged * fix: bump TF_VERSION from 1.9.0 to 1.9.1 terraform_1.9.0 zip was not in s3://csvd-packer-pipeline-assets/terraform/. Uploaded terraform_1.9.1_linux_amd64.zip to that path from local tfenv install. Public releases.hashicorp.com is blocked by Census network proxy. * fix: add HTTPS_PROXY/NO_PROXY to buildspec for registry.terraform.io access registry.terraform.io is blocked directly inside CodeBuild (Census network). Must route through http://proxy.tco.census.gov:3128. NO_PROXY excludes AWS-internal endpoints (.amazonaws.com) from proxy. * fix: widen github provider constraint to >= 6.11.0, drop stale lock file CSVD/terraform-github-repo module requires ~> 6.11; workspace had >= 6.6.0, < 6.7.0 which is incompatible. Lock file was pinned to 6.6.0 — delete so terraform init regenerates it against the updated constraint. * fix: add provider "github" block with insecure=true for Census GHE TLS The Census GHE TLS cert is signed by the Census internal CA which is not present in the CodeBuild container trust store. insecure=true disables x509 verification so terraform apply can call the GHE API. * fix: install Census CA cert + add GHE to NO_PROXY in CodeBuild buildspec - Download census-ca.pem from S3 assets bucket and add to Amazon Linux 2 trust store via update-ca-trust during INSTALL phase - Add github.e.it.census.gov to NO_PROXY so Terraform provider connects directly (not through proxy) and trusts Census CA chain - Keep insecure=true in providers.tf as belt-and-suspenders * docs: rewrite copilot-instructions to reflect CodeBuild+Terraform architecture - Replace 'Lambda-Only Approach' and 'Do NOT suggest CodeBuild' sections - Document full buildspec.yml runtime environment (proxy, CA cert, TF binary from S3) - Add complete Key Resources table with CodeBuild projects and token sources - Add Important Runtime Notes section with Census-specific networking requirements - Update What NOT to Do section with correct guidance * chore: commit callnotes updates and whitespace alignment in examples * docs: replace duplicated SC deployment section with cross-reference The SC Product Deployment Methods section was near-identical to the canonical version in lambda-template-repo-generator. Replace with a concise cross-reference to keep a single source of truth. * feat: rename template placeholder dirs via GitHub API after repo creation Add scripts/rename_template_dirs.py (Python, httpx + rich) that calls the GitHub API to delete environment/region/vpc/cluster/ placeholder paths from the repo-init PR branch and re-add the eks-*/terragrunt.hcl files at their correct computed paths: environment/region/vpc/cluster/eks-*/terragrunt.hcl → ${environment}/${region}/${vpc_name}/${cluster_name}/eks-*/terragrunt.hcl Files already rendered by managed_extra_files (account.hcl, region.hcl, vpc.hcl, cluster.hcl) are deleted from the placeholder paths but not re-added — Terraform already wrote them with real values. Controlled by var.run_in_codebuild (default false). buildspec.yml sets TF_VAR_run_in_codebuild=true so the null_resource only runs in CodeBuild. Also adds the null provider to providers.tf and pip3 install of httpx+rich to the buildspec install phase. --------- Co-authored-by: Your Name <user@example.com>
- Loading branch information