Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/k8s-crafts/lambda-auto-deployer
Automate lambda rollout on AWS ECR image push with AWS EventBrigde.
https://github.com/k8s-crafts/lambda-auto-deployer
aws-eventbridge aws-lambda aws-sdk-go-v2 golang
Last synced: 9 days ago
JSON representation
Automate lambda rollout on AWS ECR image push with AWS EventBrigde.
- Host: GitHub
- URL: https://github.com/k8s-crafts/lambda-auto-deployer
- Owner: k8s-crafts
- License: gpl-3.0
- Created: 2024-02-27T00:13:24.000Z (10 months ago)
- Default Branch: main
- Last Pushed: 2024-10-08T18:00:59.000Z (3 months ago)
- Last Synced: 2024-10-29T22:48:53.779Z (about 2 months ago)
- Topics: aws-eventbridge, aws-lambda, aws-sdk-go-v2, golang
- Language: Go
- Homepage:
- Size: 85.9 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## Lambda Auto Deployer
The project delivers an AWS Lambda that is triggered on ECR Push events from AWS EventBridge. This aims to simplify the rollout process of AWS lambdas in deployment environments.
## Configurations
### IAM Roles
This lambda requires permssions to `update-function-code` for other lambdas. Thus, besides basic execution role generated for the lambda, it requires additional policy that allows `lambda:UpdateFunctionCode`, for example:
```json
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "VisualEditor0",
"Effect": "Allow",
"Action": "lambda:UpdateFunctionCode",
"Resource": "*"
}
]
}
```### Environment variables
|VARIABLE|DESCRIPTION|
|:--|:--|
|`LAMBDA_NAMES`|A comma-separated list of targeted lambda names. For examples, `LAMBDA_NAMES=my-lambda,lambda-1`.|
|`LAMBDA_IMAGE_REPOS`|A comma-separated list of lambda image repositories. The order must match that of `LAMBDA_NAMES`, where each repository will correspond to each lambda name in the same list position. For examples, `LAMBDA_IMAGE_REPOS=my-lambda-repo,lambda-1-repo`.|
|`LAMBDA_IMAGE_TAGS`|A comma-separated list of lambda image tags that the should trigger the new deployment of the targeted lambdas. For examples, `LAMBDA_IMAGE_TAGS=0.1.0-dev,dev,0.1.0-snapshot`.|### AWS Amazon EventBridge
On an event bus, for example, `default`, create an event rule that has a pattern, matching ECR Image Action events. For example:
```json
{
"source": ["aws.ecr"],
"detail-type": ["ECR Image Action"],
"detail": {
"action-type": ["PUSH"],
"result": ["SUCCESS"],
"repository-name": ["my-lambda", "another-lambda"]
}
}
```Then, set the event rule's target to the handling lambda (i.e. this auto deployer lambda).
### Trigger
Add a lambda trigger configurations to listen to EventBridge (CloudWatch Events) and select the above event rule:
![trigger-configuration](./images/trigger-config.png)