Skip to content

Instantly share code, notes, and snippets.

Avatar

Radu Dita hades2510

View GitHub Profile
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
@hades2510
hades2510 / gist:1c5d3ef078eb1e2076121f35b942691c
Created Apr 5, 2020
IAM Policy Lambda SQS Triggered to start an ECS Task
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"
}
@hades2510
hades2510 / gist:ce0ecaa2b27a0711daffe630285e07d3
Created Apr 5, 2020
S3 Policy for S3 bucket, get, put and list a bucket
View gist:ce0ecaa2b27a0711daffe630285e07d3
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "S1",
"Effect": "Allow",
"Action": [
"s3:PutObject",
"s3:GetObject",
],
@hades2510
hades2510 / push_docker_image_to_ecr.sh
Created Apr 5, 2020
Helper script for pushing a Docker image to ECR
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 {
@hades2510
hades2510 / Dokerfile
Created Apr 5, 2020
Docker file for running a small node.js app
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,
You can’t perform that action at this time.