### Install BATS with npm Source: https://github.com/localstack/awscli-local/blob/master/tests/bin/README.md Install BATS globally using npm. Ensure you have Node.js and npm installed. ```bash npm install -g bats ``` -------------------------------- ### Install awscli-local with AWS CLI v1 Source: https://github.com/localstack/awscli-local/blob/master/README.md Install the awslocal command and AWS CLI v1 using pip. This is the recommended method for most users. ```console pip install awscli-local[ver1] ``` -------------------------------- ### Install BATS Manually Source: https://github.com/localstack/awscli-local/blob/master/tests/bin/README.md Manually install BATS by cloning the repository and running the install script. This method requires sudo privileges. ```bash git clone https://github.com/bats-core/bats-core.git cd bats-core sudo ./install.sh /usr/local ``` -------------------------------- ### AWS CLI vs awslocal Usage Example Source: https://github.com/localstack/awscli-local/blob/master/README.md Demonstrates the equivalent commands for listing Kinesis streams using the standard AWS CLI with a specified endpoint and the awslocal wrapper. ```console aws --endpoint-url=http://localhost:4566 kinesis list-streams ``` ```console awslocal kinesis list-streams ``` -------------------------------- ### Install AWS CLI v2 from Source Source: https://github.com/localstack/awscli-local/blob/master/README.md Install AWS CLI v2 from GitHub sources within a virtual environment. This is an unofficial method and requires careful management to avoid conflicts. ```console virtualenv .venv . .venv/bin/activate pip install https://github.com/boto/botocore/archive/v2.zip https://github.com/aws/aws-cli/archive/v2.zip ``` -------------------------------- ### Install awscli-local with AWS CLI v1 Source: https://context7.com/localstack/awscli-local/llms.txt Installs the awscli-local package, including AWS CLI v1. Use quotes for macOS or ZSH. ```bash pip install awscli-local[ver1] ``` ```bash pip install "awscli-local[ver1]" ``` -------------------------------- ### Install BATS with Homebrew Source: https://github.com/localstack/awscli-local/blob/master/tests/bin/README.md Install BATS core on macOS using the Homebrew package manager. ```bash brew install bats-core ``` -------------------------------- ### Install awscli-local without AWS CLI Source: https://github.com/localstack/awscli-local/blob/master/README.md Install only the awslocal wrapper script without automatically installing the AWS CLI. This is useful if you manage your own AWS CLI installation. ```console pip install awscli-local ``` -------------------------------- ### Install awscli-local on macOS/ZSH Source: https://github.com/localstack/awscli-local/blob/master/README.md Install the awslocal command and AWS CLI v1 on macOS or ZSH environments using pip. Ensure quotes are used for the package name. ```console pip install "awscli-local[ver1]" ``` -------------------------------- ### Basic BATS Test Example Source: https://github.com/localstack/awscli-local/blob/master/tests/bin/README.md A simple BATS test file demonstrating a basic test case. It checks the exit status and output of a command. ```bash #!/usr/bin/env bats @test "test description" { run echo "hello" [ "$status" -eq 0 ] [ "$output" = "hello" ] } ``` -------------------------------- ### DynamoDB Operations with awslocal Source: https://context7.com/localstack/awscli-local/llms.txt Shows how to create a DynamoDB table, put an item, and query an item using awslocal. ```bash # Create a DynamoDB table awslocal dynamodb create-table \ --table-name Users \ --key-schema AttributeName=UserId,KeyType=HASH \ --attribute-definitions AttributeName=UserId,AttributeType=S \ --billing-mode PAY_PER_REQUEST ``` ```bash # Put an item into the table awslocal dynamodb put-item \ --table-name Users \ --item '{"UserId": {"S": "user123"}, "Name": {"S": "John Doe"}, "Email": {"S": "john@example.com"}}' ``` ```bash # Query an item awslocal dynamodb get-item \ --table-name Users \ --key '{"UserId": {"S": "user123"}}' ``` ```json # Expected output: # { # "Item": { # "UserId": {"S": "user123"}, # "Name": {"S": "John Doe"}, # "Email": {"S": "john@example.com"} # } # } ``` -------------------------------- ### SQS Operations with awslocal Source: https://context7.com/localstack/awscli-local/llms.txt Demonstrates creating an SQS queue, sending and receiving messages, and deleting the queue using awslocal. ```bash # Create an SQS queue awslocal sqs create-queue --queue-name my-queue ``` ```bash # Send a message to the queue awslocal sqs send-message \ --queue-url http://localhost:4566/000000000000/my-queue \ --message-body "Hello from LocalStack" ``` ```bash # Receive messages from the queue awslocal sqs receive-message \ --queue-url http://localhost:4566/000000000000/my-queue ``` ```bash # Delete the queue awslocal sqs delete-queue \ --queue-url http://localhost:4566/000000000000/my-queue ``` -------------------------------- ### Kinesis Operations with awslocal Source: https://context7.com/localstack/awscli-local/llms.txt Shows how to create a Kinesis stream, list streams, and put a record into a stream using awslocal. ```bash # Create a Kinesis stream awslocal kinesis create-stream \ --stream-name my-stream \ --shard-count 1 ``` ```bash # List all streams awslocal kinesis list-streams ``` ```json # Expected output: # { # "StreamNames": [ # "my-stream" # ] # } ``` ```bash # Put a record into the stream awslocal kinesis put-record \ --stream-name my-stream \ --data "SGVsbG8gV29ybGQ=" \ --partition-key "partition-1" ``` -------------------------------- ### S3 Operations with awslocal Source: https://context7.com/localstack/awscli-local/llms.txt Demonstrates common S3 operations including bucket creation, file upload/download, and deletion using awslocal. ```bash # Create a new S3 bucket awslocal s3 mb s3://my-test-bucket ``` ```bash # Upload a file to S3 awslocal s3 cp ./local-file.txt s3://my-test-bucket/ ``` ```bash # List bucket contents awslocal s3 ls s3://my-test-bucket/ ``` ```bash # Download a file from S3 awslocal s3 cp s3://my-test-bucket/local-file.txt ./downloaded-file.txt ``` ```bash # Remove a bucket and all contents awslocal s3 rb s3://my-test-bucket --force ``` -------------------------------- ### List S3 Buckets with awslocal Source: https://context7.com/localstack/awscli-local/llms.txt Compares the standard AWS CLI command with the simplified awslocal command for listing S3 buckets. ```bash # Standard AWS CLI (verbose) aws --endpoint-url=http://localhost:4566 s3api list-buckets ``` ```bash # Using awslocal (simplified) awslocal s3api list-buckets ``` ```json # Expected output: # { # "Buckets": [ # { # "Name": "my-bucket", # "CreationDate": "2024-01-15T10:30:00+00:00" # } # ], # "Owner": { # "DisplayName": "webfile", # "ID": "75aa57f09aa0c8caeab4f8c24e99d10f8e7faeebf76c078efc7c6caea54ba06a" # } # } ``` -------------------------------- ### List Lambda Functions with awslocal Source: https://context7.com/localstack/awscli-local/llms.txt Lists all Lambda functions within the LocalStack environment using the awslocal command. ```bash # List all Lambda functions in LocalStack awslocal lambda list-functions ``` ```json # Expected output: # { # "Functions": [] # } ``` -------------------------------- ### Run All BATS Tests in Directory Source: https://github.com/localstack/awscli-local/blob/master/tests/bin/README.md Run all files with the `.bats` extension located in the specified directory. ```bash bats tests/bin ``` -------------------------------- ### Legacy LocalStack Configuration Source: https://context7.com/localstack/awscli-local/llms.txt Configure LocalStack host and SSL settings using legacy environment variables. These are deprecated but still supported. ```bash # Legacy configuration (deprecated but still supported) export LOCALSTACK_HOST=localhost:4566 export USE_SSL=false awslocal kinesis list-streams ``` -------------------------------- ### Package and Deploy SAM Template with awslocal Source: https://context7.com/localstack/awscli-local/llms.txt Utilizes awslocal for packaging and deploying AWS SAM templates, automatically handling S3 endpoint configuration. ```bash # Create a bucket for CloudFormation artifacts awslocal s3 mb s3://cfn-deployment-bucket ``` ```bash # Package the CloudFormation/SAM template awslocal cloudformation package \ --template-file template.yaml \ --output-template-file packaged-template.yaml \ --s3-bucket cfn-deployment-bucket ``` ```bash # Deploy the packaged template awslocal cloudformation deploy \ --template-file packaged-template.yaml \ --stack-name my-application-stack ``` ```bash # Describe the deployed stack awslocal cloudformation describe-stacks \ --stack-name my-application-stack ``` -------------------------------- ### Run BATS Tests with Debugging Options Source: https://github.com/localstack/awscli-local/blob/master/tests/bin/README.md Execute BATS tests with trace, verbose run, and output printing on failure enabled for detailed debugging. ```bash bats --trace --verbose-run --print-output-on-failure -r tests/bin/ ``` -------------------------------- ### Configure Bash Completion for awslocal Source: https://context7.com/localstack/awscli-local/llms.txt Set up persistent bash completion for the awslocal command by adding it to your ~/.bashrc file. This provides command and parameter suggestions. ```bash # Add to ~/.bashrc for persistent completion support complete -C '/usr/local/bin/aws_completer' aws complete -C '/usr/local/bin/aws_completer' awslocal # Reload bash configuration source ~/.bashrc # Usage example - type 'awslocal dynamodb d' and press Tab: # $ awslocal dynamodb d # delete-backup describe-global-table # delete-item describe-global-table-settings # delete-table describe-limits # describe-backup describe-table # describe-continuous-backups describe-table-replica-auto-scaling # describe-contributor-insights describe-time-to-live # describe-endpoints ``` -------------------------------- ### Query Specific Output Values with awslocal Source: https://context7.com/localstack/awscli-local/llms.txt Query specific output values from a CloudFormation stack. Ensure the stack name and output key are correctly specified. ```bash awslocal cloudformation describe-stacks \ --stack-name my-application-stack \ --query "Stacks[0].Outputs[?OutputKey=='LambdaURL'].OutputValue" \ --output text ``` -------------------------------- ### Run Specific BATS Test File Source: https://github.com/localstack/awscli-local/blob/master/tests/bin/README.md Execute a single BATS test file using the `bats` command. ```bash bats test_example.bats ``` -------------------------------- ### Bash Command Completion Configuration Source: https://github.com/localstack/awscli-local/blob/master/README.md Configure bash shell completion for both the standard AWS CLI and the awslocal wrapper. Ensure the path to `aws_completer` is correct for your system. ```sh complete -C '/usr/local/bin/aws_completer' aws complete -C '/usr/local/bin/aws_completer' awslocal ``` -------------------------------- ### Configure Custom LocalStack Endpoint Source: https://context7.com/localstack/awscli-local/llms.txt Set a custom endpoint URL for LocalStack using the AWS_ENDPOINT_URL environment variable. This is the highest priority configuration method. ```bash # Set custom endpoint URL (highest priority) export AWS_ENDPOINT_URL=http://localstack:4566 # Now all awslocal commands use the custom endpoint awslocal s3 ls ``` ```bash # For Docker Compose environments export AWS_ENDPOINT_URL=http://localstack:4566 awslocal lambda list-functions ``` -------------------------------- ### Simple Bash Alias for awslocal Source: https://context7.com/localstack/awscli-local/llms.txt Create a simple bash alias for awslocal to streamline basic usage. This alias sets default credentials and endpoint URL. ```bash # Add to ~/.bashrc or ~/.zshrc alias awslocal="AWS_ACCESS_KEY_ID=test AWS_SECRET_ACCESS_KEY=test AWS_DEFAULT_REGION=\" ${DEFAULT_REGION:-\" $AWS_DEFAULT_REGION}\" aws --endpoint-url=http://\ ${LOCALSTACK_HOST:-localhost}:4566" # Usage (same as awslocal command) awslocal s3 ls awslocal dynamodb list-tables # Note: This alias does NOT support the --s3-endpoint-url parameter # required for 'cloudformation package' commands. Use the full # awslocal package for CloudFormation workflows. ``` -------------------------------- ### Create Bash Alias for LocalStack Source: https://github.com/localstack/awscli-local/blob/master/README.md This bash alias simplifies LocalStack usage by setting default credentials, region, and endpoint URL. It's a convenient alternative to the awscli-local package for most commands, except for CloudFormation package operations. ```bash alias awslocal="AWS_ACCESS_KEY_ID=test AWS_SECRET_ACCESS_KEY=test AWS_DEFAULT_REGION=${DEFAULT_REGION:-$AWS_DEFAULT_REGION} aws --endpoint-url=http://${LOCALSTACK_HOST:-localhost}:4566" ``` -------------------------------- ### Clean Up Deployment Bucket with awslocal Source: https://context7.com/localstack/awscli-local/llms.txt Forcefully remove a CloudFormation deployment bucket using awslocal. Use with caution as this will delete all contents of the bucket. ```bash awslocal s3 rb s3://cfn-deployment-bucket --force ``` -------------------------------- ### Override Default Credentials Source: https://context7.com/localstack/awscli-local/llms.txt Override default AWS credentials and region for awslocal commands. Useful for testing specific credential configurations. ```bash # Override default credentials (if needed) export AWS_ACCESS_KEY_ID=test export AWS_SECRET_ACCESS_KEY=test export AWS_DEFAULT_REGION=us-east-1 awslocal sts get-caller-identity ``` -------------------------------- ### Delete CloudFormation Stack with awslocal Source: https://context7.com/localstack/awscli-local/llms.txt Delete a CloudFormation stack using awslocal. This command is typically used for cleanup after testing. ```bash awslocal cloudformation delete-stack \ --stack-name my-application-stack ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.