Skip to content

Commit 6ee3df7

Browse files
committed
add examples for shell
1 parent 8a6d3af commit 6ee3df7

File tree

4 files changed

+143
-0
lines changed

4 files changed

+143
-0
lines changed
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#!/bin/bash
2+
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 Pro auth token:"
7+
echo "export LOCALSTACK_AUTH_TOKEN='your-token-here'"
8+
exit 1
9+
fi
10+
11+
# Create a new ephemeral instance
12+
echo "Creating new ephemeral instance 'my-temp-instance'..."
13+
dagger -m github.com/localstack/localstack-dagger-module \
14+
call ephemeral \
15+
--auth-token=env:LOCALSTACK_AUTH_TOKEN \
16+
--operation=create \
17+
--name=my-temp-instance \
18+
--lifetime=60
19+
20+
# Wait for instance to be ready
21+
echo "Waiting for instance to be ready..."
22+
sleep 15
23+
24+
# List all active ephemeral instances
25+
echo "Listing all active ephemeral instances..."
26+
dagger -m github.com/localstack/localstack-dagger-module \
27+
call ephemeral \
28+
--auth-token=env:LOCALSTACK_AUTH_TOKEN \
29+
--operation=list
30+
31+
# Get logs for our instance
32+
echo "Getting logs for 'my-temp-instance'..."
33+
dagger -m github.com/localstack/localstack-dagger-module \
34+
call ephemeral \
35+
--auth-token=env:LOCALSTACK_AUTH_TOKEN \
36+
--operation=logs \
37+
--name=my-temp-instance
38+
39+
# Delete the instance
40+
echo "Deleting 'my-temp-instance'..."
41+
dagger -m github.com/localstack/localstack-dagger-module \
42+
call ephemeral \
43+
--auth-token=env:LOCALSTACK_AUTH_TOKEN \
44+
--operation=delete \
45+
--name=my-temp-instance
46+
47+
echo "Ephemeral instance operations completed!"
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/bin/bash
2+
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 Pro auth token:"
7+
echo "export LOCALSTACK_AUTH_TOKEN='your-token-here'"
8+
exit 1
9+
fi
10+
11+
# Start LocalStack Pro with custom configuration
12+
dagger -m github.com/localstack/localstack-dagger-module \
13+
call start \
14+
--auth-token=env:LOCALSTACK_AUTH_TOKEN \
15+
--configuration='DEBUG=1' \
16+
--docker-sock=/var/run/docker.sock \
17+
up
18+
19+
# Wait for LocalStack to be ready
20+
echo "Waiting for LocalStack Pro to be ready..."
21+
sleep 5
22+
23+
# Test the deployment by checking LocalStack health
24+
curl http://localhost:4566/_localstack/health
25+
26+
echo "LocalStack Pro is now running!"
27+
echo "Access your AWS services at: http://localhost:4566"
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/bin/bash
2+
3+
# Start LocalStack Community edition
4+
dagger -m github.com/localstack/localstack-dagger-module call start up
5+
6+
# Wait for LocalStack to be ready
7+
echo "Waiting for LocalStack to be ready..."
8+
sleep 5
9+
10+
# Test the deployment by checking LocalStack health
11+
curl http://localhost:4566/_localstack/health
12+
13+
echo "LocalStack Community edition is now running!"
14+
echo "Access your AWS services at: http://localhost:4566"
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
#!/bin/bash
2+
3+
export AWS_ACCESS_KEY_ID=test
4+
export AWS_SECRET_ACCESS_KEY=test
5+
export AWS_REGION=us-east-1
6+
7+
# Check if LOCALSTACK_AUTH_TOKEN is set
8+
if [ -z "$LOCALSTACK_AUTH_TOKEN" ]; then
9+
echo "Error: LOCALSTACK_AUTH_TOKEN environment variable is not set"
10+
echo "Please set your LocalStack Pro auth token:"
11+
echo "export LOCALSTACK_AUTH_TOKEN='your-token-here'"
12+
exit 1
13+
fi
14+
15+
# Start LocalStack Pro
16+
dagger -m github.com/localstack/localstack-dagger-module \
17+
call start \
18+
--auth-token=env:LOCALSTACK_AUTH_TOKEN \
19+
up
20+
21+
echo "Waiting for LocalStack to be ready..."
22+
sleep 5
23+
24+
# Create a test S3 bucket using AWS CLI
25+
aws --endpoint-url=http://localhost:4566 s3 mb s3://my-test-bucket
26+
27+
# Save the current state to a Cloud Pod
28+
echo "Saving current state to Cloud Pod 'my-test-pod'..."
29+
dagger -m github.com/localstack/localstack-dagger-module \
30+
call state \
31+
--auth-token=env:LOCALSTACK_AUTH_TOKEN \
32+
--save=my-test-pod
33+
34+
# Reset the state (this will remove all resources)
35+
echo "Resetting LocalStack state..."
36+
dagger -m github.com/localstack/localstack-dagger-module \
37+
call state \
38+
--reset
39+
40+
# Verify the bucket is gone
41+
if ! aws --endpoint-url=http://localhost:4566 s3 ls s3://my-test-bucket 2>/dev/null; then
42+
echo "State reset successful - bucket no longer exists"
43+
fi
44+
45+
# Load the saved state back
46+
echo "Loading state from Cloud Pod 'my-test-pod'..."
47+
dagger -m github.com/localstack/localstack-dagger-module \
48+
call state \
49+
--auth-token=env:LOCALSTACK_AUTH_TOKEN \
50+
--load=my-test-pod
51+
52+
# Verify the bucket is back
53+
if aws --endpoint-url=http://localhost:4566 s3 ls s3://my-test-bucket 2>/dev/null; then
54+
echo "State restored successfully - bucket exists again"
55+
fi

0 commit comments

Comments
 (0)