Skip to content

Commit

Permalink
feat: add initial version of localstack-dind
Browse files Browse the repository at this point in the history
  • Loading branch information
lakkeger committed Jul 3, 2024
1 parent fc5fe45 commit 9677431
Show file tree
Hide file tree
Showing 5 changed files with 208 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/test-pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ jobs:
id: filter
with:
filters: |
color: ./**/color/**
localstack-dind: ./**/localstack-dind/**
localstack-dood: ./**/localstack-dood/**
test:
Expand Down
36 changes: 36 additions & 0 deletions src/localstack-dind/.devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"name": "LocalStack DinD setup",
"image": "mcr.microsoft.com/devcontainers/base:${templateOption:imageVariant}",

"remoteEnv": {
// Activate LocalStack Pro: https://docs.localstack.cloud/getting-started/auth-token/
"LOCALSTACK_AUTH_TOKEN": "${localEnv:LOCALSTACK_AUTH_TOKEN}", // required for Pro, not processed via template due to security reasons
// LocalStack configuration: https://docs.localstack.cloud/references/configuration/
"ACTIVATE_PRO": "${templateOption:usePro}",
"DEBUG": "${templateOption:debug}",
"LS_LOG": "${templateOption:logLevel}",
"PERSISTENCE": "${templateOption:persistence}",
"AWS_ENDPOINT_URL": "http://${templateOption:host}",
"LOCALSTACK_HOST": "${templateOption:host}",
"AUTO_LOAD_POD": "${templateOption:loadPods}",
"IAM_ENFORCE": "${templateOption:enforceIam}",
"AWS_REGION": "${templateOption:defaultRegion}",
"AWS_DEFAULT_REGION": "${templateOption:defaultRegion}"
},

// 👇 Features to add to the Dev Container. More info: https://containers.dev/implementors/features.
"features": {
"ghcr.io/devcontainers/features/docker-in-docker:2": {},
"ghcr.io/localstack/devcontainer-feature/localstack-cli:latest": {
"awslocal": ${templateOption:awslocal},
"cdklocal": ${templateOption:cdklocal},
"pulumilocal": ${templateOption:pulumilocal},
"samlocal": ${templateOption:samlocal},
"tflocal": ${templateOption:tflocal}
}
},

// 👇 Use 'postCreateCommand' to run commands after the container is created.
"postCreateCommand": "${templateOption:startup} && localstack start -d",
"mounts": [{ "source": "dind-var-lib-docker", "target": "/var/lib/docker", "type": "volume" }] // to persist build data and images
}
157 changes: 157 additions & 0 deletions src/localstack-dind/devcontainer-template.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,157 @@
{
"id": "localstack",
"version": "0.1.0",
"name": "LocalStack DinD",
"description": "A template to manage LocalStack in DinD via CLI",
"documentationURL": "https://github.com/localstack/devcontainer-template/tree/main/src/localstack",
"licenseURL": "https://github.com/localstack/devcontainer-template/blob/main/LICENSE",
"options": {
"imageVariant": {
"type": "string",
"description": "Debian version (use bullseye or jammy on local arm64/Apple Silicon):",
"proposals": [
"jammy",
"focal",
"bullseye",
"buster"
],
"default": "jammy"
},
"awslocal": {
"type": "boolean",
"description": "Install LocalStack wrapper for AWS CLI:",
"default": "false"
},
"cdklocal": {
"type": "boolean",
"description": "Install LocalStack wrapper for CDK:",
"default": "false"
},
"pulumilocal": {
"type": "boolean",
"description": "Install LocalStack wrapper for Pulumi:",
"default": "false"
},
"samlocal": {
"type": "boolean",
"description": "Install LocalStack wrapper for AWS SAM CLI:",
"default": "false"
},
"tflocal": {
"type": "boolean",
"description": "Install LocalStack wrapper for Terraform:",
"default": "false"
},
"logLevel": {
"type": "string",
"description": "Set LocalStack log level:",
"enum": [
"trace",
"trace-internal",
"debug",
"info",
"warn",
"error",
"warning"
],
"default": "info"
},
"host": {
"type": "string",
"descripiton": "LocalStack hostname:",
"proposals": [
"localhost.localstack.cloud:4566"
],
"default": "localhost.localstack.cloud:4566"
},
"debug": {
"type": "boolean",
"descripiton": "Enable LocalStack debugging:",
"default": "false"
},
"persistence": {
"type": "boolean",
"descripiton": "Enable persistence in LocalStack:",
"default": "false"
},
"usePro": {
"type": "boolean",
"descripiton": "Enable LocalStack Pro:",
"default": "false"
},
"version": {
"type": "string",
"descripiton": "Use LocalStack version:",
"proposals": [
"latest",
"3.5.0",
"3.4.0",
"3.3.0",
"3.2.0",
"3.1.0",
"3.0.2",
"3.0.1"
],
"default": "latest"
},
"loadPods": {
"type": "string",
"descripiton": "Load Cloud Pods at start-up (comma-separated list):",
"default": " "
},
"volumePath": {
"type": "string",
"descripiton": "LocalStack volume location on the host (currently only local (bind) mounts recommended):",
"default": "./volume"
},
"enforceIam": {
"type": "boolean",
"descripiton": "Enforce IAM:",
"default": "false"
},
"defaultRegion": {
"type": "string",
"descripiton": "Default AWS region:",
"proposals": [
"us-east-1",
"us-east-2",
"us-west-1",
"us-west-2",
"af-south-1",
"ap-east-1",
"ap-south-1",
"ap-south-2",
"ap-southeast-1",
"ap-southeast-2",
"ap-southeast-3",
"ap-southeast-4",
"ap-northeast-1",
"ap-northeast-2",
"ap-northeast-3",
"ca-central-1",
"ca-west-1",
"eu-central-1",
"eu-central-2",
"eu-west-1",
"eu-west-2",
"eu-west-3",
"eu-south-1",
"eu-south-2",
"eu-north-1",
"il-central-1",
"me-south-1",
"me-central-1",
"sa-east-1"
],
"default": "us-east-1"
},
"startup": {
"type": "boolean",
"description": "Start up LocalStack:",
"default": "true"
}
},
"platforms": [
"Any"
]
}
3 changes: 3 additions & 0 deletions src/localstack-dind/inputs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"awslocal": true
}
11 changes: 11 additions & 0 deletions test/localstack-dind/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash
cd $(dirname "$0")
source test-utils.sh

# Template specific tests
check "distro" lsb_release -c | grep "jammy"
check "localstack status" localstack status
check "localstack stops" localstack stop

# Report result
reportResults

0 comments on commit 9677431

Please sign in to comment.