This repository contains the infrastructure and deployment pipeline for a Golang API. The API is deployed to AWS Lambda and made accessible through a custom domain using API Gateway and Route 53. The project uses CloudFormation for infrastructure management and GitHub Actions for CI/CD.
- Golang API: Uses the Gin framework for the API implementation.
- AWS Lambda: Serverless deployment for scalability and cost efficiency.
- API Gateway: Acts as a gateway for the Lambda function.
- Route 53: Custom domain configuration for the API endpoint.
- CloudFormation: Infrastructure as code for AWS resources.
- GitHub Actions: CI/CD pipeline for automated deployment.
- Lambda Function: Hosts the Golang API logic.
- API Gateway: Maps API routes to the Lambda function.
- Custom Domain: Configured in API Gateway and linked to Route 53.
- Route 53: Provides DNS resolution for the custom domain.
- GitHub Actions: Automates deployment using CloudFormation.
- Golang: Install Go.
- AWS CLI: Configure AWS CLI with your credentials.
- GitHub Secrets: Store sensitive information (e.g., AWS keys, domain details).
- S3 Bucket: Pre-created bucket for Lambda deployment packages.
- API Gateway
- Lambda
- Route 53
- CloudFormation
- IAM
Add the following secrets to your repository:
- AWS_ACCESS_KEY_ID
- AWS_SECRET_ACCESS_KEY
- S3_BUCKET_NAME
- CUSTOM_DOMAIN (e.g., api.yourdomain.com)
- HOSTED_ZONE_ID
- CERTIFICATE_ARN
Push your changes to the main branch to trigger the GitHub Actions pipeline:
git add .
git commit -m "Deploy API"
git push origin mainOnce deployed, access the API at:
https://api.yourdomain.com/hello{
"message": "Hello from AWS Lambda!"
}Install dependencies:
go mod tidyRun the API locally:
go run main.goAccess the API at http://localhost:8080/hello.
Prepare the binary for Lambda:
GOOS=linux GOARCH=amd64 go build -o main
zip deployment.zip main