dev, readme,deploy

This commit is contained in:
2025-02-20 19:10:13 -06:00
parent 7328d68702
commit a62a66b829
3 changed files with 22 additions and 27 deletions

6
DEV.md Normal file
View File

@@ -0,0 +1,6 @@
## Deploy lambda function
If you want to deploy your own changes directly to lambda you can use [deploy.sh](./deploy.sh) to package and deploy it for you. Tested on linux.
Requirements:
- aws cli installed and configured (instructions in [README.md](./README.md))
- python3.12 and pip installed

View File

@@ -37,7 +37,11 @@ There are several ways of creating credentials to deploy this in AWS. Ideally yo
### Configure CLI
Now that you have aws cli installed and credentials ready its time for the last step of the requirements -> configuring the aws cli to work with your account.
Open terminal in your OS and type `aws configure` and press enter. Now copy/paste the api key and secret that you got in the previous step. You will also have to chose a default region where you want to deploy your api. You can see the list of all regions [here](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-regions-availability-zones.html). You should pick the region that is closest to your business. For quick reference US (us-east-1,us-west-1), Europe (eu-central-1,eu-west-1), Latam (sa-east-1), Asia (ap-southeast-1).
You will also have to chose a default region where you want to deploy your api. You can see the list of all regions [here](https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/using-regions-availability-zones.html). You should pick the region that is closest to your business. For quick reference US (us-east-1,us-west-1), Europe (eu-central-1,eu-west-1), Latam (sa-east-1), Asia (ap-southeast-1).
Once you have api key, api secret and you've chosen the region you want to deploy to you're ready to configure the cli.
Open terminal in your OS and type `aws configure` and press enter. Now copy/paste the api key, press enter, and copy/paste the secret and press enter do the same for region. You can leave the default output format blank..
```
# aws configure
@@ -108,6 +112,7 @@ root@2edec8635e65:/# aws cloudformation describe-stacks --stack-name breez-i
}
]
If the deploy was successful you should deactivate your api key now.
```
### Example usage
#### Python

View File

@@ -1,12 +1,8 @@
#!/bin/bash
# Variables
FUNCTION_NAME="nodeless-payments"
ROLE_ARN="arn:aws:iam::<ARN>:role/lambda-breez-role"
REGION="<region>"
HANDLER="lambda_function.lambda_handler"
RUNTIME="python3.12"
ZIP_FILE="lambda_package.zip"
FUNCTION_NAME="BreezLambda" # Match the FunctionName in CloudFormation
ZIP_FILE="lambda.zip"
# Install dependencies
echo "Installing dependencies..."
@@ -20,27 +16,15 @@ cd package
zip -r ../$ZIP_FILE .
cd ..
# Check if function exists
EXISTS=$(aws lambda get-function --function-name $FUNCTION_NAME --region $REGION --query 'Configuration.FunctionArn' --output text 2>/dev/null)
# Update Lambda function code directly
echo "Updating Lambda function code..."
aws lambda update-function-code \
--function-name $FUNCTION_NAME \
--zip-file fileb://$ZIP_FILE
if [ -z "$EXISTS" ]; then
echo "Creating new Lambda function..."
aws lambda create-function \
--function-name $FUNCTION_NAME \
--runtime $RUNTIME \
--role $ROLE_ARN \
--handler $HANDLER \
--timeout 30 \
--memory-size 256 \
--region $REGION \
--zip-file fileb://$ZIP_FILE
else
echo "Updating existing Lambda function..."
aws lambda update-function-code \
--function-name $FUNCTION_NAME \
--region $REGION \
--zip-file fileb://$ZIP_FILE
fi
# Clean up
rm -rf package
rm $ZIP_FILE
echo "Deployment complete!"