localstack-pro-samples
localstack-pro-samples copied to clipboard
Migrate from deprecated LOCALSTACK_API_KEY to LOCALSTACK_AUTH_TOKEN
Summary
This PR migrates all usages of the deprecated LOCALSTACK_API_KEY environment variable to the new LOCALSTACK_AUTH_TOKEN to ensure continued authentication with LocalStack Pro services.
Background
The LOCALSTACK_API_KEY has been sunset and will no longer work for authentication. Without this migration, sample tests will fail due to authentication errors since the API key mechanism is deprecated. FIXES #262
Changes Made
Core Migration
-
.github/workflows/makefile.yml: Updated CI workflow to useLOCALSTACK_AUTH_TOKENinstead ofLOCALSTACK_API_KEY -
emr-serverless-python-dependencies/docker-compose.yml: Removed deprecatedLOCALSTACK_API_KEYenvironment variable
Documentation Updates
-
testcontainers-java-sample/LocalStackTestcontainers/src/test/java/TestRDS.java: Updated variable name fromapi_keytoauthTokenfor consistency -
sample-archive/spring-cloud-function-microservice/.env.example: Updated placeholder format from<your-pro=api-key>to<your-auth-token> -
java-notification-app/README.md: Updated documentation to use<your-auth-token>format -
route53-dns-failover/README.md: Updated documentation to use<your-auth-token>format
Testing Steps
1. Verification of Migration
# Confirmed no LOCALSTACK_API_KEY references remain
grep -r "LOCALSTACK_API_KEY" . --exclude-dir=.git
# Result: No matches found ✅
# Verified LOCALSTACK_AUTH_TOKEN is properly used
grep -r "LOCALSTACK_AUTH_TOKEN" . --exclude-dir=.git | wc -l
# Result: 40+ references found ✅
2. Local Testing
# Set up environment
export LOCALSTACK_AUTH_TOKEN=<auth-token>
pip install localstack[pro] awscli-local
# Test basic functionality
localstack start -d
localstack wait -t 30
awslocal s3 mb s3://test-migration
awslocal s3 ls
localstack stop
# Result: No authentication errors ✅
3. Sample Testing
# Test terraform sample
cd terraform-resources
export LOCALSTACK_AUTH_TOKEN=<auth-token>
make start && make ready && make run && make stop
# Result: Sample completed successfully ✅
# Test serverless sample
cd serverless-lambda-layers
make test-ci
# Result: Lambda deployment and invocation successful ✅
4. Docker Compose Testing
# Test docker-compose integration
cd java-notification-app
export LOCALSTACK_AUTH_TOKEN=<auth-token>
docker-compose up -d
docker-compose logs localstack | grep -i error
# Result: No authentication errors in logs ✅
5. CI Workflow Validation
- Verified GitHub workflow uses
LOCALSTACK_AUTH_TOKEN: ${{ secrets.TEST_LOCALSTACK_AUTH_TOKEN }} - Confirmed secret name change from
TEST_LOCALSTACK_API_KEYtoTEST_LOCALSTACK_AUTH_TOKEN
Impact
- ✅ All sample tests will continue to work with LocalStack Pro
- ✅ No breaking changes for users (they just need to use the new environment variable)
- ✅ Consistent authentication mechanism across all samples