This commit is contained in:
2025-04-29 21:13:21 +02:00
parent 84b1aa00d4
commit 444fc0614c
25 changed files with 877 additions and 150 deletions

6
lambda/dev/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

@@ -0,0 +1,28 @@
### Code deployment
New code is automatically packaged and deployed to Breez's S3 bucket for public consumption.
### Create S3 bucket
```
aws s3api create-bucket --bucket breez-nodeless-payment --acl public-read
aws s3api delete-public-access-block --bucket breez-nodeless-payment
aws s3api put-bucket-policy --bucket breez-nodeless-payment --policy '{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "PublicReadGetObject",
"Effect": "Allow",
"Principal": "*",
"Action": "s3:GetObject",
"Resource": "arn:aws:s3:::breez-nodeless-payment/*"
}
]
}'
```
### Create user for github actions upload
```
aws iam create-user --user-name github-actions-user
aws iam put-user-policy --user-name github-actions-user --policy-name S3UploadPolicy --policy-document file://github-actions-policy.json
aws iam create-access-key --user-name github-actions-user
```

30
lambda/dev/deploy.sh Normal file
View File

@@ -0,0 +1,30 @@
#!/bin/bash
# Variables
FUNCTION_NAME="BreezLambda" # Match the FunctionName in CloudFormation
ZIP_FILE="lambda.zip"
# Install dependencies
echo "Installing dependencies..."
mkdir -p package
pip install -r requirements.txt -t package/
# Package the function
echo "Packaging the function..."
cp lambda_function.py package/
cd package
zip -r ../$ZIP_FILE .
cd ..
# Update Lambda function code directly
echo "Updating Lambda function code..."
aws lambda update-function-code \
--function-name $FUNCTION_NAME \
--zip-file fileb://$ZIP_FILE
# Clean up
rm -rf package
rm $ZIP_FILE
echo "Deployment complete!"

View File

@@ -0,0 +1,20 @@
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "AllowS3Upload",
"Effect": "Allow",
"Action": [
"s3:PutObject",
"s3:PutObjectAcl"
],
"Resource": "arn:aws:s3:::breez-nodeless-payment/*"
},
{
"Sid": "AllowListBucket",
"Effect": "Allow",
"Action": "s3:ListBucket",
"Resource": "arn:aws:s3:::breez-nodeless-payment"
}
]
}