Build and run the Nomos Terraform Remote State Provider. Use this when testing the provider, verifying functionality, or running the provider binary locally.
This skill provides a consistent way to build and run the Nomos Terraform Remote State Provider, including development workflows, debugging, and deployment scenarios.
Use this skill when you need to:
go mod download)make test)bin/)To build the provider binary:
make build
This command:
go mod tidy to ensure dependencies are correctbin/ directory if it doesn't existbin/nomos-provider-terraform-remote-stateExpected output:
Building nomos-provider-terraform-remote-state...
Build complete: bin/nomos-provider-terraform-remote-state
Version Information Embedded:
To build and immediately run the provider:
make run
This command:
make build)To remove old build artifacts and rebuild:
make clean
make build
The clean command removes:
bin/ directory and contentscoverage.out, coverage.html)To install the provider to $GOPATH/bin:
make install
This allows running the provider from anywhere:
nomos-provider-terraform-remote-state
Installation location: $(go env GOPATH)/bin/nomos-provider-terraform-remote-state
Run the compiled binary directly:
./bin/nomos-provider-terraform-remote-state
The provider accepts command-line arguments:
# Show version information
./bin/nomos-provider-terraform-remote-state -version
# Run on specific port
./bin/nomos-provider-terraform-remote-state -port 50051
# Enable debug logging
./bin/nomos-provider-terraform-remote-state -debug
# Show help
./bin/nomos-provider-terraform-remote-state -help
To run the provider as a background process:
# Start in background
./bin/nomos-provider-terraform-remote-state &
# Get process ID
echo $!
# Stop later
kill <PID>
Configure the provider using environment variables:
# Set log level
export LOG_LEVEL=debug
# Set port
export PROVIDER_PORT=50051
# Run provider
./bin/nomos-provider-terraform-remote-state
make test
make run
Ctrl+CFor comprehensive verification:
# 1. Format code
make fmt
# 2. Run static analysis
make vet
# 3. Run tests
make test
# 4. Build provider
make build
# 5. Run provider
make run
Or use the complete verification target:
make verify
For quick iteration during development:
# Terminal 1: Watch mode (requires entr or similar)
ls **/*.go | entr -r make run
# Terminal 2: Test gRPC calls
grpcurl -plaintext localhost:50051 list
Using grpcurl (install from https://github.com/fullstorydev/grpcurl):
# List available services
grpcurl -plaintext localhost:50051 list
# Call health check
grpcurl -plaintext localhost:50051 nomos.provider.v1.Provider/Health
# Get provider information
grpcurl -plaintext localhost:50051 nomos.provider.v1.Provider/Info
Expected response:
{
"alias": "tfstate",
"version": "0.1.0",
"type": "state"
}
# Initialize with configuration
grpcurl -plaintext -d '{
"config": {
"backend": {
"type": "local",
"path": "/tmp/terraform.tfstate"
}
}
}' localhost:50051 nomos.provider.v1.Provider/Init
# Fetch state
grpcurl -plaintext -d '{
"query": {
"path": "outputs.bucket_name"
}
}' localhost:50051 nomos.provider.v1.Provider/Fetch
Build with debug flags:
go build -gcflags="all=-N -l" -o bin/provider-debug ./cmd/provider
Run with debugger (using delve):
# Install delve
go install github.com/go-delve/delve/cmd/dlv@latest
# Run with debugger
dlv exec ./bin/provider-debug
View embedded version information:
# Linux/macOS
strings ./bin/nomos-provider-terraform-remote-state | grep version
# Or run with version flag
./bin/nomos-provider-terraform-remote-state -version
Use grpc-dump or similar tools:
# Set gRPC debug environment
export GRPC_GO_LOG_VERBOSITY_LEVEL=99
export GRPC_GO_LOG_SEVERITY_LEVEL=info
# Run provider
./bin/nomos-provider-terraform-remote-state
Run with profiling enabled:
# CPU profiling
go run -cpuprofile=cpu.prof ./cmd/provider
# Memory profiling
go run -memprofile=mem.prof ./cmd/provider
# Analyze profiles
go tool pprof cpu.prof
make test && make run
make verify && make build && ./bin/nomos-provider-terraform-remote-state -version
make clean && make deps && make build
# Create test config
cat > /tmp/provider-config.json <<EOF
{
"backend": {
"type": "local",
"path": "/tmp/terraform.tfstate"
}
}
EOF
# Run provider with config
./bin/nomos-provider-terraform-remote-state -config /tmp/provider-config.json
make install
which nomos-provider-terraform-remote-state
nomos-provider-terraform-remote-state -version
bin/nomos-provider-terraform-remote-state$(go env GOPATH)/bin/nomos-provider-terraform-remote-stateTypical binary size: ~15-25 MB (varies by platform and build flags)
Build for different platforms:
# Linux AMD64
GOOS=linux GOARCH=amd64 go build -o bin/provider-linux-amd64 ./cmd/provider
# macOS ARM64 (Apple Silicon)
GOOS=darwin GOARCH=arm64 go build -o bin/provider-darwin-arm64 ./cmd/provider
# Windows AMD64
GOOS=windows GOARCH=amd64 go build -o bin/provider-windows-amd64.exe ./cmd/provider
Symptom: Build fails with dependency errors
Solution:
# Clean and refresh dependencies
make clean
go mod tidy
go mod download
make build
Symptom: Binary exits immediately or fails to start
Solution:
lsof -i :50051
./bin/nomos-provider-terraform-remote-state -debug
ls -la ./bin/nomos-provider-terraform-remote-state
chmod +x ./bin/nomos-provider-terraform-remote-state
Symptom: command not found after make install
Solution:
go env GOPATH
export PATH="$PATH:$(go env GOPATH)/bin"
ls -la $(go env GOPATH)/bin/nomos-provider-terraform-remote-state
Symptom: ./bin/provider -version shows "dev"
Solution: This is normal for local builds. Version comes from git tags:
# Create and tag a release
git tag v0.1.0
make build
./bin/nomos-provider-terraform-remote-state -version
Symptom: Cannot connect to provider with grpcurl
Solution:
ps aux | grep nomos-provider
lsof -i :50051
grpcurl -plaintext localhost:50051 list
grpcurl -plaintext 127.0.0.1:50051 list
make test before make buildmake clean to avoid stale artifactsmake build over direct go build commandsmake install for frequent usego mod tidy regularlyThe provider is designed to run as a subprocess of the Nomos orchestrator:
# Orchestrator starts provider
nomos-provider-terraform-remote-state
# Provider writes port to stdout
# Orchestrator reads and connects
Build and run in Docker:
FROM golang:1.25-alpine AS builder
WORKDIR /app
COPY . .
RUN go build -o provider ./cmd/provider
FROM alpine:latest
COPY --from=builder /app/provider /usr/local/bin/
CMD ["provider"]
Deploy as a Kubernetes service:
apiVersion: apps/v1
kind: Deployment
metadata:
name: nomos-provider-tfstate
spec:
replicas: 1
template:
spec:
containers:
- name: provider
image: nomos-provider-terraform-remote-state:latest
ports:
- containerPort: 50051