Because of this issue aws/containers-roadmap#1565 lambda is updated to monitor stoppedReason as well as stopCode might not come.
Terraform scripts for deploying lambda for de-registering load balancer targets on FargateSpot interruption.
- lambda function code that is used here is written by @jicowan on issue: aws/containers-roadmap#797 Lambda for de-registering tasks: https://gist.github.com/jicowan/ad5e13d12577b41a22f83ed91a3e61bf
- EventBridge rule is created based on: https://docs.aws.amazon.com/AmazonECS/latest/developerguide/fargate-capacity-providers.html#fargate-capacity-providers-termination
I also added deadletter SQS queue for failed lambda executions.
All commands are defined in MakeFile
.
You do not need to have installed go
or terraform
environments on your computer.
All commands are executed in inside docker image which needs to be build at the beginning.
At the very beginning we need to build image which will be used laetr for other commands.
Command: make build
will build local git-josip/aws-lambda-deregister-targets-fargate-spot
image. In that image we initialize terraform with our terraform configuration.
Check DOckerFile
for details.
To compile your source code, run make compile
.
With this command executes go build
command in docker Go env.
After this command we have new build/
folder created containing compiled program.
All terrafrom tasks are depending on this one so we do not execute it when runnign plan
or apply
plan
, apply
and destroy
are supported terraform commands.
WIth plan
we will just get output what resources will be created.
In order to run these commands we need to pass AWS acces,secret and region params to make.
make awsDefaultRegion=eu-central-1 awsAccessKey=accessxxx awsSecretKey=secretxxx plan
make awsDefaultRegion=eu-central-1 awsAccessKey=accessxxx awsSecretKey=secretxxx apply
make awsDefaultRegion=eu-central-1 awsAccessKey=accessxxx awsSecretKey=secretxxx destroy