Skip to content

Commit a467d2a

Browse files
authored
remove community image fallback, make auth token required (#7)
- `start()` now requires `LOCALSTACK_AUTH_TOKEN` — no more optional fallback to `localstack/localstack:latest` without a token - Remove `localstack/localstack-pro:latest` image reference; always use `localstack/localstack:latest` - Always expose ports 4566 and 443 (no longer conditional on auth token) - Update README, tests, and all examples to remove community edition references and pass auth token to every `start()` call Closes DEVREL-62
1 parent 49332d9 commit a467d2a

File tree

11 files changed

+98
-109
lines changed

11 files changed

+98
-109
lines changed

README.md

Lines changed: 29 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,13 @@
33
[![License](https://img.shields.io/badge/License-Apache_2.0-blue.svg)](LICENSE)
44
[![LocalStack Dagger Module Tests](https://github.com/localstack/localstack-dagger-module/actions/workflows/test.yml/badge.svg)](https://github.com/localstack/localstack-dagger-module/actions/workflows/test.yml)
55

6-
A [Dagger](https://dagger.io/) module for running [LocalStack](https://github.com/localstack/localstack) (Community and Pro image) as a service within your Dagger pipelines.
6+
A [Dagger](https://dagger.io/) module for running [LocalStack](https://github.com/localstack/localstack) as a service within your Dagger pipelines.
77

88
This module simplifies integrating LocalStack into your development and testing workflows by:
99

10-
- Starting LocalStack Community or Pro editions as a Dagger service.
10+
- Starting LocalStack as a Dagger service.
1111
- Securely handling LocalStack Auth Tokens using Dagger secrets.
12-
- Automatically exposing standard LocalStack ports (`4566` for Community/Pro, `443` for Pro).
12+
- Automatically exposing standard LocalStack ports (`4566` and `443`).
1313
- Allowing customization of the LocalStack container via environment variables.
1414
- Optionally mounting the Docker socket for tests interacting with external containers.
1515
- Managing LocalStack state using [Cloud Pods](https://docs.localstack.cloud/user-guide/state-management/cloud-pods/) (`save`/`load`/`reset`).
@@ -19,7 +19,7 @@ This module simplifies integrating LocalStack into your development and testing
1919

2020
- [Dagger CLI installed](https://docs.dagger.io/install)
2121
- Docker or a compatible container runtime
22-
- LocalStack Auth Token (required for Pro features, Cloud Pods, and Ephemeral Instances)
22+
- LocalStack Auth Token (required)
2323

2424
## Installation
2525

@@ -33,31 +33,19 @@ You can then call its functions from the Dagger CLI or your Dagger SDK code.
3333

3434
## Usage
3535

36-
### Start LocalStack Community
36+
### Start LocalStack
3737

38-
This is the simplest way to start the default LocalStack Community edition.
39-
40-
```bash
41-
dagger -m github.com/localstack/localstack-dagger-module call start up
42-
```
43-
44-
LocalStack will run and be accessible at `localhost:4566` and with any integration that LocalStack supports.
45-
46-
### Start LocalStack Pro
47-
48-
To use LocalStack Pro features, Cloud Pods, or Ephemeral Instances, you need an Auth Token.
49-
50-
```bash
51-
# 1. Set your LocalStack Pro auth token as an environment variable
52-
export LOCALSTACK_AUTH_TOKEN="your-pro-token"
38+
```bash
39+
# 1. Set your LocalStack auth token as an environment variable
40+
export LOCALSTACK_AUTH_TOKEN="your-token"
5341

54-
# 2. Start LocalStack Pro using the token from the environment
42+
# 2. Start LocalStack using the token from the environment
5543
dagger -m github.com/localstack/localstack-dagger-module \
5644
call start --auth-token=env:LOCALSTACK_AUTH_TOKEN \
5745
up
5846
```
5947

60-
If the token is invalid or missing when Pro usage is implied, LocalStack might behave unexpectedly or functionality might be limited.
48+
LocalStack will run and be accessible at `localhost:4566` and with any integration that LocalStack supports.
6149

6250
### Customizing LocalStack
6351

@@ -74,7 +62,7 @@ dagger -m github.com/localstack/localstack-dagger-module call start \
7462

7563
To run emulated AWS services that rely on a container, like Lambda or ECS, you would need to mount Docker Socket into the LocalStack container.
7664

77-
```bash
65+
```bash
7866
dagger -m github.com/localstack/localstack-dagger-module call start \
7967
--auth-token=env:LOCALSTACK_AUTH_TOKEN \
8068
--docker-sock /var/run/docker.sock \
@@ -83,11 +71,11 @@ dagger -m github.com/localstack/localstack-dagger-module call start \
8371

8472
### Managing State with Cloud Pods
8573

86-
Cloud pods are persistent state snapshots of your LocalStack instance that can easily be stored, versioned, shared, and restored. Cloud Pods require a LocalStack Auth Token.
74+
Cloud pods are persistent state snapshots of your LocalStack instance that can easily be stored, versioned, shared, and restored.
8775

88-
```bash
76+
```bash
8977
# Set your auth token
90-
export LOCALSTACK_AUTH_TOKEN="your-pro-token"
78+
export LOCALSTACK_AUTH_TOKEN="your-token"
9179

9280
# Save the current state of your running LocalStack instance to a Cloud Pod
9381
# Assumes you have a running instance started via 'dagger call start ... up'
@@ -108,11 +96,11 @@ dagger -m github.com/localstack/localstack-dagger-module call state \
10896

10997
### Managing Ephemeral Instances
11098

111-
Ephemeral Instances allows you to run a LocalStack instance in the cloud. Ephemeral Instances require a LocalStack Pro Auth Token.
99+
Ephemeral Instances allows you to run a LocalStack instance in the cloud.
112100

113101
```bash
114102
# Set your auth token
115-
export LOCALSTACK_AUTH_TOKEN="your-pro-token"
103+
export LOCALSTACK_AUTH_TOKEN="your-token"
116104

117105
# Create a new Ephemeral Instance in LocalStack Cloud
118106
dagger -m github.com/localstack/localstack-dagger-module call ephemeral \
@@ -141,36 +129,36 @@ dagger -m github.com/localstack/localstack-dagger-module call ephemeral \
141129

142130
## Inputs
143131

144-
### `start`
132+
### `start`
145133

146134
Used to configure and start the main LocalStack service.
147135

148-
| Input | Description | Default | Example |
149-
| --------------- | --------------------------------------------------------------------------- | ----------------------------------- | ------------------------------------------------------------- |
150-
| `auth-token` | LocalStack Pro auth token (as Dagger `Secret`). Required for Pro features. | `None` | `dagger call start --auth-token=env:LOCALSTACK_AUTH_TOKEN` |
151-
| `configuration` | Comma-separated `KEY=VALUE` pairs for LocalStack environment variables. | `None` | `dagger call start --configuration='DEBUG=1,PERSISTENCE=1'` |
152-
| `docker-sock` | Path to the Unix socket for the Docker daemon to mount into the container. | `None` | `dagger call start --docker-sock=/var/run/docker.sock` |
153-
| `image-name` | Custom LocalStack Docker image name and tag. | `localstack/localstack:latest` | `dagger call start --image-name=localstack/snowflake:latest` |
136+
| Input | Description | Default | Example |
137+
| --------------- | --------------------------------------------------------------------------- | ------------------------------ | ------------------------------------------------------------ |
138+
| `auth-token` | LocalStack Auth Token (as Dagger `Secret`). Required. | Required | `dagger call start --auth-token=env:LOCALSTACK_AUTH_TOKEN` |
139+
| `configuration` | Comma-separated `KEY=VALUE` pairs for LocalStack environment variables. | `None` | `dagger call start --configuration='DEBUG=1,PERSISTENCE=1'` |
140+
| `docker-sock` | Path to the Unix socket for the Docker daemon to mount into the container. | `None` | `dagger call start --docker-sock=/var/run/docker.sock` |
141+
| `image-name` | Custom LocalStack Docker image name and tag. | `localstack/localstack:latest` | `dagger call start --image-name=localstack/snowflake:latest` |
154142

155143
### `state`
156144

157-
Used to manage the state of a running LocalStack instance using Cloud Pods (Pro only).
145+
Used to manage the state of a running LocalStack instance using Cloud Pods.
158146

159-
| Input | Description | Default | Example |
160-
| ------------ | ------------------------------------------------------------------------------------ | ---------------------------- | ------------------------------------------------ |
161-
| `auth-token` | LocalStack Pro Auth Token (as Dagger `Secret`). Required for `save` and `load`. | `None` | `dagger call state --auth-token=env:LOCALSTACK_AUTH_TOKEN` |
147+
| Input | Description | Default | Example |
148+
| ------------ | ------------------------------------------------------------------------------- | ---------------------------- | ------------------------------------------------ |
149+
| `auth-token` | LocalStack Auth Token (as Dagger `Secret`). Required for `save` and `load`. | `None` | `dagger call state --auth-token=env:LOCALSTACK_AUTH_TOKEN` |
162150
| `load` | Name of the LocalStack Cloud Pod to load into the running instance. | `None` | `dagger call state --load=my-pod` |
163151
| `save` | Name under which to save the current state as a LocalStack Cloud Pod. | `None` | `dagger call state --save=my-pod` |
164152
| `reset` | If `true`, resets the state of the running LocalStack instance. | `False` | `dagger call state --reset` |
165153
| `endpoint` | LocalStack endpoint to connect to. | `host.docker.internal:4566` | `dagger call state --endpoint=localhost:4566` |
166154

167155
### `ephemeral`
168156

169-
Used to manage LocalStack Ephemeral Instances in LocalStack Cloud (Pro only).
157+
Used to manage LocalStack Ephemeral Instances in LocalStack Cloud.
170158

171159
| Input | Description | Default | Example |
172160
| ------------------------ | ---------------------------------------------------------------------------------------------------------- | --------- | -------------------------------------------------------- |
173-
| `auth-token` | LocalStack Pro Auth Token (as Dagger `Secret`). Required for all operations. | Required | `dagger call ephemeral --auth-token=env:LOCALSTACK_AUTH_TOKEN` |
161+
| `auth-token` | LocalStack Auth Token (as Dagger `Secret`). Required for all operations. | Required | `dagger call ephemeral --auth-token=env:LOCALSTACK_AUTH_TOKEN` |
174162
| `operation` | Action to perform: `create`, `list`, `delete`, `logs`. | Required | `dagger call ephemeral --operation=create` |
175163
| `name` | Name of the ephemeral instance. Required for `create`, `delete`, `logs`. | `None` | `dagger call ephemeral --name=my-instance` |
176164
| `lifetime` | Lifetime of the instance in minutes (only for `create` operation). | `60` | `dagger call ephemeral --lifetime=120` |

examples/golang/main.go

Lines changed: 10 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ import (
2323
type Golang struct{}
2424

2525
// Starts LocalStack and performs example S3 operations
26-
func (m *Golang) LocalstackQuickstart(ctx context.Context) (string, error) {
27-
service := dag.Localstack().Start()
26+
func (m *Golang) LocalstackQuickstart(ctx context.Context, authToken *dagger.Secret) (string, error) {
27+
service := dag.Localstack().Start(authToken)
2828

2929
// Start the service and get endpoint
3030
if _, err := service.Start(ctx); err != nil {
@@ -103,16 +103,14 @@ S3 object content: %s`, endpoint, string(data))
103103
return output, nil
104104
}
105105

106-
// Starts LocalStack Pro with custom configuration and creates an ECR repository
106+
// Starts LocalStack with custom configuration and creates an ECR repository
107107
func (m *Golang) LocalstackPro(ctx context.Context, authToken *dagger.Secret) (string, error) {
108-
// Start LocalStack Pro using the module with custom configuration
109-
service := dag.Localstack().Start(dagger.LocalstackStartOpts{
110-
AuthToken: authToken,
111-
})
108+
// Start LocalStack using the module with custom configuration
109+
service := dag.Localstack().Start(authToken)
112110

113111
// Start the service and wait for it to be ready
114112
if _, err := service.Start(ctx); err != nil {
115-
return "", fmt.Errorf("failed to start LocalStack Pro: %w", err)
113+
return "", fmt.Errorf("failed to start LocalStack: %w", err)
116114
}
117115

118116
endpoint, err := service.Endpoint(ctx)
@@ -152,22 +150,20 @@ func (m *Golang) LocalstackPro(ctx context.Context, authToken *dagger.Secret) (s
152150
return "", fmt.Errorf("failed to create ECR repository: %w", err)
153151
}
154152

155-
output := fmt.Sprintf(`LocalStack Pro is running at %s
153+
output := fmt.Sprintf(`LocalStack is running at %s
156154
ECR repository '%s' created`, endpoint, repositoryName)
157155

158156
return output, nil
159157
}
160158

161159
// Demonstrates LocalStack state management using Cloud Pods
162160
func (m *Golang) LocalstackState(ctx context.Context, authToken *dagger.Secret) (string, error) {
163-
// Start LocalStack Pro
164-
service := dag.Localstack().Start(dagger.LocalstackStartOpts{
165-
AuthToken: authToken,
166-
})
161+
// Start LocalStack
162+
service := dag.Localstack().Start(authToken)
167163

168164
// Start the service and wait for it to be ready
169165
if _, err := service.Start(ctx); err != nil {
170-
return "", fmt.Errorf("failed to start LocalStack Pro: %w", err)
166+
return "", fmt.Errorf("failed to start LocalStack: %w", err)
171167
}
172168

173169
endpoint, err := service.Endpoint(ctx)

examples/python/src/example/main.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66
@object_type
77
class Example:
88
@function
9-
async def localstack__quickstart(self) -> str:
10-
"""Example showing how to start LocalStack Community edition."""
11-
service = dag.localstack().start()
9+
async def localstack__quickstart(self, auth_token: dagger.Secret) -> str:
10+
"""Example showing how to start LocalStack."""
11+
service = dag.localstack().start(auth_token=auth_token)
1212

1313
await service.start()
1414
endpoint = await service.endpoint()
@@ -41,16 +41,16 @@ async def localstack__quickstart(self) -> str:
4141

4242
@function
4343
async def localstack__pro(self, auth_token: dagger.Secret) -> str:
44-
"""Example showing how to start LocalStack Pro with custom configuration."""
45-
# Start LocalStack Pro using the module
44+
"""Example showing how to start LocalStack with custom configuration."""
45+
# Start LocalStack using the module
4646
service = dag.localstack().start(
4747
auth_token=auth_token,
4848
configuration="DEBUG=1,SERVICES=ecr"
4949
)
5050

5151
await service.start()
5252
endpoint = await service.endpoint()
53-
print(f"LocalStack Pro is running at {endpoint}")
53+
print(f"LocalStack is running at {endpoint}")
5454

5555
# Create a test ECR repository
5656
ecr = boto3.client(

examples/shell/localstack_dagger_module_ephemeral.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
# Check if LOCALSTACK_AUTH_TOKEN is set
44
if [ -z "$LOCALSTACK_AUTH_TOKEN" ]; then
55
echo "Error: LOCALSTACK_AUTH_TOKEN environment variable is not set"
6-
echo "Please set your LocalStack Pro auth token:"
6+
echo "Please set your LocalStack auth token:"
77
echo "export LOCALSTACK_AUTH_TOKEN='your-token-here'"
88
exit 1
99
fi

examples/shell/localstack_dagger_module_pro.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@
33
# Check if LOCALSTACK_AUTH_TOKEN is set
44
if [ -z "$LOCALSTACK_AUTH_TOKEN" ]; then
55
echo "Error: LOCALSTACK_AUTH_TOKEN environment variable is not set"
6-
echo "Please set your LocalStack Pro auth token:"
6+
echo "Please set your LocalStack auth token:"
77
echo "export LOCALSTACK_AUTH_TOKEN='your-token-here'"
88
exit 1
99
fi
1010

11-
# Start LocalStack Pro with custom configuration
11+
# Start LocalStack with custom configuration
1212
dagger -m github.com/localstack/localstack-dagger-module \
1313
call start \
1414
--auth-token=env:LOCALSTACK_AUTH_TOKEN \
@@ -17,11 +17,11 @@ dagger -m github.com/localstack/localstack-dagger-module \
1717
up
1818

1919
# Wait for LocalStack to be ready
20-
echo "Waiting for LocalStack Pro to be ready..."
20+
echo "Waiting for LocalStack to be ready..."
2121
sleep 5
2222

2323
# Test the deployment by checking LocalStack health
2424
curl http://localhost:4566/_localstack/health
2525

26-
echo "LocalStack Pro is now running!"
26+
echo "LocalStack is now running!"
2727
echo "Access your AWS services at: http://localhost:4566"
Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,18 @@
11
#!/bin/bash
22

3-
# Start LocalStack Community edition
4-
dagger -m github.com/localstack/localstack-dagger-module call start up
3+
# Check if LOCALSTACK_AUTH_TOKEN is set
4+
if [ -z "$LOCALSTACK_AUTH_TOKEN" ]; then
5+
echo "Error: LOCALSTACK_AUTH_TOKEN environment variable is not set"
6+
echo "Please set your LocalStack auth token:"
7+
echo "export LOCALSTACK_AUTH_TOKEN='your-token-here'"
8+
exit 1
9+
fi
10+
11+
# Start LocalStack
12+
dagger -m github.com/localstack/localstack-dagger-module \
13+
call start \
14+
--auth-token=env:LOCALSTACK_AUTH_TOKEN \
15+
up
516

617
# Wait for LocalStack to be ready
718
echo "Waiting for LocalStack to be ready..."
@@ -10,5 +21,5 @@ sleep 5
1021
# Test the deployment by checking LocalStack health
1122
curl http://localhost:4566/_localstack/health
1223

13-
echo "LocalStack Community edition is now running!"
24+
echo "LocalStack is now running!"
1425
echo "Access your AWS services at: http://localhost:4566"

examples/shell/localstack_dagger_module_state.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ export AWS_REGION=us-east-1
77
# Check if LOCALSTACK_AUTH_TOKEN is set
88
if [ -z "$LOCALSTACK_AUTH_TOKEN" ]; then
99
echo "Error: LOCALSTACK_AUTH_TOKEN environment variable is not set"
10-
echo "Please set your LocalStack Pro auth token:"
10+
echo "Please set your LocalStack auth token:"
1111
echo "export LOCALSTACK_AUTH_TOKEN='your-token-here'"
1212
exit 1
1313
fi
1414

15-
# Start LocalStack Pro
15+
# Start LocalStack
1616
dagger -m github.com/localstack/localstack-dagger-module \
1717
call start \
1818
--auth-token=env:LOCALSTACK_AUTH_TOKEN \

examples/typescript/src/index.ts

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,17 @@ import { Readable } from "stream"
1010
@object()
1111
export class Example {
1212
/**
13-
* Demonstrates basic LocalStack functionality using the community edition.
13+
* Demonstrates basic LocalStack functionality.
1414
* Creates an S3 bucket and object to verify the setup is working correctly.
15-
*
15+
*
16+
* @param authToken - LocalStack authentication token
1617
* @returns Promise<void>
1718
*/
1819
@func()
19-
async localstack__quickstart() {
20+
async localstack__quickstart(authToken: Secret) {
2021
await connect(async (client) => {
2122
// Start LocalStack using the module
22-
const service = client.localstack().start()
23+
const service = client.localstack().start({ authToken })
2324

2425
await service.start()
2526
const endpoint = await service.endpoint()
@@ -62,10 +63,10 @@ export class Example {
6263
}
6364

6465
/**
65-
* Demonstrates LocalStack Pro functionality by starting a Pro instance
66+
* Demonstrates LocalStack functionality with custom configuration
6667
* and creating an ECR repository.
67-
*
68-
* @param authToken - LocalStack Pro authentication token
68+
*
69+
* @param authToken - LocalStack authentication token
6970
* @returns Promise<void>
7071
*/
7172
@func()
@@ -78,7 +79,7 @@ export class Example {
7879

7980
await service.start()
8081
const endpoint = await service.endpoint()
81-
console.log(`LocalStack Pro is running at ${endpoint}`)
82+
console.log(`LocalStack is running at ${endpoint}`)
8283

8384
// Create ECR client
8485
const ecr = new ECRClient({
@@ -102,8 +103,8 @@ export class Example {
102103
/**
103104
* Demonstrates LocalStack state management functionality using Cloud Pods.
104105
* Creates a test bucket, saves state to a pod, resets state, and loads it back.
105-
*
106-
* @param authToken - LocalStack Pro authentication token
106+
*
107+
* @param authToken - LocalStack authentication token
107108
* @returns Promise<void>
108109
*/
109110
@func()
@@ -163,8 +164,8 @@ export class Example {
163164
* Demonstrates LocalStack ephemeral instance management.
164165
* Creates an ephemeral instance, lists instances, retrieves logs,
165166
* and cleans up by deleting the instance.
166-
*
167-
* @param authToken - LocalStack Pro authentication token
167+
*
168+
* @param authToken - LocalStack authentication token
168169
* @returns Promise<void>
169170
*/
170171
@func()

0 commit comments

Comments
 (0)