Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
4 changes: 4 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
FROM mcr.microsoft.com/devcontainers/base:bookworm

# Install necessary dependencies
RUN apt-get update -y && rm -rf /var/lib/apt/lists/*
21 changes: 21 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"name": "Terraform Development Container",
"build": {
"dockerfile": "Dockerfile"
},
"features": {
"ghcr.io/devcontainers/features/terraform:1": {
"version": "latest"
},
"ghcr.io/dhoeric/features/terraform-docs:1": {}
},
"customizations": {
"vscode": {
"extensions": [
"hashicorp.terraform"
]
}
},
"postCreateCommand": "",
"remoteUser": "vscode"
}
14 changes: 14 additions & 0 deletions .github/workflows/commitmsg-conform.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: Commit Message Conformance

on:
pull_request: {}

permissions:
statuses: write
checks: write
contents: read
pull-requests: read

jobs:
commitmsg-conform:
uses: actionsforge/actions/.github/workflows/commitmsg-conform.yml@main
14 changes: 14 additions & 0 deletions .github/workflows/markdown-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: Markdown Lint

on:
pull_request: {}

permissions:
statuses: write
checks: write
contents: read
pull-requests: read

jobs:
markdown-lint:
uses: actionsforge/actions/.github/workflows/markdown-lint.yml@main
13 changes: 13 additions & 0 deletions .github/workflows/terraform-docs.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: Generate terraform docs

on:
push:
branches:
- main

permissions:
contents: write

jobs:
terraform-docs:
uses: actionsforge/actions/.github/workflows/terraform-docs.yml@main
13 changes: 13 additions & 0 deletions .github/workflows/terraform-lint-validate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
name: Terraform Lint & Validate

on:
pull_request: {}
permissions:
statuses: write
checks: write
contents: read
pull-requests: read

jobs:
terraform-lint-validate:
uses: actionsforge/actions/.github/workflows/terraform-lint-validate.yml@main
10 changes: 10 additions & 0 deletions .github/workflows/terraform-tag-and-release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
name: Terraform Tag and Release
on:
push:
branches:
- main
permissions:
contents: write
jobs:
terraform-tag-and-release:
uses: actionsforge/actions/.github/workflows/terraform-tag-and-release.yml@main
63 changes: 63 additions & 0 deletions .terraform.lock.hcl

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 14 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"recommendations": [
"davidanson.vscode-markdownlint",
"eamodio.gitlens",
"esbenp.prettier-vscode",
"foxundermoon.shell-format",
"Gruntfuggly.todo-tree",
"hashicorp.terraform",
"mhutchie.git-graph",
"streetsidesoftware.code-spell-checker",
"usernamehw.errorlens",
"vscode-icons-team.vscode-icons"
]
}
52 changes: 52 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
{
"files.associations": {
"*.dockerfile": "dockerfile",
"*.sh.tpl": "shellscript",
"docker-compose*.yml": "yaml",
"Dockerfile*": "dockerfile"
},
"files.exclude": {
"**/.git": true,
"**/.svn": true,
"**/.hg": true,
"**/CVS": true,
"**/.DS_Store": true,
"__debug_bin": true,
"vendor/": true,
"go.sum": true
},
"files.trimTrailingWhitespace": true,
"files.trimFinalNewlines": true,
"files.insertFinalNewline": true,
"remote.extensionKind": {
"ms-azuretools.vscode-docker": "ui",
"ms-vscode-remote.remote-containers": "ui"
},
"editor.formatOnSave": true,
"editor.formatOnPaste": true,
"prettier.requireConfig": true,
"workbench.iconTheme": "vscode-icons",
"[css]": {
"editor.defaultFormatter": "vscode.css-language-features",
"editor.foldingStrategy": "indentation"
},
"[dockerfile]": {
"editor.defaultFormatter": "ms-azuretools.vscode-docker"
},
"[html]": {
"editor.defaultFormatter": "vscode.html-language-features"
},
"[json]": {
"editor.formatOnSave": true,
"editor.defaultFormatter": "esbenp.prettier-vscode"
},
"[shellscript]": {
"editor.defaultFormatter": "foxundermoon.shell-format"
},
"[terraform]": {
"editor.formatOnSave": true,
"editor.defaultFormatter": "hashicorp.terraform",
"editor.tabSize": 2,
"editor.insertSpaces": true
}
}
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,6 @@
# terraform-aws-lambda-versioned
Terraform module for versioned AWS Lambda deployments using S3 and aliases

Terraform module for versioned AWS Lambda deployments supporting both zip packages from S3 and container images from ECR.

<!-- BEGIN_TF_DOCS -->
<!-- END_TF_DOCS -->
62 changes: 62 additions & 0 deletions examples/image/.terraform.lock.hcl

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions examples/image/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FROM public.ecr.aws/lambda/python:3.11

COPY app.py ${LAMBDA_TASK_ROOT}

CMD [ "app.handler" ]
61 changes: 61 additions & 0 deletions examples/image/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Terraform AWS Lambda Container Image Deployment Example

This example demonstrates how to deploy an AWS Lambda function using a container image from ECR, with versioning support.

## Features

- **Container Deployment**: Deploys Lambda function using container images
- **ECR Integration**: Uses ECR for container image storage
- **IAM Roles**: Configures execution role with Lambda and ECR permissions
- **Environment Variables**: Supports custom environment variables
- **Resource Limits**: Configurable timeout and memory settings
- **Tagging**: Supports custom resource tagging

## Usage

### **Initialize and Apply**

```bash
terraform init
terraform plan
terraform apply
```

### **Destroy Resources**

```bash
terraform destroy
```

> **Warning:** Running this example creates AWS resources that incur costs.

## Inputs

| Name | Description | Type | Default |
|------|-------------|------|---------|
| `function_name` | Name of the Lambda function | `string` | Required |
| `package_type` | Lambda package type | `string` | `"Image"` |
| `image_uri` | URI of the container image | `string` | Required |
| `policy_arns` | List of IAM policy ARNs to attach | `list(string)` | `[]` |
| `timeout` | Function timeout in seconds | `number` | `3` |
| `memory_size` | Function memory in MB | `number` | `128` |
| `environment_variables` | Environment variables for function | `map(string)` | `{}` |
| `tags` | Resource tags | `map(string)` | `{}` |

## Outputs

| Name | Description |
|------|-------------|
| `function_name` | Name of the Lambda function |
| `function_arn` | ARN of the Lambda function |
| `function_invoke_arn` | Invoke ARN of the Lambda function |
| `role_arn` | ARN of the Lambda execution role |

## Resources Created

- **Lambda Function** with container image deployment
- **IAM Role** for Lambda execution
- **IAM Policy Attachments** for Lambda and ECR permissions
- **CloudWatch Log Group** for function logs

This example provides a **complete Lambda deployment** using container images from ECR.
11 changes: 11 additions & 0 deletions examples/image/app.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import os
import json

def handler(event, context):
version = os.environ.get("AWS_LAMBDA_FUNCTION_VERSION", "$LATEST")
print(f"Lambda version: {version}")

return {
"statusCode": 200,
"body": json.dumps({ "version": version })
}
Binary file added examples/image/external/hello.zip
Binary file not shown.
2 changes: 2 additions & 0 deletions examples/image/external/source/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
FROM busybox
CMD tail -f /dev/null
Loading