Add hello lambda CFT and Forgejo workflow
Some checks failed
Deploy Hello Lambda CFT / deploy (push) Failing after 8s
Some checks failed
Deploy Hello Lambda CFT / deploy (push) Failing after 8s
This commit is contained in:
commit
11a6fe0130
3 changed files with 90 additions and 0 deletions
50
.forgejo/workflows/deploy-cfn.yml
Normal file
50
.forgejo/workflows/deploy-cfn.yml
Normal file
|
|
@ -0,0 +1,50 @@
|
||||||
|
name: Deploy Hello Lambda CFT
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
|
push:
|
||||||
|
branches: [ main ]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
deploy:
|
||||||
|
runs-on: nas-safe
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Ensure AWS CLI
|
||||||
|
run: |
|
||||||
|
if ! command -v aws >/dev/null 2>&1; then
|
||||||
|
if command -v apk >/dev/null 2>&1; then
|
||||||
|
apk add --no-cache aws-cli
|
||||||
|
elif command -v apt-get >/dev/null 2>&1; then
|
||||||
|
apt-get update && apt-get install -y awscli
|
||||||
|
else
|
||||||
|
echo "No supported package manager found for awscli install"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
aws --version
|
||||||
|
|
||||||
|
- name: Verify AWS identity
|
||||||
|
env:
|
||||||
|
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
|
||||||
|
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
|
||||||
|
AWS_DEFAULT_REGION: ${{ secrets.AWS_REGION }}
|
||||||
|
run: aws sts get-caller-identity
|
||||||
|
|
||||||
|
- name: Validate CFT
|
||||||
|
env:
|
||||||
|
AWS_DEFAULT_REGION: ${{ secrets.AWS_REGION }}
|
||||||
|
run: |
|
||||||
|
aws cloudformation validate-template \
|
||||||
|
--template-body file://infra/hello-lambda.yml
|
||||||
|
|
||||||
|
- name: Deploy CFT
|
||||||
|
env:
|
||||||
|
AWS_DEFAULT_REGION: ${{ secrets.AWS_REGION }}
|
||||||
|
run: |
|
||||||
|
aws cloudformation deploy \
|
||||||
|
--stack-name hello-lambda-stack \
|
||||||
|
--template-file infra/hello-lambda.yml \
|
||||||
|
--capabilities CAPABILITY_NAMED_IAM
|
||||||
3
README.md
Normal file
3
README.md
Normal file
|
|
@ -0,0 +1,3 @@
|
||||||
|
# Hello World Lambda via CloudFormation
|
||||||
|
|
||||||
|
This repo deploys a simple Lambda using Forgejo Actions.
|
||||||
37
infra/hello-lambda.yml
Normal file
37
infra/hello-lambda.yml
Normal file
|
|
@ -0,0 +1,37 @@
|
||||||
|
AWSTemplateFormatVersion: '2010-09-09'
|
||||||
|
Description: Hello World Lambda via CloudFormation
|
||||||
|
|
||||||
|
Resources:
|
||||||
|
HelloLambdaRole:
|
||||||
|
Type: AWS::IAM::Role
|
||||||
|
Properties:
|
||||||
|
RoleName: hello-world-lambda-role-cft
|
||||||
|
AssumeRolePolicyDocument:
|
||||||
|
Version: '2012-10-17'
|
||||||
|
Statement:
|
||||||
|
- Effect: Allow
|
||||||
|
Principal:
|
||||||
|
Service: lambda.amazonaws.com
|
||||||
|
Action: sts:AssumeRole
|
||||||
|
ManagedPolicyArns:
|
||||||
|
- arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole
|
||||||
|
|
||||||
|
HelloLambdaFunction:
|
||||||
|
Type: AWS::Lambda::Function
|
||||||
|
Properties:
|
||||||
|
FunctionName: hello-world-lambda-cft
|
||||||
|
Runtime: python3.12
|
||||||
|
Handler: index.lambda_handler
|
||||||
|
Role: !GetAtt HelloLambdaRole.Arn
|
||||||
|
Timeout: 10
|
||||||
|
Code:
|
||||||
|
ZipFile: |
|
||||||
|
def lambda_handler(event, context):
|
||||||
|
return {
|
||||||
|
"statusCode": 200,
|
||||||
|
"body": "Hello from Lambda via CloudFormation!"
|
||||||
|
}
|
||||||
|
|
||||||
|
Outputs:
|
||||||
|
LambdaName:
|
||||||
|
Value: !Ref HelloLambdaFunction
|
||||||
Loading…
Add table
Reference in a new issue