localstack
This module has been generated via dagger init and serves as a reference tobasic module structure as you get started with Dagger.
Two functions have been pre-created. You can modify, delete, or add to them,
as needed. They demonstrate usage of arguments and return types using simple
echo and grep commands. The functions can be called from the dagger CLI or
from one of the SDKs.
The first line in this comment block is a short description line and the
rest is a long description with more detail on the module's purpose or usage,
if appropriate. All modules should have a short description.
Example
no available example in current language
no available example in current language
no available example in current language
/**
* Demonstrates LocalStack Pro functionality by starting a Pro instance
* and creating an ECR repository.
*
* @param authToken - LocalStack Pro authentication token
* @returns Promise<void>
*/
@func()
async localstack__pro(authToken: Secret) {
await connect(async (client) => {
const service = client.localstack().start({
authToken,
configuration: "DEBUG=1,SERVICES=ecr",
})
await service.start()
const endpoint = await service.endpoint()
console.log(`LocalStack Pro is running at ${endpoint}`)
// Create ECR client
const ecr = new ECRClient({
endpoint: `http://${endpoint}`,
credentials: {
accessKeyId: "test",
secretAccessKey: "test"
},
region: "us-east-1"
})
// Create a test repository
const repositoryName = "test-ecr-repo"
await ecr.send(new CreateRepositoryCommand({
repositoryName
}))
console.log(`ECR repository '${repositoryName}' created`)
})
}
Example
no available example in current language
no available example in current language
no available example in current language
/**
* Demonstrates LocalStack state management functionality using Cloud Pods.
* Creates a test bucket, saves state to a pod, resets state, and loads it back.
*
* @param authToken - LocalStack Pro authentication token
* @returns Promise<void>
*/
@func()
async localstack__state(authToken: Secret) {
await connect(async (client) => {
const service = client.localstack().start({
authToken
})
await service.start()
const endpoint = await service.endpoint()
// Create S3 client and test bucket
const s3 = new S3Client({
endpoint: `http://${endpoint}`,
credentials: {
accessKeyId: "test",
secretAccessKey: "test"
},
region: "us-east-1",
forcePathStyle: true
})
await s3.send(new CreateBucketCommand({
Bucket: "test-bucket"
}))
console.log("Test bucket created")
// Save state to Cloud Pod
await client.localstack().state({
authToken,
save: "test-dagger-example-pod",
endpoint: `http://${endpoint}`
})
console.log("State saved to Cloud Pod")
// Reset state
await client.localstack().state({
reset: true,
endpoint: `http://${endpoint}`
})
console.log("State reset")
// Load state back
await client.localstack().state({
authToken,
load: "test-dagger-example-pod",
endpoint: `http://${endpoint}`
})
console.log("State loaded from Cloud Pod")
})
}
Example
no available example in current language
no available example in current language
no available example in current language
/**
* Demonstrates LocalStack ephemeral instance management.
* Creates an ephemeral instance, lists instances, retrieves logs,
* and cleans up by deleting the instance.
*
* @param authToken - LocalStack Pro authentication token
* @returns Promise<void>
*/
@func()
async localstack__ephemeral(authToken: Secret) {
await connect(async (client) => {
// Create a new ephemeral instance
await client.localstack().ephemeral(
authToken,
"create",
{
name: "test-dagger-example-instance",
lifetime: 60
}
)
console.log("Instance created")
// Wait for instance to be ready
await new Promise(resolve => setTimeout(resolve, 15000))
// List instances
const listResponse = await client.localstack().ephemeral(
authToken,
"list"
)
console.log(`Ephemeral instances: ${listResponse}`)
// Get instance logs
const instanceLogs = await client.localstack().ephemeral(
authToken,
"logs",
{
name: "test-dagger-example-instance"
}
)
console.log(`Instance logs: ${instanceLogs}`)
// Delete instance
await client.localstack().ephemeral(
authToken,
"delete",
{
name: "test-dagger-example-instance"
}
)
console.log("Instance deleted")
})
}
Example
no available example in current language
no available example in current language
no available example in current language
/**
* Demonstrates basic LocalStack functionality using the community edition.
* Creates an S3 bucket and object to verify the setup is working correctly.
*
* @returns Promise<void>
*/
@func()
async localstack__quickstart() {
await connect(async (client) => {
// Start LocalStack using the module
const service = client.localstack().start()
await service.start()
const endpoint = await service.endpoint()
console.log(`LocalStack is running at ${endpoint}`)
// Create S3 client
const s3 = new S3Client({
endpoint: `http://${endpoint}`,
credentials: {
accessKeyId: "test",
secretAccessKey: "test"
},
region: "us-east-1",
forcePathStyle: true
})
// Create a test bucket
await s3.send(new CreateBucketCommand({
Bucket: "test-bucket"
}))
console.log("S3 bucket created")
// Create a test object
await s3.send(new PutObjectCommand({
Bucket: "test-bucket",
Key: "test-object",
Body: "Hello, LocalStack!"
}))
console.log("S3 object created")
// Verify the object was created
const response = await s3.send(new GetObjectCommand({
Bucket: "test-bucket",
Key: "test-object"
}))
const content = await streamToString(response.Body as Readable)
console.log(`S3 object content: ${content}`)
})
}
Installation
dagger install github.com/localstack/localstack-dagger-module@2c1bc63f21c6431982587799b1f7a30adbc2251d
Entrypoint
Return Type
Localstack !
Example
dagger -m github.com/localstack/localstack-dagger-module@2c1bc63f21c6431982587799b1f7a30adbc2251d call \
func (m *myModule) example() *dagger.Localstack {
return dag.
Localstack()
}
@function
def example() -> dagger.Localstack:
return (
dag.localstack()
)
@func()
example(): Localstack {
return dag
.localstack()
}
Types
Localstack 🔗
LocalStack service management functions.
ephemeral() 🔗
Manage ephemeral LocalStack instances in the cloud.
Return Type
String !
Arguments
Name | Type | Default Value | Description |
---|---|---|---|
authToken | Secret ! | - | LocalStack Auth Token (required) |
operation | String ! | - | Operation to perform (create, list, delete, logs) |
name | String | null | Name of the ephemeral instance (required for create, delete, logs) |
lifetime | Integer | null | Lifetime of the instance in minutes (default: 60) |
autoLoadPod | String | null | Auto load pod configuration |
extensionAutoInstall | String | null | Extension auto install configuration |
Example
dagger -m github.com/localstack/localstack-dagger-module@2c1bc63f21c6431982587799b1f7a30adbc2251d call \
ephemeral --auth-token env:MYSECRET --operation string
func (m *myModule) example(ctx context.Context, authToken *dagger.Secret, operation string) string {
return dag.
Localstack().
Ephemeral(ctx, authToken, operation)
}
@function
async def example(auth_token: dagger.Secret, operation: str) -> str:
return await (
dag.localstack()
.ephemeral(auth_token, operation)
)
@func()
async example(authToken: Secret, operation: string): Promise<string> {
return dag
.localstack()
.ephemeral(authToken, operation)
}
start() 🔗
Start a LocalStack service with appropriate configuration.
Return Type
Service !
Arguments
Name | Type | Default Value | Description |
---|---|---|---|
authToken | Secret | null | LocalStack Pro Auth Token for authentication |
configuration | String | null | Configuration variables in format 'KEY1=value1,KEY2=value2' |
dockerSock | Socket | null | Docker socket for container interactions |
imageName | String | null | Custom LocalStack image name to use |
Example
echo 'Custom types are not supported in shell examples'
func (m *myModule) example() *dagger.Service {
return dag.
Localstack().
Start()
}
@function
def example() -> dagger.Service:
return (
dag.localstack()
.start()
)
@func()
example(): Service {
return dag
.localstack()
.start()
}
state() 🔗
Load, save, or reset LocalStack state.
Return Type
String !
Arguments
Name | Type | Default Value | Description |
---|---|---|---|
authToken | Secret | null | LocalStack Auth Token (required for save/load) |
load | String | null | Name of the Cloud Pod to load |
save | String | null | Name of the Cloud Pod to save |
endpoint | String | null | LocalStack endpoint (defaults to host.docker.internal:4566) |
reset | Boolean ! | false | Reset the LocalStack state |
Example
dagger -m github.com/localstack/localstack-dagger-module@2c1bc63f21c6431982587799b1f7a30adbc2251d call \
state --reset boolean
func (m *myModule) example(ctx context.Context, reset bool) string {
return dag.
Localstack().
State(ctxreset)
}
@function
async def example(reset: bool) -> str:
return await (
dag.localstack()
.state(reset)
)
@func()
async example(reset: boolean): Promise<string> {
return dag
.localstack()
.state(reset)
}