Skip to content

Instantly share code, notes, and snippets.

@yeisoncruz16
Created September 18, 2021 02:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yeisoncruz16/b55137cc07119e9c8d547405761e65a8 to your computer and use it in GitHub Desktop.
Save yeisoncruz16/b55137cc07119e9c8d547405761e65a8 to your computer and use it in GitHub Desktop.
Trigger lambda function using AWS Elastic load balance
service: sample-lambda-alb
provider:
name: aws
runtime: nodejs14.x
stage: ${opt:stage, 'dev'}
region: ${opt:region, 'us-west-2'}
profile: crazy
alb:
targetGroupPrefix: tg-${opt:stage, 'dev'}- # this is the name for the target group
custom:
alb: # If you are using the same ALB ARN you must set uniq priority
priority:
prod: 1
dev: 2
functions:
validate-user:
description: "Example lambda using elastic load balance"
handler: handler.producer
name: sample-lambda-alb-${opt:stage, 'dev'}
timeout: 900 # This is set to 15min
memorySize: 128
events:
- alb:
listenerArn: ALB_LISTENER_ARN
priority: ${self:custom.alb.priority.${opt:stage, self:provider.stage}}
method: GET
conditions:
path: /validate-user/${opt:stage, 'dev'} # enable both url /validate-user/dev and /validate-user/dev
@yeisoncruz16
Copy link
Author

yeisoncruz16 commented Sep 18, 2021

You will need to create an ALB type application and also create a listener without target, after that just copy the ARN and replace ir for ALB_LISTENER_ARN

WhatsApp Image 2021-09-17 at 9 37 22 PM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment