grada-run 0.40.15 → 0.40.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (43) hide show
  1. package/bin/cli.js +22 -18
  2. package/package.json +1 -1
  3. package/src/commands/add.js +70 -3
  4. package/src/commands/alerts.js +6 -3
  5. package/src/commands/apply.js +6 -3
  6. package/src/commands/db/backup.js +5 -2
  7. package/src/commands/db/connect.js +6 -3
  8. package/src/commands/db/enable-vector.js +5 -2
  9. package/src/commands/db/import.js +5 -2
  10. package/src/commands/db/migrate.js +38 -30
  11. package/src/commands/db/restore.js +5 -2
  12. package/src/commands/destroy.js +6 -3
  13. package/src/commands/doctor.js +5 -1
  14. package/src/commands/domain.js +5 -2
  15. package/src/commands/drift.js +6 -3
  16. package/src/commands/eject.js +5 -2
  17. package/src/commands/exec.js +6 -2
  18. package/src/commands/gc.js +6 -3
  19. package/src/commands/init.js +6 -3
  20. package/src/commands/logs.js +6 -2
  21. package/src/commands/mcp.js +5 -2
  22. package/src/commands/rollback.js +6 -3
  23. package/src/commands/sleep.js +5 -2
  24. package/src/commands/status.js +6 -2
  25. package/src/commands/wake.js +6 -3
  26. package/src/core/parser.js +16 -5
  27. package/src/utils/args.js +11 -5
  28. package/src/utils/aws.js +11 -4
  29. package/src/utils/command.js +20 -0
  30. package/src/utils/hcl.js +22 -0
  31. package/templates/github/deploy-lambda.yml +7 -0
  32. package/templates/github/deploy-static.yml +7 -0
  33. package/templates/github/deploy.yml +7 -0
  34. package/templates/github/drift.yml +4 -1
  35. package/templates/github/preview-lambda.yml +8 -1
  36. package/templates/github/preview.yml +12 -4
  37. package/templates/github/teardown.yml +16 -1
  38. package/templates/terraform/addons/redis.tf +2 -2
  39. package/templates/terraform/database-aurora-postgresql.tf +2 -12
  40. package/templates/terraform/database-mysql.tf +2 -12
  41. package/templates/terraform/database.tf +2 -12
  42. package/templates/terraform/main.tf +1 -1
  43. package/templates/terraform/network.tf +30 -6
@@ -5,6 +5,13 @@ on:
5
5
  branches:
6
6
  - {{DEPLOY_BRANCH}}
7
7
 
8
+ # Overlapping deploys race: each run registers its own revision and force-
9
+ # deploys, so a stale run finishing last would silently regress production.
10
+ # Superseded runs cancel instead — newest always wins.
11
+ concurrency:
12
+ group: deploy-${{ github.ref }}
13
+ cancel-in-progress: true
14
+
8
15
  env:
9
16
  AWS_REGION: {{REGION}}
10
17
  ECR_REPOSITORY: {{PROJECT_NAME}}{{RESOURCE_SUFFIX}}-repo
@@ -99,10 +99,13 @@ jobs:
99
99
  }
100
100
 
101
101
  - name: Notify Slack
102
- if: steps.plan.outputs.exitcode == '2' && secrets.SLACK_WEBHOOK_URL != ''
102
+ if: steps.plan.outputs.exitcode == '2'
103
103
  env:
104
104
  SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
105
105
  run: |
106
+ # GitHub rejects the secrets context in step-level if: expressions,
107
+ # so the absent-secret skip lives here instead of the condition.
108
+ if [ -z "$SLACK_WEBHOOK_URL" ]; then exit 0; fi
106
109
  SUMMARY=$(head -c 1500 terraform/plan.txt)
107
110
  jq -n \
108
111
  --arg repo "$GITHUB_REPOSITORY" \
@@ -4,6 +4,13 @@ on:
4
4
  pull_request:
5
5
  types: [opened, synchronize, reopened]
6
6
 
7
+ # One runner per PR: rapid pushes cancel superseded previews instead of
8
+ # overlapping applies on the same workspace. Shares its group with
9
+ # teardown.yml, which queues (never cancels) behind an in-flight deploy.
10
+ concurrency:
11
+ group: preview-${{ github.event.pull_request.number }}
12
+ cancel-in-progress: true
13
+
7
14
  env:
8
15
  AWS_REGION: {{REGION}}
9
16
  ECR_REPOSITORY: {{PROJECT_NAME}}{{RESOURCE_SUFFIX}}-repo
@@ -48,7 +55,7 @@ jobs:
48
55
  id: tf-apply
49
56
  working-directory: ./terraform
50
57
  run: |
51
- terraform init
58
+ terraform init -input=false
52
59
  # Create or select the workspace specific to this PR
53
60
  terraform workspace select -or-create ${{ env.WORKSPACE }}
54
61
  terraform apply -auto-approve
@@ -4,6 +4,13 @@ on:
4
4
  pull_request:
5
5
  types: [opened, synchronize, reopened]
6
6
 
7
+ # One runner per PR: rapid pushes cancel superseded previews instead of
8
+ # overlapping applies on the same workspace. Shares its group with
9
+ # teardown.yml, which queues (never cancels) behind an in-flight deploy.
10
+ concurrency:
11
+ group: preview-${{ github.event.pull_request.number }}
12
+ cancel-in-progress: true
13
+
7
14
  env:
8
15
  AWS_REGION: {{REGION}}
9
16
  ECR_REPOSITORY: {{PROJECT_NAME}}{{RESOURCE_SUFFIX}}-repo
@@ -48,14 +55,15 @@ jobs:
48
55
  id: tf-apply
49
56
  working-directory: ./terraform
50
57
  run: |
51
- terraform init
58
+ terraform init -input=false
52
59
  # Create or select the workspace specific to this PR
53
60
  terraform workspace select -or-create ${{ env.WORKSPACE }}
54
61
  terraform apply -auto-approve
55
62
 
56
- # Extract the ALB URL to post to GitHub
57
- ALB_URL=$(terraform output -raw alb_direct_url)
58
- echo "PREVIEW_URL=$ALB_URL" >> $GITHUB_ENV
63
+ # Extract the CloudFront URL to post to GitHub (the ALB origin
64
+ # accepts CloudFront edges only — its direct URL is not browsable)
65
+ PREVIEW_URL=$(terraform output -raw cloudfront_url)
66
+ echo "PREVIEW_URL=$PREVIEW_URL" >> $GITHUB_ENV
59
67
 
60
68
  - name: Comment PR
61
69
  uses: actions/github-script@v7
@@ -4,6 +4,12 @@ on:
4
4
  pull_request:
5
5
  types: [closed]
6
6
 
7
+ # Shared with the preview workflow: teardown queues behind an in-flight
8
+ # deploy instead of racing it on the state lock. No cancel-in-progress —
9
+ # a teardown must run to completion, never be skipped.
10
+ concurrency:
11
+ group: preview-${{ github.event.pull_request.number }}
12
+
7
13
  env:
8
14
  AWS_REGION: {{REGION}}
9
15
  WORKSPACE: pr-${{ github.event.pull_request.number }}
@@ -33,7 +39,16 @@ jobs:
33
39
  - name: Terraform Init & Destroy
34
40
  working-directory: ./terraform
35
41
  run: |
36
- terraform init
42
+ terraform init -input=false
43
+ # PRs that never got a preview (early failure, pre-previews PR)
44
+ # have no workspace — exit green instead of failing the run. But
45
+ # a failed listing (backend outage, dead creds) must stay red:
46
+ # matching against empty output would leak the stack silently.
47
+ WORKSPACES=$(terraform workspace list 2>&1) || { echo "$WORKSPACES"; exit 1; }
48
+ if ! printf '%s\n' "$WORKSPACES" | sed 's/^[* ]*//' | grep -qx "${{ env.WORKSPACE }}"; then
49
+ echo "No preview workspace ${{ env.WORKSPACE }} — nothing to tear down."
50
+ exit 0
51
+ fi
37
52
  # Select the PR workspace
38
53
  terraform workspace select ${{ env.WORKSPACE }}
39
54
  # Destroy all resources in this workspace safely
@@ -5,10 +5,10 @@
5
5
  # Billing: fixed ~$9.49/mo baseline (cache.t4g.micro Valkey 8.0 at $0.013/hr
6
6
  # in us-east-2); $0 intra-AZ VPC data transfer.
7
7
 
8
- # --- ElastiCache Subnet Group ---
8
+ # --- ElastiCache Subnet Group (isolated subnets, shared with RDS) ---
9
9
  resource "aws_elasticache_subnet_group" "redis" {
10
10
  name = "${local.app_name}-redis-subnets"
11
- subnet_ids = aws_subnet.public[*].id
11
+ subnet_ids = aws_subnet.db_isolated[*].id
12
12
  }
13
13
 
14
14
  # --- Redis Security Group (ECS tasks only) ---
@@ -1,15 +1,5 @@
1
- # 1. Isolated Subnets (No Internet Gateway routing)
2
- resource "aws_subnet" "db_isolated" {
3
- count = 2
4
- vpc_id = aws_vpc.main.id
5
- cidr_block = cidrsubnet(aws_vpc.main.cidr_block, 8, count.index + 10)
6
- availability_zone = data.aws_availability_zones.available.names[count.index]
7
-
8
- tags = {
9
- Name = "${local.app_name}-db-isolated-${count.index}"
10
- }
11
- }
12
-
1
+ # 1. Database Subnet Group (isolated subnets live in network.tf, shared
2
+ # with ElastiCache so every data-plane group stays off public subnets)
13
3
  resource "aws_db_subnet_group" "main" {
14
4
  name = "${local.app_name}-db-subnet-group"
15
5
  subnet_ids = aws_subnet.db_isolated[*].id
@@ -1,15 +1,5 @@
1
- # 1. Isolated Subnets (No Internet Gateway routing)
2
- resource "aws_subnet" "db_isolated" {
3
- count = 2
4
- vpc_id = aws_vpc.main.id
5
- cidr_block = cidrsubnet(aws_vpc.main.cidr_block, 8, count.index + 10)
6
- availability_zone = data.aws_availability_zones.available.names[count.index]
7
-
8
- tags = {
9
- Name = "${local.app_name}-db-isolated-${count.index}"
10
- }
11
- }
12
-
1
+ # 1. Database Subnet Group (isolated subnets live in network.tf, shared
2
+ # with ElastiCache so every data-plane group stays off public subnets)
13
3
  resource "aws_db_subnet_group" "main" {
14
4
  name = "${local.app_name}-db-subnet-group"
15
5
  subnet_ids = aws_subnet.db_isolated[*].id
@@ -1,15 +1,5 @@
1
- # 1. Isolated Subnets (No Internet Gateway routing)
2
- resource "aws_subnet" "db_isolated" {
3
- count = 2
4
- vpc_id = aws_vpc.main.id
5
- cidr_block = cidrsubnet(aws_vpc.main.cidr_block, 8, count.index + 10)
6
- availability_zone = data.aws_availability_zones.available.names[count.index]
7
-
8
- tags = {
9
- Name = "${local.app_name}-db-isolated-${count.index}"
10
- }
11
- }
12
-
1
+ # 1. Database Subnet Group (isolated subnets live in network.tf, shared
2
+ # with ElastiCache so every data-plane group stays off public subnets)
13
3
  resource "aws_db_subnet_group" "main" {
14
4
  name = "${local.app_name}-db-subnet-group"
15
5
  subnet_ids = aws_subnet.db_isolated[*].id
@@ -280,7 +280,7 @@ resource "aws_iam_role_policy" "secrets_policy" {
280
280
 
281
281
  # --- Outputs ---
282
282
  output "alb_direct_url" {
283
- description = "Direct Load Balancer URL (Bypasses CloudFront/CDN)"
283
+ description = "Load Balancer origin URL (accepts CloudFront edge traffic only; direct browser access needs a temporary SG rule)"
284
284
  value = "http://${aws_lb.main.dns_name}"
285
285
  }
286
286
 
@@ -47,18 +47,42 @@ resource "aws_route_table_association" "public" {
47
47
  route_table_id = aws_route_table.public.id
48
48
  }
49
49
 
50
+ # Isolated Subnets (No Internet Gateway routing). Shared by every data-plane
51
+ # subnet group (RDS, ElastiCache) so caches never need public subnets. The
52
+ # historical db_isolated address is kept deliberately: renaming would force
53
+ # subnet replacement on existing trees.
54
+ resource "aws_subnet" "db_isolated" {
55
+ count = 2
56
+ vpc_id = aws_vpc.main.id
57
+ cidr_block = cidrsubnet(aws_vpc.main.cidr_block, 8, count.index + 10)
58
+ availability_zone = data.aws_availability_zones.available.names[count.index]
59
+
60
+ tags = {
61
+ Name = "${local.app_name}-db-isolated-${count.index}"
62
+ }
63
+ }
64
+
50
65
  # --- Security Groups ---
51
- # ALB SG: Allow public internet access on HTTP
66
+
67
+ # Origin-facing CloudFront edge IPs: the only callers the ALB accepts.
68
+ data "aws_ec2_managed_prefix_list" "cloudfront" {
69
+ name = "com.amazonaws.global.cloudfront.origin-facing"
70
+ }
71
+
72
+ # ALB SG: Allow HTTP from CloudFront edges only (no direct internet access)
52
73
  resource "aws_security_group" "alb" {
53
74
  name = "${local.app_name}-alb-sg"
54
- description = "Allow inbound HTTP to ALB"
75
+ description = "Allow inbound HTTP to ALB from CloudFront only"
55
76
  vpc_id = aws_vpc.main.id
56
77
 
57
78
  ingress {
58
- from_port = 80
59
- to_port = 80
60
- protocol = "tcp"
61
- cidr_blocks = ["0.0.0.0/0"]
79
+ from_port = 80
80
+ to_port = 80
81
+ protocol = "tcp"
82
+ # CloudFront-only: the origin speaks plaintext HTTP, so direct browser
83
+ # access would bypass the CDN (and TLS on domained trees). Debugging
84
+ # via the direct URL needs a temporary personal-IP rule.
85
+ prefix_list_ids = [data.aws_ec2_managed_prefix_list.cloudfront.id]
62
86
  }
63
87
 
64
88
  egress {