Skip to content

patterninc/knife-drop-templates

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

37 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Service Templates

This directory contains starter templates for creating new services that deploy via Knife-Drop.

Usage

Run the bootstrap script from the knife-drop repo root:

./bootstrap-service.py

The script clones templates from pattern/knife-drop-templates and asks you:

  1. Service name
  2. Language (python/node/go/loki)
  3. Account to deploy to
  4. Output directory

It creates a complete service repository with:

  • Dockerfile
  • Sample application code with / and /health endpoints
  • GitHub Action for CI/CD
  • README with instructions
  • .gitignore

Templates

Python

  • Flask web server
  • Port 8080
  • requirements.txt for dependencies

Node.js

  • Express web server
  • Port 8080
  • package.json for dependencies

Go

  • Standard library HTTP server
  • Port 8080
  • Multi-stage Docker build

Loki (hello-world)

  • Minimal Python web form; on submit, logs input to stdout (one JSON line).
  • Used with enable_loki_logging: true in knife-drop so the Fluent Bit sidecar sends logs to Loki.
  • Port 8080; no Loki client in the app—just print() to stdout.
  • Service JSON includes enable_gatekeeper: true and enable_loki_logging: true; deploy to an account that has Loki SSM parameters and CommonECSLokiTaskExecPolicy.

GitHub Action

The generated workflow uses OIDC authentication (no access keys needed):

  1. Builds Docker image on push to main/develop
  2. Pushes to ECR with commit SHA and latest tags
  3. Forces ECS service redeployment

The IAM role GitHubActionsECRDeploy is created by Terraform and trusts GitHub OIDC for pattern/* repos.

Customization

After generation, you can:

  • Modify the application code in src/
  • Update the Dockerfile
  • Add dependencies
  • Customize the GitHub Action workflow
  • Add environment variables to the service JSON

Next Steps

After creating a service:

  1. Initialize git repo
  2. Create GitHub repository under pattern org
  3. Create service JSON in knife-drop/accounts/sandbox/services/
  4. Run terraform apply to create infrastructure
  5. Push code to trigger deployment

About

Templates for knife-drop TF

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published