This repository contains the AWS Simple API template for the Bluelink CLI. It provides an AWS-native starting point for serverless API projects using API Gateway, Lambda, DynamoDB, and VPC.
The AWS Simple API template demonstrates:
- AWS-specific resource types (
aws/apiGateway/api,aws/lambda/function,aws/dynamodb/table) - AWS Flex VPC (
aws/flex/vpc) with automatic networking configuration - Bluelink's link system for automatic IAM permissions and VPC integration
- Lambda function packaging workflow with Python and boto3
- Real DynamoDB integration with proper error handling
- Production-ready AWS architecture patterns
├── README.md # This file (for maintainers)
├── README.md.tmpl # Template for generated project README
├── LICENSE # Apache 2.0 License
├── .gitignore # Python/IDE/Bluelink/Lambda build ignores
├── bluelink.deploy.jsonc.tmpl # Deployment configuration template
├── project.blueprint.yaml.tmpl # Blueprint in YAML format (template)
├── project.blueprint.jsonc.tmpl # Blueprint in JSONC format (template)
├── requirements.txt # Python dependencies (boto3)
├── scripts/
│ └── package-lambda.sh # Lambda packaging script
└── handlers/ # Lambda handler code
├── __init__.py
└── resources/
├── __init__.py
└── update_resource.py # PATCH /resources/{resourceId} handler
The Bluelink CLI replaces these Go template variables during project initialization:
| Variable | Description | Example |
|---|---|---|
{{.ProjectName}} |
User-provided project name | my-api |
{{.NormalisedProjectName}} |
Normalized version (lowercase, hyphens) | my-api |
{{.BlueprintFormat}} |
Selected format (yaml or jsonc) | yaml |
-
.tmplextension: Files with Go template syntax that need processingREADME.md.tmpl→README.mdproject.blueprint.yaml.tmpl→project.blueprint.yamlbluelink.deploy.jsonc.tmpl→bluelink.deploy.jsonc
-
No
.tmplextension: Files copied as-ishandlers/**/*.pyrequirements.txt.gitignorescripts/**/*.sh
- Uses AWS-specific resource types (
aws/apiGateway/api,aws/lambda/function,aws/dynamodb/table) - Demonstrates AWS Flex VPC for automatic networking
- Showcases Bluelink's link system for IAM and VPC configuration
- Separates this from cloud-agnostic templates (e.g.,
scaffold)
- Uses boto3 for DynamoDB access (not mocked responses)
- Demonstrates proper Lambda handler structure
- Shows environment variable injection via Bluelink links
- Includes production-ready error handling patterns
- Includes Lambda packaging script (
scripts/package-lambda.sh) - Shows how to create deployment artifacts
- Demonstrates VPC networking with Lambda
- Includes proper .gitignore for build artifacts
- Demonstrates automatic IAM policy generation (Lambda → DynamoDB)
- Shows automatic VPC configuration (Lambda → VPC)
- Uses label-based resource discovery (API Gateway → Lambda)
- Minimizes manual configuration through intelligent links
- Provides both YAML and JSONC blueprint formats
- CLI selects one based on user preference
- Both are kept in sync with identical structure
- Flexible VPC with standard preset
- Automatic subnet creation (public/private)
- Security group management
- NAT gateway configuration
- Uses linkSelector for label-based discovery
- HTTP API (not REST API)
- CORS configuration
- Throttling settings
- Optional custom domain support
- Optional JWT authorization
- Uses linkSelector to discover Lambda functions
- Python 3.13 runtime
- VPC configuration via links
- DynamoDB access via links
- Environment variable injection
- X-Ray tracing enabled
- Route configuration for API Gateway
- PAY_PER_REQUEST billing mode
- Point-in-time recovery enabled
- KMS encryption
- DynamoDB Streams enabled
- Partition key configuration
- Update both blueprint formats: Make identical changes to
.yaml.tmpland.jsonc.tmpl - Update AWS resource types: Use correct
aws/service/resourceformat - Maintain link configuration: Ensure links are properly configured for IAM/VPC
- Update handler code: If adding new endpoints, create example handlers
- Update packaging script: If handler structure changes
- Update README.md.tmpl: Document new features in generated project README
- Test with CLI: Run
bluelink init --template aws-simple-apito verify
When updating blueprints, ensure:
- YAML and JSONC have identical structure
- Comments are adapted to format (# vs //)
- AWS resource types are consistent
- Link configurations match exactly
- Template variables are used consistently
When modifying links:
- Lambda → DynamoDB: Generates read/write IAM policies
- Lambda → VPC: Configures subnets and security groups
- API → Lambda: Uses label selectors, not direct references
Before committing changes:
-
Test template generation:
bluelink init --template aws-simple-api --project-name test-api cd test-api -
Verify template variables were replaced:
# Should see "test-api", not "{{.ProjectName}}" cat README.md grep -r "{{.ProjectName}}" . --include="*.yaml" --include="*.jsonc" --include="*.md"
-
Test Lambda packaging:
./scripts/package-lambda.sh # Should create dist/lambda-package.zip -
Validate blueprint syntax:
bluelink validate --blueprint-file project.blueprint.yaml
-
Test both formats:
bluelink init --template aws-simple-api --blueprint-format yaml --project-name test-yaml bluelink init --template aws-simple-api --blueprint-format jsonc --project-name test-jsonc
-
Verify AWS resource types:
# Check that all resources use aws/* types, not celerity/* grep -E "type: (aws|celerity)/" project.blueprint.yaml.tmpl
-
Test deployment (optional but recommended):
# Set AWS credentials export AWS_ACCESS_KEY_ID=... export AWS_SECRET_ACCESS_KEY=... # Package and deploy ./scripts/package-lambda.sh bluelink deploy --instance-name test-deployment # Clean up bluelink destroy --instance-name test-deployment
The template includes scripts/package-lambda.sh which:
- Creates
dist/package/directory - Installs requirements.txt into package directory
- Copies handler code to package directory
- Creates
dist/lambda-package.zip
When updating:
- Test with empty requirements.txt
- Test with commented-out dependencies
- Verify handler imports work correctly
- Check ZIP structure matches Lambda expectations
This template demonstrates the linkSelector pattern for connecting resources:
Resources connect using linkSelector with label matching:
# Resource A declares what it wants to connect to
updateResourceHandler:
metadata:
labels:
app: {{.NormalisedProjectName}}
network: {{.NormalisedProjectName}}
linkSelector:
byLabel:
app: {{.NormalisedProjectName}} # Finds resources with this label
# Resource B with matching label - automatically linked
resourceStore:
metadata:
labels:
app: {{.NormalisedProjectName}} # Matched by Lambda's linkSelector
# Resource C discovers Resource A via its labels
appVpc:
linkSelector:
byLabel:
network: {{.NormalisedProjectName}} # Finds Lambda with network label- Labels on resources act as identifiers
- LinkSelector on resources queries for matching labels
- Bidirectional matching - either resource can initiate the link
- Provider-defined behavior - AWS provider determines what happens (IAM policies, VPC config, etc.)
updateResourceHandler:
metadata:
annotations:
aws.lambda.function.http: true
aws.lambda.function.http.method: "PATCH"
aws.lambda.function.http.path: "/resources/{resourceId}"Annotations guide HOW the link is established (e.g., which HTTP method/path for API Gateway integration).
When contributing to this template:
- Open an issue describing the proposed change
- Ensure changes are AWS-specific (not cloud-agnostic)
- Update all relevant files (both blueprint formats, README, handler code, scripts)
- Maintain Bluelink link system patterns
- Test thoroughly with Bluelink CLI and actual AWS deployment
- Submit a PR with clear description of changes
- Use conventional commit messages
- Leverage Bluelink links for automatic IAM/VPC configuration
- Include realistic AWS examples (not mocked)
- Document AWS-specific features (X-Ray, CloudWatch, etc.)
- Show production-ready patterns (encryption, backups, etc.)
- Template Issues: Bluelink GitHub Issues
- AWS Provider Issues: Bluelink AWS Provider
- Documentation: Bluelink Docs
Apache License 2.0 - See LICENSE file for details.