This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env node | |
const path = require('path'); | |
const https = require('https'); | |
const AWS = require('aws-sdk'); | |
const promisePipe = require('promisepipe'); | |
const unzip = require('unzipper'); | |
const runner = async () => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const runParams = { | |
taskDefinition: RUNNER, | |
launchType: "FARGATE", | |
networkConfiguration: { | |
awsvpcConfiguration: { | |
assignPublicIp: "ENABLED", | |
subnets: [SUBNET] | |
} | |
}, | |
overrides: { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const runParams = { | |
taskDefinition: RUNNER, | |
launchType: "FARGATE", | |
networkConfiguration: { | |
awsvpcConfiguration: { | |
assignPublicIp: "ENABLED", | |
subnets: [SUBNET] | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env node | |
const path = require('path'); | |
const https = require('https'); | |
const AWS = require('aws-sdk'); | |
const promisePipe = require('promisepipe'); | |
const unzip = require('unzip'); | |
const { argv } = require('yargs'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import AWS from 'aws-sdk'; | |
export const handler = async (event, context, callback) => { | |
// Coming from environment variables setup in your `serverless.yaml` file | |
// See https://serverless.com/framework/docs/providers/aws/guide/variables/#referencing-environment-variables | |
const { RUNNER, SUBNET } = process.env; | |
const ecs = new AWS.ECS(); | |
// Some other logic specific to your case here ... |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM node:8 | |
# Environment variables acting as parameters of the runner. | |
ENV AWS_LAMBDA_FUNCTION_EVENT {} | |
ENV AWS_LAMBDA_FUNCTION_CONTEXT {} | |
# Create app directory | |
WORKDIR /usr/src/app | |
COPY . . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
iamRoleStatements: | |
... | |
# Allow running AWS Fargate containers when AWS Lambda timeout cannot be bypassed. | |
- Effect: 'Allow' | |
Action: | |
- ecs:RunTask | |
Resource: '*' | |
- Effect: Allow | |
Action: | |
- iam:PassRole |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SQSFailureQueue: | |
Type: AWS::SQS::Queue | |
Properties: | |
QueueName: sqs-failure-queue | |
MessageRetentionPeriod: '1209600' | |
VisibilityTimeout: '60' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
functions: | |
primaryHandler: | |
handler: path/to/immortal-handler.handler | |
name: immortal-handler | |
deadLetter: | |
targetArn: | |
GetResourceArn: SQSFailureQueue |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
secondaryHandler: | |
handler: path/to/immortal-handlerDlq.handler | |
name: immortal-handlerDql | |
environment: | |
REGION: eu-west-1 | |
# ECS task to execute handler without timeout limitations | |
RUNNER: runner | |
# Required for runTask API call, preliminary created on AWS. | |
SUBNET: subnet-xxxxxxxx | |
... |