belt 0.3.6 → 0.3.8
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.
- checksums.yaml +4 -4
- data/CHANGELOG.md +18 -1
- data/lib/belt/cli/app_detection.rb +26 -1
- data/lib/belt/cli/deploy_command.rb +13 -0
- data/lib/belt/version.rb +1 -1
- data/lib/templates/module/dns.tf.erb +4 -0
- data/lib/templates/module/frontend.tf.erb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 20fce17142b2c69d75437a4c0a1c74f430674a5d68d1ca8e5e26a2f29a801d04
|
|
4
|
+
data.tar.gz: 4238c56a47ec43f5816f3abf1a8d5a85457a0216fa59940d42a773bdb13e8965
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: aacc4008ae9096011385a7cebf597a1a96b68cdaa14ca3119e659fcbdac06b095cdb946116463d75885acefe84ecca0dd3ae7c60390462c5631701f5577c70e9
|
|
7
|
+
data.tar.gz: 917bbc217bc7573bc37a45990867dafff8ba91e3a6b3788b98b6ff2db7e6543e09a20ac9bb8209cdbb97fc80241ba74ce5c53f4d1dcc2cb3c22eb6652a89f3a4
|
data/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,23 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
-
##
|
|
3
|
+
## 0.3.8
|
|
4
|
+
|
|
5
|
+
### Bug Fix
|
|
6
|
+
|
|
7
|
+
- **S3 bucket naming with underscored app names**: The module template now sanitizes
|
|
8
|
+
`var.app_name` for S3 bucket names by replacing underscores with hyphens. Apps named
|
|
9
|
+
with underscores (e.g. `feature_parity`) previously generated invalid bucket names
|
|
10
|
+
since S3 follows DNS naming rules which prohibit underscores.
|
|
11
|
+
|
|
12
|
+
## 0.3.7
|
|
13
|
+
|
|
14
|
+
### Bug Fix
|
|
15
|
+
|
|
16
|
+
- **App name detection in worktrees**: `detect_app_name` now checks
|
|
17
|
+
`infrastructure/*/variables.tf` for `variable "app_name" { default = "..." }`
|
|
18
|
+
before falling back to the directory name. Fixes incorrect Lambda function
|
|
19
|
+
lookups (e.g. `belt logs`) when running from a git worktree whose directory
|
|
20
|
+
name doesn't match the actual app name.
|
|
4
21
|
|
|
5
22
|
## 0.3.6
|
|
6
23
|
|
|
@@ -17,7 +17,7 @@ module Belt
|
|
|
17
17
|
end
|
|
18
18
|
|
|
19
19
|
# Detects the application name.
|
|
20
|
-
#
|
|
20
|
+
# Priority: terraform.tfvars app_name > variables.tf default > directory name.
|
|
21
21
|
def detect_app_name
|
|
22
22
|
# Check any environment tfvars for the app_name
|
|
23
23
|
Dir.glob('infrastructure/*/terraform.tfvars').each do |f|
|
|
@@ -26,6 +26,10 @@ module Belt
|
|
|
26
26
|
return match[1] if match
|
|
27
27
|
end
|
|
28
28
|
|
|
29
|
+
# Check variables.tf for a default app_name value
|
|
30
|
+
name = detect_app_name_from_variables_tf
|
|
31
|
+
return name if name
|
|
32
|
+
|
|
29
33
|
# Fall back to directory name
|
|
30
34
|
File.basename(Dir.pwd)
|
|
31
35
|
end
|
|
@@ -67,6 +71,27 @@ module Belt
|
|
|
67
71
|
def find_schema_file_path
|
|
68
72
|
find_contracts_file_path
|
|
69
73
|
end
|
|
74
|
+
|
|
75
|
+
private
|
|
76
|
+
|
|
77
|
+
# Parses `variable "app_name" { default = "..." }` from any environment's variables.tf.
|
|
78
|
+
# This handles the common pattern where app_name is a Terraform variable with a default
|
|
79
|
+
# rather than being set directly in terraform.tfvars.
|
|
80
|
+
def detect_app_name_from_variables_tf
|
|
81
|
+
Dir.glob('infrastructure/*/variables.tf').each do |f|
|
|
82
|
+
content = File.read(f)
|
|
83
|
+
# Match the app_name variable block and extract its default value
|
|
84
|
+
next unless content.match?(/variable\s+"app_name"/)
|
|
85
|
+
|
|
86
|
+
# Extract default from within the variable block
|
|
87
|
+
block_match = content.match(/variable\s+"app_name"\s*\{([^}]*)\}/m)
|
|
88
|
+
next unless block_match
|
|
89
|
+
|
|
90
|
+
default_match = block_match[1].match(/default\s*=\s*"([^"]+)"/)
|
|
91
|
+
return default_match[1] if default_match
|
|
92
|
+
end
|
|
93
|
+
nil
|
|
94
|
+
end
|
|
70
95
|
end
|
|
71
96
|
end
|
|
72
97
|
end
|
|
@@ -321,6 +321,19 @@ module Belt
|
|
|
321
321
|
return match[1] if match
|
|
322
322
|
end
|
|
323
323
|
|
|
324
|
+
# Try variables.tf for a default app_name value
|
|
325
|
+
vars_file = File.join(@infra_dir, @env, 'variables.tf')
|
|
326
|
+
if File.exist?(vars_file)
|
|
327
|
+
content = File.read(vars_file)
|
|
328
|
+
if content.match?(/variable\s+"app_name"/)
|
|
329
|
+
block_match = content.match(/variable\s+"app_name"\s*\{([^}]*)\}/m)
|
|
330
|
+
if block_match
|
|
331
|
+
default_match = block_match[1].match(/default\s*=\s*"([^"]+)"/)
|
|
332
|
+
return default_match[1] if default_match
|
|
333
|
+
end
|
|
334
|
+
end
|
|
335
|
+
end
|
|
336
|
+
|
|
324
337
|
# Fall back to directory name
|
|
325
338
|
File.basename(@project_root)
|
|
326
339
|
end
|
data/lib/belt/version.rb
CHANGED
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
# Convention: prod → mydomain.com, other envs → <env>.mydomain.com
|
|
3
3
|
|
|
4
4
|
locals {
|
|
5
|
+
# S3 bucket names follow DNS rules — underscores are not allowed.
|
|
6
|
+
# App names often use underscores (Ruby conventions); replace for S3/resource naming.
|
|
7
|
+
s3_safe_name = replace(var.app_name, "_", "-")
|
|
8
|
+
|
|
5
9
|
# Determine the domain for this environment
|
|
6
10
|
app_domain = var.domain != "" ? (
|
|
7
11
|
var.environment == "prod" ? var.domain : "${var.environment}.${var.domain}"
|
|
@@ -11,7 +11,7 @@ resource "random_string" "<%= @tf_name %>_suffix" {
|
|
|
11
11
|
|
|
12
12
|
# S3 bucket for frontend static assets
|
|
13
13
|
resource "aws_s3_bucket" "<%= @tf_name %>" {
|
|
14
|
-
bucket = "${
|
|
14
|
+
bucket = "${local.s3_safe_name}-<%= @bucket_slug %>-${var.environment}-${random_string.<%= @tf_name %>_suffix.result}"
|
|
15
15
|
force_destroy = true
|
|
16
16
|
|
|
17
17
|
lifecycle {
|