View LambdaStartECS.js
const AWS = require('aws-sdk') | |
var ecs = new AWS.ECS(); | |
exports.handler = async (event, context) => { | |
const record = event.Records[0] | |
const receiptHandle = record.receiptHandle | |
const sqsARN = record.eventSourceARN | |
let message = null |
View gist:1c5d3ef078eb1e2076121f35b942691c
{ | |
"Version": "2012-10-17", | |
"Statement": [ | |
{ | |
"Sid": "S1", | |
"Effect": "Allow", | |
"Action": "iam:PassRole", | |
"Resource": "arn:aws:iam::aws-acount-id:role/ecs-task-role" | |
}, | |
{ |
View sqsSampleMessage.json
{ | |
"bucket": "your-bucket", | |
"key": "prefix", | |
"destination": "path-to-arhive", | |
"exluce": "regexp for excluding paths" | |
} |
View gist:ce0ecaa2b27a0711daffe630285e07d3
{ | |
"Version": "2012-10-17", | |
"Statement": [ | |
{ | |
"Sid": "S1", | |
"Effect": "Allow", | |
"Action": [ | |
"s3:PutObject", | |
"s3:GetObject", | |
], |
View push_docker_image_to_ecr.sh
#!/bin/bash | |
function push_it { | |
docker tag $DOCKER_IMAGE_TAG $AWS_ACCOUNT_ID.dkr.ecr.$AWS_REGION.amazonaws.com/$AWS_ECR_NAME | |
docker push $AWS_ACCOUNT_ID.dkr.ecr.$AWS_REGION.amazonaws.com/$AWS_ECR_NAME | |
} | |
function usage { |
View Dokerfile
FROM node:12.16.1-alpine3.9 | |
WORKDIR /app | |
COPY app/* /app/ | |
RUN npm install | |
CMD node archive.js |
View archive.js
const Archiver = require('archiver') | |
const Stream = require('stream') | |
const AWS = require("aws-sdk"); | |
const s3 = new AWS.S3( { apiVersion: '2006-03-01'} ); | |
const archiveFolder = async (data) => { | |
//get list of items | |
const s3Files = await s3.listObjectsV2({ | |
Bucket: data.bucket, |