### Install Dependencies and Run Tests Source: https://github.com/ministackorg/ministack/blob/main/README.md Commands to install necessary Python packages for testing, start the MiniStack service using Docker Compose, and execute the full test suite. ```bash # Install test dependencies pip install boto3 pytest duckdb docker cbor2 # Start MiniStack docker compose up -d # Run the full test suite (2,500+ tests across all services) pytest tests/ -v ``` -------------------------------- ### Amplify/CDK Sandbox Setup Source: https://github.com/ministackorg/ministack/blob/main/README.md Set the AWS endpoint URL and start the Amplify sandbox. This is used for local development with Amplify Gen 2. ```bash export AWS_ENDPOINT_URL=http://localhost:4566 npx ampx sandbox ``` -------------------------------- ### Install Dependencies Source: https://github.com/ministackorg/ministack/blob/main/Testcontainers/python-testcontainers/README.md Installs project dependencies using pip. ```bash pip install -r requirements.txt ``` -------------------------------- ### Install Dependencies and Run Tests Source: https://github.com/ministackorg/ministack/blob/main/Testcontainers/go-testcontainers/README.md Ensures all Go modules are tidy and then executes all tests in the project. Testcontainers will automatically manage the MiniStack container. ```bash go mod tidy go test ./... -v ``` -------------------------------- ### Run MiniStack Tests Locally Source: https://github.com/ministackorg/ministack/blob/main/CONTRIBUTING.md Commands to set up and run tests locally. Includes starting the Docker Compose stack, installing dependencies, and executing parallel-safe and serial test phases. ```bash # Start the stack docker compose up -d # Install test dependencies pip install boto3 pytest pytest-xdist duckdb docker cbor2 # Parallel-safe phase: run tests that are safe to run concurrently pytest tests/ -v -n 4 --dist=loadfile -m "not serial" # Serial/global-state phase: run tests that mutate runtime state or require isolation pytest tests/ -v -m serial # Run a specific service pytest tests/ -v -k "cognito" ``` -------------------------------- ### Seed Data using Python SDK in Startup Script Source: https://github.com/ministackorg/ministack/blob/main/README.md Example of a Python script using the boto3 SDK to put an object into an S3 bucket within the MiniStack environment. ```python # ready.d/02-seed-data.py import boto3, os s3 = boto3.client("s3", endpoint_url=os.environ["AWS_ENDPOINT_URL"]) s3.put_object(Bucket="my-bucket", Key="config.json", Body=b'{"env": "local"}') ``` -------------------------------- ### Install and Run MiniStack via PyPI Source: https://github.com/ministackorg/ministack/blob/main/README.md Install MiniStack using pip and run it directly. The service defaults to port 4566, but this can be changed using the GATEWAY_PORT environment variable. ```bash pip install ministack ministack # Runs on http://localhost:4566 — use GATEWAY_PORT=XXXX to change ``` -------------------------------- ### Run AWS CLI Commands in Startup Script Source: https://github.com/ministackorg/ministack/blob/main/README.md Example of a bash script to create an S3 bucket, copy a file, and create an SQS queue using AWS CLI commands within the MiniStack environment. ```bash # ready.d/01-create-resources.sh aws s3 mb s3://my-bucket aws s3 cp "${MINISTACK_INIT_SCRIPT_DIR}/seed-data.json" s3://my-bucket/ aws sqs create-queue --queue-name my-queue ``` -------------------------------- ### Run MiniStack with State Persistence Source: https://github.com/ministackorg/ministack/blob/main/README.md Docker run command to start MiniStack with state persistence enabled, specifying a directory for state storage and mounting a volume for data. ```bash docker run -p 4566:4566 \ -e PERSIST_STATE=1 \ -e STATE_DIR=/data/ministack-state \ -v /tmp/ministack-data:/data \ ministackorg/ministack ``` -------------------------------- ### Example Test Output Source: https://github.com/ministackorg/ministack/blob/main/README.md Illustrative output from running the MiniStack test suite, showing individual test case results and a summary of passed tests and execution time. ```text tests/test_s3.py::test_s3_create_bucket PASSED ... tests/test_lambda.py::test_lambda_invoke PASSED 2100+ passed in ~120s ``` -------------------------------- ### Build and Run MiniStack from Source Source: https://github.com/ministackorg/ministack/blob/main/README.md Clone the MiniStack repository, navigate to the directory, and use Docker Compose to build and run the services. ```bash git clone https://github.com/ministackorg/ministack cd ministack docker compose up -d ``` -------------------------------- ### AWS STS Get Caller Identity with Multi-Tenancy Source: https://github.com/ministackorg/ministack/blob/main/README.md Demonstrates how MiniStack uses a 12-digit AWS access key as the account ID for ARN generation, enabling multi-tenancy. This example shows how different access keys result in different account IDs. ```bash # Team A — gets account 111111111111 export AWS_ACCESS_KEY_ID=111111111111 export AWS_SECRET_ACCESS_KEY=anything aws --endpoint-url=http://localhost:4566 sts get-caller-identity # → { "Account": "111111111111", ... } ``` ```bash # Team B — gets account 222222222222 export AWS_ACCESS_KEY_ID=222222222222 export AWS_SECRET_ACCESS_KEY=anything aws --endpoint-url=http://localhost:4566 sts get-caller-identity # → { "Account": "222222222222", ... } ``` -------------------------------- ### Create VPC and Subnet Source: https://github.com/ministackorg/ministack/blob/main/README.md Shows how to create a Virtual Private Cloud (VPC) and a subnet within it. ```python vpc = ec2.create_vpc(CidrBlock="10.0.0.0/16") subnet = ec2.create_subnet( VpcId=vpc["Vpc"]["VpcId"], CidrBlock="10.0.1.0/24", AvailabilityZone="us-east-1a", ) ``` -------------------------------- ### Create DynamoDB Table and Put Item Source: https://github.com/ministackorg/ministack/blob/main/README.md Demonstrates creating a DynamoDB table with a hash key and inserting an item. ```python ddb = client("dynamodb") ddb.create_table( TableName="Users", KeySchema=[{"AttributeName": "userId", "KeyType": "HASH"}], AttributeDefinitions=[{"AttributeName": "userId", "AttributeType": "S"}], BillingMode="PAY_PER_REQUEST", ) ddb.put_item(TableName="Users", Item={"userId": {"S": "u1"}, "name": {"S": "Alice"}}) ``` -------------------------------- ### Put and Get SSM Parameter Source: https://github.com/ministackorg/ministack/blob/main/README.md Shows how to store a String parameter in SSM Parameter Store and retrieve it. ```python ssm = client("ssm") ssm.put_parameter(Name="/app/db/host", Value="localhost", Type="String") param = ssm.get_parameter(Name="/app/db/host") print(param["Parameter"]["Value"]) # localhost ``` -------------------------------- ### Verify MiniStack Service Health Source: https://github.com/ministackorg/ministack/blob/main/README.md Check if the MiniStack service is running by sending a GET request to the internal health check endpoint. ```bash curl http://localhost:4566/_ministack/health ``` -------------------------------- ### Run EC2 Instance Source: https://github.com/ministackorg/ministack/blob/main/README.md This snippet shows how to launch a new EC2 instance with a specified AMI and instance type. ```python ec2 = client("ec2") reservation = ec2.run_instances( ImageId="ami-00000001", MinCount=1, MaxCount=1, InstanceType="t3.micro", ) instance_id = reservation["Instances"][0]["InstanceId"] print(instance_id) # i-xxxxxxxxxxxxxxxxx ``` -------------------------------- ### Configure MiniStack Runtime Settings Source: https://github.com/ministackorg/ministack/blob/main/README.md Adjust service-level configurations dynamically without restarting MiniStack. This example changes the Lambda executor to use Docker. ```bash curl -X POST http://localhost:4566/_ministack/config \ -H "Content-Type: application/json" \ -d '{"lambda_svc.LAMBDA_EXECUTOR": "docker"}' ``` -------------------------------- ### Docker Compose for Startup Scripts Source: https://github.com/ministackorg/ministack/blob/main/README.md Docker Compose configuration showing how to mount local init scripts into the MiniStack container using either the MiniStack-native or LocalStack-compatible paths. ```yaml volumes: - ./init-scripts:/docker-entrypoint-initaws.d # ministack-native # OR - ./init-scripts:/etc/localstack/init # localstack-compatible ```