diff --git a/stateless-mcp-on-lambda-python/README.md b/stateless-mcp-on-lambda-python/README.md index e9c34cf..9ef9a96 100644 --- a/stateless-mcp-on-lambda-python/README.md +++ b/stateless-mcp-on-lambda-python/README.md @@ -47,7 +47,6 @@ Before deploying, you need to configure the environment variables in `etc/enviro ```bash make layer ``` - After execution, copy the `outLayer` value and update the `O_LAYER_ARN` in `etc/environment.sh`. 2. Deploy the API Gateway and Lambda function: ```bash diff --git a/stateless-mcp-on-lambda-python/etc/environment.sh b/stateless-mcp-on-lambda-python/etc/environment.sh index 48c4808..442a8ac 100644 --- a/stateless-mcp-on-lambda-python/etc/environment.sh +++ b/stateless-mcp-on-lambda-python/etc/environment.sh @@ -9,7 +9,7 @@ LAYER_STACK=samples-mcp-lambda-layer LAYER_TEMPLATE=sam/layer.yaml LAYER_OUTPUT=sam/layer_output.yaml LAYER_PARAMS="ParameterKey=description,ParameterValue=${P_DESCRIPTION}" -O_LAYER_ARN=your-output-layer-arn +O_LAYER_ARN=will be populated by the script # api gateway and lambdastack P_API_STAGE=dev diff --git a/stateless-mcp-on-lambda-python/makefile b/stateless-mcp-on-lambda-python/makefile index 75caa86..d756132 100644 --- a/stateless-mcp-on-lambda-python/makefile +++ b/stateless-mcp-on-lambda-python/makefile @@ -1,19 +1,28 @@ include etc/environment.sh # dependencies -layer: layer.build layer.package layer.deploy +layer: layer.build layer.package layer.deploy layer.get-arn layer.build: - sam build -t ${LAYER_TEMPLATE} --parameter-overrides ${LAYER_PARAMS} --build-dir build --manifest src/dependencies/requirements.txt --use-container + sam build -t ${LAYER_TEMPLATE} --parameter-overrides ${LAYER_PARAMS} --build-dir build --manifest src/dependencies/requirements.txt --use-container --region ${REGION} --profile ${PROFILE} layer.package: - sam package -t build/template.yaml --region ${REGION} --output-template-file ${LAYER_OUTPUT} --s3-bucket ${BUCKET} --s3-prefix ${LAYER_STACK} + sam package -t build/template.yaml --region ${REGION} --output-template-file ${LAYER_OUTPUT} --s3-bucket ${BUCKET} --s3-prefix ${LAYER_STACK} --profile ${PROFILE} layer.deploy: - sam deploy -t ${LAYER_OUTPUT} --region ${REGION} --stack-name ${LAYER_STACK} --parameter-overrides ${LAYER_PARAMS} --capabilities CAPABILITY_NAMED_IAM + sam deploy -t ${LAYER_OUTPUT} --region ${REGION} --stack-name ${LAYER_STACK} --parameter-overrides ${LAYER_PARAMS} --profile ${PROFILE} +layer.get-arn: + @echo "Getting layer ARN and updating environment.sh..." + $(eval LAYER_ARN := $(shell aws cloudformation describe-stacks --stack-name ${LAYER_STACK} --region ${REGION} --profile ${PROFILE} --query 'Stacks[0].Outputs[?OutputKey==`outLayer`].OutputValue' --output text)) + @sed -i 's|^O_LAYER_ARN=.*|O_LAYER_ARN=${LAYER_ARN}|' etc/environment.sh + @echo "Updated O_LAYER_ARN to: ${LAYER_ARN}" # api gateway apigw: apigw.package apigw.deploy apigw.package: - sam package -t ${APIGW_TEMPLATE} --output-template-file ${APIGW_OUTPUT} --s3-bucket ${BUCKET} --s3-prefix ${APIGW_STACK} + sam package -t ${APIGW_TEMPLATE} --output-template-file ${APIGW_OUTPUT} --s3-bucket ${BUCKET} --s3-prefix ${APIGW_STACK} --region ${REGION} --profile ${PROFILE} apigw.deploy: - sam deploy -t ${APIGW_OUTPUT} --region ${REGION} --stack-name ${APIGW_STACK} --parameter-overrides ${APIGW_PARAMS} --capabilities CAPABILITY_NAMED_IAM + sam deploy -t ${APIGW_OUTPUT} --region ${REGION} --stack-name ${APIGW_STACK} --parameter-overrides ${APIGW_PARAMS} --profile ${PROFILE} apigw.delete: - sam delete --stack-name ${APIGW_STACK} + sam delete --stack-name ${APIGW_STACK} --region ${REGION} --profile ${PROFILE} + +delete: + sam delete --stack-name ${APIGW_STACK} --region ${REGION} --profile ${PROFILE} + sam delete --stack-name ${LAYER_STACK} --region ${REGION} --profile ${PROFILE}