Dagger
Search

localstack

No long description provided.

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}`)
    })
  }
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`)
    })
  }

Installation

dagger install github.com/localstack/localstack-dagger-module@6e2683e20e54e7ceab130ebe2abed050b6670ed2

Entrypoint

Return Type
Localstack !
Example
dagger -m github.com/localstack/localstack-dagger-module@6e2683e20e54e7ceab130ebe2abed050b6670ed2 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
NameTypeDefault ValueDescription
authTokenSecret !-LocalStack Auth Token (required)
operationString !-Operation to perform (create, list, delete, logs)
nameString nullName of the ephemeral instance (required for create, delete, logs)
lifetimeInteger nullLifetime of the instance in minutes (default: 60)
autoLoadPodString nullAuto load pod configuration
extensionAutoInstallString nullExtension auto install configuration
Example
dagger -m github.com/localstack/localstack-dagger-module@6e2683e20e54e7ceab130ebe2abed050b6670ed2 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
NameTypeDefault ValueDescription
authTokenSecret nullLocalStack Pro Auth Token for authentication
configurationString nullConfiguration variables in format 'KEY1=value1,KEY2=value2'
dockerSockSocket nullDocker socket for container interactions
imageNameString nullCustom 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
NameTypeDefault ValueDescription
authTokenSecret nullLocalStack Auth Token (required for save/load)
loadString nullName of the Cloud Pod to load
saveString nullName of the Cloud Pod to save
endpointString nullLocalStack endpoint (defaults to host.docker.internal:4566)
resetBoolean !falseReset the LocalStack state
Example
dagger -m github.com/localstack/localstack-dagger-module@6e2683e20e54e7ceab130ebe2abed050b6670ed2 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)
}