feat: add AWS deployment configuration and scripts

This commit is contained in:
Ardeman 2025-04-16 08:23:05 +08:00
parent 98b871a5ed
commit 4b02988145
4 changed files with 101 additions and 0 deletions

35
.github/workflows/deploy.yml vendored Normal file
View File

@ -0,0 +1,35 @@
name: Deploy to AWS Lambda via SAM
on:
push:
branches: [main]
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.24' # adjust to your Go version
- name: Set up AWS SAM CLI
uses: aws-actions/setup-sam@v2
- name: Build with SAM
run: sam build
- name: Configure AWS credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
aws-region: ${{ secrets.AWS_REGION }}
- name: Deploy with SAM
run: |
sam deploy --no-confirm-changeset --no-fail-on-empty-changeset --stack-name legalgo-stack --capabilities CAPABILITY_IAM --region ${{ secrets.AWS_REGION }}

3
deploy.sh Executable file
View File

@ -0,0 +1,3 @@
#!/bin/bash
sam build
sam deploy --guided

41
env/production.yaml vendored Normal file
View File

@ -0,0 +1,41 @@
server:
base-url: https://api.legalgo.id/core
local-url: http://localhost:3300
port: 3300
jwt:
token:
expires-ttl: 1440
secret: "5Lm25V3Qd7aut8dr4QUxm5PZUrSFs"
postgresql:
host: legalgodb.ctuok62cmn6i.ap-southeast-1.rds.amazonaws.com
port: 5432
driver: postgres
db: legalgonews
username: legalgo_admin
password: "K4K!2Kg7cKW6H&4A2aBy2dFCRY3Sh"
ssl-mode: disable
max-idle-connections-in-second: 600
max-open-connections-in-second: 600
connection-max-life-time-in-second: 600
debug: false
oss:
access_key_id: cf9a475e18bc7626cbdbf09709d82a64
access_key_secret: 91f3321294d3e23035427a0ecb893ada
endpoint: sin1.contabostorage.com
bucket_name: legalgonews-dev
log_level: Error
host_url: https://sin1.contabostorage.com
public_url: https://sin1.contabostorage.com/fda98c2228f246f29a7e466b86b3b9e7
redis:
host: legalgocache-qn8fuh.serverless.apse1.cache.amazonaws.com
port: 6379
db: 5
ssl: false
max-idle-connections-in-second: 600
max-open-connections-in-second: 600
connection-max-life-time-in-second: 600
debug: false

22
template.yml Normal file
View File

@ -0,0 +1,22 @@
AWSTemplateFormatVersion: '2010-09-09'
Transform: AWS::Serverless-2016-10-31
Description: Go Lambda API deployed with AWS SAM
Globals:
Function:
Timeout: 10
Resources:
ApiFunction:
Type: AWS::Serverless::Function
Properties:
FunctionName: legalgo-api
Handler: main
Runtime: go1.x
CodeUri: .
Events:
Api:
Type: Api
Properties:
Path: /
Method: ANY