Class: Belt::CLI::ZipArtifactBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/belt/cli/zip_artifact_builder.rb

Overview

Builds zip files that Terraform filebase64sha256(...) / filename = "...zip" references before plan/apply. Conveyor Belt packages Ruby lambdas itself; sidecar functions (Node image processors, Cognito triggers, …) are plain aws_lambda_function resources that expect a zip on disk at plan time.

Node packages (package.json) are installed in Docker on linux/amd64 so native addons like sharp match Lambda. Plain JS directories are zipped as-is. Existing zips are reused when a source hash still matches.

Defined Under Namespace

Classes: Artifact

Constant Summary collapse

NODE_DOCKER_IMAGE =
'public.ecr.aws/lambda/nodejs:20-x86_64'
ZIP_REF =
/(?:filebase64sha256\(\s*|filename\s*=\s*)["']([^"']+\.zip)["']/

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(project_root:, infra_dir:) ⇒ ZipArtifactBuilder

Returns a new instance of ZipArtifactBuilder.



25
26
27
28
# File 'lib/belt/cli/zip_artifact_builder.rb', line 25

def initialize(project_root:, infra_dir:)
  @project_root = File.expand_path(project_root)
  @infra_dir = File.expand_path(infra_dir, @project_root)
end

Class Method Details

.build!(project_root: Dir.pwd, infra_dir: 'infrastructure') ⇒ Object



21
22
23
# File 'lib/belt/cli/zip_artifact_builder.rb', line 21

def self.build!(project_root: Dir.pwd, infra_dir: 'infrastructure')
  new(project_root: project_root, infra_dir: infra_dir).build!
end

Instance Method Details

#build!Object



32
33
34
35
36
37
# File 'lib/belt/cli/zip_artifact_builder.rb', line 32

def build!
  artifacts = discover_artifacts
  return if artifacts.empty?

  artifacts.each { |artifact| ensure_zip!(artifact) }
end