Skip to content

Instantly share code, notes, and snippets.

View dhavaln's full-sized avatar
💭
I may be slow to respond.

Dhaval Nagar dhavaln

💭
I may be slow to respond.
View GitHub Profile
@dhavaln
dhavaln / check-whitelist-domain.js
Created December 29, 2020 06:53
Check for Domains and Emails before Cognito Signup
const whitelistedDomains = process.env.WHITE_LISTED_DOMAINS.split(',');
const whitelistedEmails = process.env.WHITE_LISTED_EMAIL.split(',');
exports.handler = async (event, context, callback) => {
console.log('Validate signup request', event);
console.log('wd', whitelistedDomains)
console.log('we', whitelistedEmails)
// Split the email address so we can compare domains
const userEmail = event.request.userAttributes.email;
@dhavaln
dhavaln / s3-folder-access.yml
Last active December 29, 2020 06:38
S3 Access Auth Role
- PolicyName: !Join ["-", [ "CognitoIDP", { Ref: AWS::StackName }, "S3-Access", "Policy"]]
PolicyDocument:
Version: "2012-10-17"
Statement:
- Sid: "AllowListingPublicFiles"
Effect: Allow
Action: "s3:ListBucket"
Condition:
StringLike:
"s3:prefix":
@dhavaln
dhavaln / README.md
Created October 16, 2019 10:25
Docker for Mac Volumes

Only for Docker for Mac

Screen into the Docker Desktop

screen /Users/dhavalnagar/Library/Containers/com.docker.docker/Data/vms/0/tty

List the Volumes Directory

ls /var/lib/docker/volumes/

@dhavaln
dhavaln / Dockerfile
Created October 13, 2019 10:45
Simple NodeJS Multistage Build
FROM node:10 as build
MAINTAINER dhavaln
LABEL description="This is a multi-stage NodeJS image"
WORKDIR /src
COPY package*.json .
RUN npm install
COPY . .
FROM node:10-slim
WORKDIR /src
@dhavaln
dhavaln / Dockerfile
Created October 11, 2019 11:20
hello-app source for CodeCommit and CodeBuild
FROM alpine
MAINTAINER dhavaln
LABEL description="Part 1 - Running Docker on AWS EC2"
WORKDIR /src
RUN echo "Hello world" > hello.txt
CMD ["cat", "hello.txt"]
@dhavaln
dhavaln / install_docker_ec2.sh
Last active October 3, 2023 13:52
Install Docker on EC2
#! /bin/sh
yum update -y
amazon-linux-extras install docker
service docker start
usermod -a -G docker ec2-user
chkconfig docker on
@dhavaln
dhavaln / simple.txt
Created October 2, 2019 07:26
Docker Inline Demo
# Demo1: This is an inline build
docker build -t inlineimage -f- . <<EOF
FROM node:10
MAINTAINER dhavaln
WORKDIR /usr/src
RUN echo "console.log('hello world');" > index.js
CMD ["node", "index.js"]
<<EOF
@dhavaln
dhavaln / README.md
Last active August 22, 2019 06:37
Compute calls from Cloud Function

Test Values

Make sure you change the project and firewall resource Ids of your environment.

Local Testing

gcloud beta auth application-default login
@dhavaln
dhavaln / cmd.txt
Created July 3, 2019 18:09
AWS KMS encrypt/decrypt
aws kms encrypt --key-id <key id> --plaintext "Hello world" --profile <user profile> --output text --query CiphertextBlob | base64 --decode > encryptedtext
aws kms decrypt --ciphertext-blob fileb://encryptedtext --output text --query Plaintext --profile <user profile> | base64 --decode
@dhavaln
dhavaln / serverless.yml
Created June 8, 2019 15:40
Serverless Hello World Layer Package
# layers
layers:
moment:
path: ../layers/moment-layer
compatibleRuntimes:
- nodejs8.10
package:
include:
- node_modules/**