Use three different methods via the CLI to create and invoke a Lambda. Create node and python lambda from simple make targets.
makefile
uses these three different ways to configure the AWS CLI. Uncomment the one you want to use.
#AWS_CLI=AWS_PROFILE=localstack aws
#AWS_CLI=AWS_ACCESS_KEY_ID=test AWS_SECRET_ACCESS_KEY=test aws --endpoint-url http://localhost:4566 --region us-east-1
#AWS_CLI=awslocal
After you've cloned this repo.
You can either use a LocalStack AWS_PROFILE for credentials, or use awslocal
. Setup options are directly below.
- Setup an AWS_PROFILE for LocalStack
[profile localstack]
region=us-east-1
output=json
endpoint_url = http://localhost:4566
[localstack]
aws_access_key_id=test
aws_secret_access_key=test
-
Create a Python venv and activate it
make setup-venv source venv/bin/activate
-
Change makefile to point at awslocal
#AWS_CLI=AWS_PROFILE=localstack aws
#AWS_CLI=AWS_ACCESS_KEY_ID=test AWS_SECRET_ACCESS_KEY=test aws --endpoint-url http://localhost:4566 --region us-east-1
AWS_CLI=awslocal
Change makefile to point at aws CLI. Must be AWS CLI v2.
#AWS_CLI=AWS_PROFILE=localstack aws
AWS_CLI=AWS_ACCESS_KEY_ID=test AWS_SECRET_ACCESS_KEY=test aws --endpoint-url http://localhost:4566 --region us-east-1
#AWS_CLI=awslocal
You can use LocalStack Pro, just see the commented out line in docker-compose.yml
.
docker compose up
- Build python function zip
make bundle-py
- Deploy function
make create-py-function
- Invoke function
make local-py-invoke
- See results
cat output.txt
- Build python function zip
make bundle
- Deploy function
make create-function
- Invoke function
make local-invoke
- See results
cat output.txt