Skip to content

Fix script paths and kubectl context matching#53

Merged
sdpoueme merged 1 commit intoaws-solutions-library-samples:mainfrom
jpvelasco:fix/script-paths-and-context-matching
Mar 31, 2026
Merged

Fix script paths and kubectl context matching#53
sdpoueme merged 1 commit intoaws-solutions-library-samples:mainfrom
jpvelasco:fix/script-paths-and-context-matching

Conversation

@jpvelasco
Copy link
Copy Markdown
Contributor

Fixes #52

Summary

  • Script paths: Replace path.cwd with local.repo_root (path.module/../..) in all Terraform null_resource provisioners. When deploying manually per README (cd terraform/intra-cluster && terraform apply), path.cwd resolves to the terraform directory, not the repo root where scripts/ and manifests/ live. This caused every post-install script (TLS config, ClusterIssuer, Open Match ingress, port mapping) to fail silently under nohup. Also fixes the missing ClusterIssuer on Cluster 2 (the manifest was never applied because the path was wrong).
  • Context matching: Anchor all kubectl context grep patterns from grep ${CLUSTER_NAME} to grep "/${CLUSTER_NAME}$" across 14 scripts and both buildspec files. Prevents failures when multiple EKS contexts share a name prefix.

Files Changed

Area Files Change
Terraform terraform/intra-cluster/main.tf Add repo_root local, replace 6x path.cwd
Terraform terraform/extra-cluster/main.tf Add repo_root local, replace 2x path.cwd
Scripts 14 files in scripts/ Anchor grep with "/${VAR}$"
CI buildspec.yml, cleanup-buildspec.yml Same grep fix

Test plan

  • terraform validate passes for intra-cluster and extra-cluster
  • Zero path.cwd references remaining in terraform/
  • Zero unanchored grep ${CLUSTER patterns remaining in scripts/
  • Full deploy to verify scripts find manifests and switch contexts correctly

Replace path.cwd with local.repo_root (path.module/../..) in all
Terraform null_resource provisioners. path.cwd resolves to the
terraform directory when running from within it, but scripts and
manifests live at the repo root. path.module is stable regardless
of invocation method.

Anchor all kubectl context grep patterns from grep ${CLUSTER_NAME}
to grep "/${CLUSTER_NAME}$" to prevent partial matches when multiple
EKS contexts share a name prefix.
@sdpoueme sdpoueme self-requested a review March 31, 2026 17:44
@sdpoueme sdpoueme self-assigned this Mar 31, 2026
Copy link
Copy Markdown
Contributor

@sdpoueme sdpoueme left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed changes and they are aligned with the intended flows.

@sdpoueme sdpoueme merged commit c3d9c80 into aws-solutions-library-samples:main Mar 31, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Scripts fail on manual deploy: wrong paths and ambiguous kubectl context matching

2 participants