Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
048cdea
feat: nat-zero module, CI, and release automation
leonardosul Feb 24, 2026
813f0e9
fix: add pull_request trigger to integration tests
leonardosul Feb 24, 2026
9bb7255
ci: trigger PR checks
leonardosul Feb 24, 2026
512b311
fix: use label trigger for integration tests
leonardosul Feb 24, 2026
1b50b10
ci: re-trigger checks
leonardosul Feb 24, 2026
fc69f8e
docs: rewrite docs, deduplicate terraform-docs, fix integration test AZ
leonardosul Feb 24, 2026
d3e0aba
fix: prevent EIP leak from concurrent attachEIP races
leonardosul Feb 24, 2026
d49b87d
fix: resolve scale-down race from EC2 API eventual consistency
leonardosul Feb 25, 2026
c1628d1
test: add race condition catalog with unit tests and docs
leonardosul Feb 25, 2026
2e9dab5
style: fix gofmt alignment in race_test.go
leonardosul Feb 25, 2026
4a9c336
fix: sweep orphan EIPs on NAT termination (R11)
leonardosul Feb 25, 2026
4d99138
refactor: replace event-driven logic with reconciliation + reserved c…
leonardosul Feb 25, 2026
cce49de
fix: correct stale NAT state from EC2 filter eventual consistency
leonardosul Feb 25, 2026
884510a
test: always dump Lambda CloudWatch logs before destroy
leonardosul Feb 25, 2026
98722a2
fix: distinguish waiting from converged in reconcile log, expand log …
leonardosul Feb 25, 2026
245904f
fix: log waiting for nat=stopping, reduce Lambda memory to 128 MB
leonardosul Feb 25, 2026
b41f3d6
docs: update terraform-docs for lambda_memory_size default change
leonardosul Feb 25, 2026
87440a8
fix: wait for NAT fully terminated before terraform destroy
leonardosul Feb 25, 2026
3cad0ae
fix: wait for NAT instance termination in cleanup before returning
leonardosul Feb 25, 2026
5395766
docs: simplify all documentation to match reconciliation pattern
leonardosul Feb 26, 2026
cfd47c9
fix: increase Lambda timeout from 30s to 60s
leonardosul Feb 26, 2026
7f457a1
fix: terminate workloads before cleanup in integration test
leonardosul Feb 26, 2026
d9bb51c
fix: don't wait for full workload termination in cleanup test
leonardosul Feb 26, 2026
ba6a7b3
fix: add EventBridge propagation delay after target creation
leonardosul Feb 26, 2026
353b8e6
fix: handle EC2 eventual consistency in NAT event processing
leonardosul Feb 26, 2026
ef4a5da
docs: add missing time_sleep.eventbridge_propagation to terraform-docs
leonardosul Feb 26, 2026
5c85189
fix: trust event state for stopped NAT (EC2 eventual consistency)
leonardosul Feb 26, 2026
a559715
fix: trust event state for trigger instance, increase EventBridge delay
leonardosul Feb 26, 2026
83ed7d7
fix: increase EventBridge propagation delay to 60s
leonardosul Feb 26, 2026
7635d20
docs: add pattern origins, reliability notes, and fix config versioning
leonardosul Feb 26, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Docs

on:
push:
branches: [main]
paths:
- "docs/**"
- "mkdocs.yml"
- "README.md"
- "*.tf"

permissions:
contents: write

jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4

- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5
with:
python-version: "3.12"

- name: Install mkdocs-material
run: pip install mkdocs-material

- name: Deploy docs
run: mkdocs gh-deploy --force
29 changes: 29 additions & 0 deletions .github/workflows/go-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Go Tests

on:
pull_request:
paths:
- "cmd/lambda/**"
push:
branches: [main]
paths:
- "cmd/lambda/**"

permissions:
contents: read

jobs:
go-test:
runs-on: ubuntu-latest
defaults:
run:
working-directory: cmd/lambda
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4

- uses: actions/setup-go@40f1582b2485089dde7abd97c1529aa768e1baff # v5
with:
go-version-file: cmd/lambda/go.mod

- name: Test
run: go test -v -race ./...
50 changes: 50 additions & 0 deletions .github/workflows/integration-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Integration Tests

on:
pull_request:
types: [labeled]
workflow_dispatch:

concurrency:
group: nat-zero-integration
cancel-in-progress: false

permissions:
id-token: write
contents: read

jobs:
integration-test:
if: >-
github.event_name == 'workflow_dispatch' ||
github.event.label.name == 'integration-test'
runs-on: ubuntu-latest
timeout-minutes: 15
environment: integration
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4

- uses: actions/setup-go@40f1582b2485089dde7abd97c1529aa768e1baff # v5
with:
go-version-file: cmd/lambda/go.mod

- uses: hashicorp/setup-terraform@b9cd54a3c349d3f38e8881555d616ced269862dd # v3
with:
terraform_wrapper: false

- uses: aws-actions/configure-aws-credentials@7474bc4690e29a8392af63c5b98e7449536d5c3a # v4
with:
role-to-assume: ${{ secrets.INTEGRATION_ROLE_ARN }}
aws-region: us-east-1

- name: Build Lambda binary
working-directory: cmd/lambda
run: |
GOOS=linux GOARCH=arm64 CGO_ENABLED=0 go build -tags lambda.norpc -ldflags='-s -w' -o bootstrap
zip lambda.zip bootstrap
mkdir -p ../../.build
cp lambda.zip ../../.build/lambda.zip

- name: Test
working-directory: tests/integration
run: go test -v -timeout 10m -count=1
37 changes: 37 additions & 0 deletions .github/workflows/precommit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Pre-commit

on:
pull_request:
push:
branches: [main]
paths:
- "*.tf"
- "cmd/lambda/**"
- ".pre-commit-config.yaml"
- ".terraform-docs.yml"

permissions:
contents: read

jobs:
precommit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4

- uses: actions/setup-go@40f1582b2485089dde7abd97c1529aa768e1baff # v5
with:
go-version-file: cmd/lambda/go.mod

- uses: hashicorp/setup-terraform@b9cd54a3c349d3f38e8881555d616ced269862dd # v3

- name: Install tools
run: |
go install honnef.co/go/tools/cmd/staticcheck@latest
curl -s https://raw.githubusercontent.com/terraform-linters/tflint/master/install_linux.sh | bash

- uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5
with:
python-version: "3.12"

- uses: pre-commit/action@2c7b3805fd2a0fd8c1884dcaebf91fc102a13ecd # v3.0.1
58 changes: 58 additions & 0 deletions .github/workflows/release-please.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
name: Release

on:
push:
branches: [main]
workflow_dispatch:

permissions:
contents: write
pull-requests: write

jobs:
release-please:
runs-on: ubuntu-latest
outputs:
release_created: ${{ steps.release.outputs.release_created }}
tag_name: ${{ steps.release.outputs.tag_name }}
steps:
- uses: googleapis/release-please-action@16a9c90856f42705d54a6fda1823352bdc62cf38 # v4
id: release
with:
config-file: release-please-config.json
manifest-file: .release-please-manifest.json

build-lambda:
needs: release-please
if: needs.release-please.outputs.release_created == 'true'
runs-on: ubuntu-latest
defaults:
run:
working-directory: cmd/lambda
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4

- uses: actions/setup-go@40f1582b2485089dde7abd97c1529aa768e1baff # v5
with:
go-version-file: cmd/lambda/go.mod

- name: Build
run: GOOS=linux GOARCH=arm64 CGO_ENABLED=0 go build -tags lambda.norpc -ldflags='-s -w' -o bootstrap

- name: Package
run: zip lambda.zip bootstrap

- name: Upload to versioned release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: gh release upload "${{ needs.release-please.outputs.tag_name }}" lambda.zip --clobber

- name: Update rolling latest release
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh release create nat-zero-lambda-latest \
--title "nat-zero Lambda (latest)" \
--notes "Auto-built Go Lambda binary from ${{ needs.release-please.outputs.tag_name }}" \
--latest=false 2>/dev/null || true
gh release upload nat-zero-lambda-latest lambda.zip --clobber
29 changes: 29 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Terraform
.terraform/
.terraform.lock.hcl
*.tfstate
*.tfstate.backup
*.tfplan

# Lambda build artifacts
.build/
cmd/lambda/lambda
cmd/lambda/bootstrap
*.zip

# Go
vendor/

# Test cache
.pytest_cache/

# OS
.DS_Store

# IDE
.idea/
.vscode/
*.swp

# AI
.claude/
47 changes: 47 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
hooks:
- id: check-yaml
args: ["--unsafe"]
- id: end-of-file-fixer
- id: trailing-whitespace
- id: check-toml
- id: check-json
- repo: https://github.com/TekWizely/pre-commit-golang
rev: v1.0.0-rc.1
hooks:
- id: go-fmt
name: go fmt
- id: go-vet-repo-mod
name: go vet
- id: go-test-mod
name: go test
exclude: "tests/integration/"
- repo: local
hooks:
- id: go-staticcheck
name: go staticcheck
language: system
entry: bash -c 'export PATH="$HOME/go/bin:$PATH" && cd cmd/lambda && staticcheck ./...'
files: '\.go$'
exclude: "tests/integration/"
pass_filenames: false
- repo: https://github.com/zricethezav/gitleaks
rev: v8.16.4
hooks:
- id: gitleaks
- repo: https://github.com/antonbabenko/pre-commit-terraform.git
rev: v1.77.0
hooks:
- id: terraform_fmt
- id: terraform_tflint
- repo: https://github.com/terraform-docs/terraform-docs
rev: "v0.16.0"
hooks:
- id: terraform-docs-go
name: terraform-docs (README.md)
args: ["--output-mode", "inject", "--output-file", "README.md", "."]
- id: terraform-docs-go
name: terraform-docs (docs/REFERENCE.md)
args: ["-c", ".terraform-docs-reference.yml", "--output-mode", "replace", "--output-file", "docs/REFERENCE.md", "."]
3 changes: 3 additions & 0 deletions .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
".": "0.0.0"
}
5 changes: 5 additions & 0 deletions .terraform-docs-reference.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
formatter: "markdown table"

output:
template: |
{{ .Content }}
1 change: 1 addition & 0 deletions .terraform-docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
formatter: "markdown table"
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2026 MachineDotDev contributors

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
Loading
Loading