Skip to content

Instantly share code, notes, and snippets.

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,
@hades2510
hades2510 / Dokerfile
Created April 5, 2020 09:59
Docker file for running a small node.js app
FROM node:12.16.1-alpine3.9
WORKDIR /app
COPY app/* /app/
RUN npm install
CMD node archive.js
@hades2510
hades2510 / push_docker_image_to_ecr.sh
Created April 5, 2020 10:26
Helper script for pushing a Docker image to ECR
#!/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 / gist:ce0ecaa2b27a0711daffe630285e07d3
Created April 5, 2020 12:10
S3 Policy for S3 bucket, get, put and list a bucket
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "S1",
"Effect": "Allow",
"Action": [
"s3:PutObject",
"s3:GetObject",
],
{
"bucket": "your-bucket",
"key": "prefix",
"destination": "path-to-arhive",
"exluce": "regexp for excluding paths"
}
@hades2510
hades2510 / gist:1c5d3ef078eb1e2076121f35b942691c
Created April 5, 2020 13:22
IAM Policy Lambda SQS Triggered to start an ECS Task
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "S1",
"Effect": "Allow",
"Action": "iam:PassRole",
"Resource": "arn:aws:iam::aws-acount-id:role/ecs-task-role"
},
{
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
type Zero = {
__type: 'zero',
}
type One = {
__type: 'one'
}
type Bit = Zero | One;
type BitNot<T extends Bit> = T extends Zero ? One : Zero;
type BitAnd<LHS extends Bit, RHS extends Bit> = LHS extends One
? RHS extends One
? One
: Zero
: Zero;
type BitOr<LHS extends Bit, RHS extends Bit> = LHS extends Zero
? RHS extends Zero
? Zero
: One
type ShiftLeft<T extends Byte> = T extends [
infer U extends Bit,
...infer R extends Bit[]
]
? [...R, Zero]
: never;
type ShiftRight<T extends Byte> = T extends [
...infer U extends Bit[],
infer R extends Bit
]