belt 0.1.3 → 0.1.4

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b12c5b4c22f46e0d4c80c10de7ee88f41bbcbb8a8e14a68b9033d19979a6c5af
4
- data.tar.gz: d699a6f241fb01a111545450cb024d409e099d9e8617b788eee6fa1a47021a20
3
+ metadata.gz: d40f2f591f9daeb3ee7a04cebbb5399268bb181771ccaeddb036ca100159dcfd
4
+ data.tar.gz: 77a31c0cf454675261c2103cfc66ba391d879a6fdd24b7f7df2a05fdf7a3313c
5
5
  SHA512:
6
- metadata.gz: c1a17ba50a432b6f84103129394524c1fcaf40abadc89eb59dec7dd93b9e68ef6fda35444c45486c06f030d123816c7ac99b4d7b9320ba02485d9b70716cdb46
7
- data.tar.gz: dab18cbb83517e05e404755923b6ce90dd45a8e155516e07649c63285f83f7ef0ec3d5cc8d62f9f7dd08553f8596d5ed0bb0298fc687a8167c0482bee44492dd
6
+ metadata.gz: b8e1a4a0bb6127fe6216f11f218b4ad9c835acf04b45b163c711ebec98dd9153016b8dc09136bfeeea1b34a6f83d45831e407aa5db831601872a5df1d303f0ad
7
+ data.tar.gz: b8dc9e16e672b73b99afcae96d268c8ab8d7eac0fbd30b5a82bffcc6f34b6a4189b1c14af84b55d0d5d1458de088c91984a41ff9bd5e30b5264a9e24af3444f6
data/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # Changelog
2
2
 
3
+ ## Unreleased
4
+
5
+ ## 0.1.4
6
+
7
+ ### Bug fixes
8
+
9
+ - Accept optional `environment` keyword on terraform commands so `belt destroy environment dev` works (mirrors `belt generate environment`). Short form `belt destroy dev` still works.
10
+ - Sanitize app names for S3 bucket names in `belt setup state` (and env/frontend templates): underscores are converted to hyphens so names like `my_app` produce valid buckets (`my-app-terraform-state`)
11
+
3
12
  ## 0.1.1
4
13
 
5
14
  ### `belt routes` CLI command
data/README.md CHANGED
@@ -112,17 +112,18 @@ That's it. `lambda_handler` is automatically your Lambda function handler. It:
112
112
  - Catches unhandled errors and returns proper CORS-enabled error responses
113
113
  - Calls your `execute` method for routing
114
114
 
115
- ### 5. Configure the Belt Terraform provider
115
+ ### 5. Configure the Conveyor Belt Terraform provider
116
116
 
117
- The Belt Terraform provider (formerly Dispatcher) handles Lambda packaging, API Gateway routing, and IAM permissions.
117
+ The [Conveyor Belt](https://registry.terraform.io/providers/stowzilla/conveyor-belt) Terraform provider (formerly Dispatcher) handles Lambda packaging, API Gateway routing, and IAM permissions.
118
118
 
119
119
  Add the provider to your Terraform config:
120
120
 
121
121
  ```hcl
122
122
  terraform {
123
123
  required_providers {
124
- belt = {
125
- source = "stowzilla/belt"
124
+ conveyor-belt = {
125
+ source = "stowzilla/conveyor-belt"
126
+ version = "~> 0.0.1"
126
127
  }
127
128
  }
128
129
  }
@@ -11,6 +11,12 @@ module Belt
11
11
  end
12
12
  File.basename(Dir.pwd)
13
13
  end
14
+
15
+ # S3 bucket names follow DNS rules — underscores are not allowed.
16
+ # App names often use underscores (Ruby namespaces); convert for S3.
17
+ def s3_safe_name(name)
18
+ name.to_s.downcase.tr('_', '-')
19
+ end
14
20
  end
15
21
  end
16
22
  end
@@ -3,7 +3,17 @@
3
3
  module Belt
4
4
  module CLI
5
5
  module EnvResolver
6
+ # Resolve the target environment from CLI args or BELT_ENV.
7
+ #
8
+ # Accepts an optional "environment" keyword so terraform commands mirror
9
+ # `belt generate environment <name>`:
10
+ # belt destroy environment dev
11
+ # belt apply environment staging
12
+ # as well as the short form:
13
+ # belt destroy dev
6
14
  def self.resolve(args)
15
+ args.shift if args.first == 'environment'
16
+
7
17
  if args.first && !args.first.start_with?('-')
8
18
  args.shift
9
19
  else
@@ -134,9 +134,9 @@ module Belt
134
134
  if @custom_bucket
135
135
  @custom_bucket
136
136
  elsif @env_name
137
- "#{@app_name}-terraform-state-#{@env_name}"
137
+ s3_safe_name("#{@app_name}-terraform-state-#{@env_name}")
138
138
  else
139
- "#{@app_name}-terraform-state"
139
+ s3_safe_name("#{@app_name}-terraform-state")
140
140
  end
141
141
  end
142
142
 
@@ -11,10 +11,11 @@ module Belt
11
11
  env = EnvResolver.resolve(args)
12
12
 
13
13
  if env.nil?
14
- puts "Usage: belt #{action} <environment> [terraform flags...]"
14
+ puts "Usage: belt #{action} [environment] <name> [terraform flags...]"
15
15
  puts "\nYou can also set BELT_ENV to skip the environment argument."
16
16
  puts "\nExamples:"
17
17
  puts " belt #{action} wups"
18
+ puts " belt #{action} environment dev"
18
19
  puts " belt #{action} dev01"
19
20
  puts " BELT_ENV=wups belt #{action}"
20
21
  puts ' belt plan staging -target=module.lambda'
data/lib/belt/cli.rb CHANGED
@@ -89,11 +89,11 @@ module Belt
89
89
  setup tables <env> Generate DynamoDB tables from schema
90
90
  setup frontend <env> Generate S3 + CloudFront infrastructure
91
91
  deploy frontend <env> Build and deploy frontend to AWS
92
- init <env> terraform init for environment
93
- plan <env> terraform plan for environment
94
- apply <env> terraform apply for environment
95
- destroy <env> terraform destroy for environment
96
- output <env> terraform output for environment
92
+ init [environment] <env> terraform init for environment
93
+ plan [environment] <env> terraform plan for environment
94
+ apply [environment] <env> terraform apply for environment
95
+ destroy [environment] <env> terraform destroy for environment
96
+ output [environment] <env> terraform output for environment
97
97
  --version Show Belt version
98
98
 
99
99
  Rake Tasks:
data/lib/belt/version.rb CHANGED
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Belt
4
- VERSION = '0.1.3'
4
+ VERSION = '0.1.4'
5
5
  end
@@ -1,6 +1,6 @@
1
1
  terraform {
2
2
  backend "s3" {
3
- bucket = "<%= @app_name %>-terraform-state"
3
+ bucket = "<%= s3_safe_name(@app_name) %>-terraform-state"
4
4
  key = "<%= @env_name %>/terraform.tfstate"
5
5
  region = "us-east-1"
6
6
  encrypt = true
@@ -8,9 +8,9 @@ terraform {
8
8
  source = "hashicorp/random"
9
9
  version = "~> 3.0"
10
10
  }
11
- dispatcher = {
12
- source = "terraform.local/stowzilla/dispatcher"
13
- version = "99.0.0"
11
+ conveyor-belt = {
12
+ source = "stowzilla/conveyor-belt"
13
+ version = "~> 0.0.1"
14
14
  }
15
15
  }
16
16
  }
@@ -27,12 +27,12 @@ provider "aws" {
27
27
  }
28
28
  }
29
29
 
30
- provider "dispatcher" {
30
+ provider "conveyor-belt" {
31
31
  environment = var.environment
32
32
  aws_region = var.aws_region
33
33
  }
34
34
 
35
- resource "dispatcher" "main" {
35
+ resource "conveyor_belt" "main" {
36
36
  source = "${path.module}/../routes.tf.rb"
37
37
  app_name = var.app_name
38
38
  lambda_source_dir = "${path.module}/../../lambda"
@@ -9,7 +9,7 @@ resource "random_string" "frontend_suffix" {
9
9
 
10
10
  # S3 bucket for frontend static assets
11
11
  resource "aws_s3_bucket" "frontend" {
12
- bucket = "<%= @app_name %>-frontend-${var.environment}-${random_string.frontend_suffix.result}"
12
+ bucket = "<%= s3_safe_name(@app_name) %>-frontend-${var.environment}-${random_string.frontend_suffix.result}"
13
13
 
14
14
  lifecycle {
15
15
  ignore_changes = [bucket]
@@ -155,5 +155,5 @@ output "frontend_url" {
155
155
  }
156
156
 
157
157
  output "api_url" {
158
- value = values(dispatcher.main.api_gateway_urls)[0]
158
+ value = values(conveyor_belt.main.api_gateway_urls)[0]
159
159
  }
@@ -6,7 +6,7 @@ This file explains the project structure, tooling, and conventions for AI agents
6
6
 
7
7
  - **Belt** — CLI and runtime framework (like Rails for serverless). Provides Lambda handler, action router, controller base class, and CLI tooling.
8
8
  - **ActiveItem** — ActiveRecord-like ORM for DynamoDB. Models inherit from `ActiveItem::Base`.
9
- - **Dispatcher** — Terraform provider that reads a Ruby DSL (`routes.tf.rb`) and creates API Gateway + Lambda + IAM infrastructure.
9
+ - **Conveyor Belt** — Terraform provider that reads a Ruby DSL (`routes.tf.rb`) and creates API Gateway + Lambda + IAM infrastructure.
10
10
  - **Lambda Loadout** — Lambda cold-start optimizer (auto-required by Belt).
11
11
 
12
12
  ## Project Structure
@@ -23,7 +23,7 @@ This file explains the project structure, tooling, and conventions for AI agents
23
23
  │ ├── lib/routes/ # Route manifests (auto-generated)
24
24
  │ └── Gemfile # Lambda-specific dependencies
25
25
  ├── infrastructure/
26
- │ ├── routes.tf.rb # API routes (Dispatcher DSL)
26
+ │ ├── routes.tf.rb # API routes (Conveyor Belt DSL)
27
27
  │ ├── schema.tf.rb # Model schema definitions
28
28
  │ └── <env>/ # Per-environment Terraform configs
29
29
  ├── Gemfile # Project-level dependencies
@@ -44,6 +44,7 @@ belt init <env> # terraform init
44
44
  belt plan <env> # terraform plan
45
45
  belt apply <env> # terraform apply
46
46
  belt destroy <env> # terraform destroy
47
+ belt destroy environment <env> # same (mirrors generate environment)
47
48
  belt output <env> # terraform output
48
49
  ```
49
50
 
@@ -58,7 +59,7 @@ belt output <env> # terraform output
58
59
  end
59
60
  ```
60
61
 
61
- 2. Dispatcher creates an API Gateway where the namespace becomes a base path mapping. URLs look like:
62
+ 2. Conveyor Belt creates an API Gateway where the namespace becomes a base path mapping. URLs look like:
62
63
  ```
63
64
  https://api.<env>.example.com/<%= @app_name %>/things
64
65
  ```
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: belt
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stowzilla