Skip to content

Instantly share code, notes, and snippets.

Nacho García nachoab

View GitHub Profile
nachoab / resource.yml
Created Mar 2, 2017
Cloud Formation: Create API Gateway endpoint with HTTP Integration, passing cognito user [Serverless]
View resource.yml
# Create 'foo/bar' private endpoint on API Gateway, with POST method using HTTP integration
# Your APIG foo/bar endpoint will validate the request IAM session and if succeds, pass the request to your endpoint passing all data received including the user session
# It passes request headers, path, querystring, body and context (cognito user is here) to the endpoint as the body payload
Type: AWS::ApiGateway::Resource
PathPart: foo
nachoab / aws-cloudwatch-console-delete-log-groups
Created Feb 2, 2017
Deletes multiple cloud watch log groups on the AWS console UI filtering by name regexp. Without doing clicks. Useful for serverless migrating to auto create log groups
View aws-cloudwatch-console-delete-log-groups
var nextPage = () => {
return new Promise((resolve, reject) => {
console.log('Go to next page ...');
const disabledIcon = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABgAAAAXCAYAAAARIY8tAAABVklEQVR42u1UsUrDUBStiyAoKAh+gn6Bk//gqKOOgpvgKDg5OaaFJE1K0iRNSJo2bSIdYhKIJehixoyd+wVS0+t5/YW8ReiFx+Pd4Z5z7j33tVrb2IbjOKeKonwbhnHJvfhwOLwAwHKxWFAQBD+WZV1xBQDrzzAMKc9zqqqKgayQu+EGMB6PT3RdL6GCZrMZlWVJyP32er07biCTyeQYBb80TaPRaERFUbC7liTpgRuI7/uH3W73A8OmwWBAWZYxJbUoik/cQARB2O90OjGKUr/fpyRJKIqiGvkXXnbdbbfbPlOhqiqZpklwGQFAaFx8Pp/voedvcBDBqpsjy/Iaal6JaKepkw7AOnVdd8PY8zzC0NcAeG7MfDqdHsE9BW7Wb2I7gfcaAI9c+o5i74jNQOM4Zn2vsRf3PO15btv2Mk1TwpBXsOgt9/8IrM+wAxXUXG+//v8Zf/3P6XuKEbAtAAAAAElFTkSuQmCC"
const nextImg = document.querySelector('#gwt-debug-pager td:last-child img');
if (nextImg.src !== disabledIcon) {;
setTimeout(resolve, 1000);
nachoab / s3-aws-policy
Created Nov 14, 2016
AWS S3 user folder policy
View s3-aws-policy
"Version": "2012-10-17",
"Statement": [
"Effect": "Allow",
"Principal": { "Federated": "" },
"Action": ["s3:ListBucket"],
"Resource": ["arn:aws:s3:::BUCKET_NAME"],
"Condition": {"StringLike": {"s3:prefix": ["${}/*"]}}
nachoab / serverless-auth-extension-plugin
Created Oct 3, 2016
adds the posibility to configure AWS_IAM and "Invoke with caller credentials" for your API Gateway endpoints
View serverless-auth-extension-plugin
'use strict';
* Adds the posibility to configure AWS_IAM for your API Gateway endpoints
* and "Invoke with caller credentials"
* Usage:
* myFuncGetItem:
View Cognito Federated oauth + API Gateway IAM auth + Lambda for serverless
TO USE THIS client:
- Go to the google developer console and get your client id. This is pretty
well documented somewhere else. Use your localhost(:port)? as url to work in
your local as always.
- Go to AWS and create a new Federated identity pool
* Associate an Authenticated role and Unauthenticated role to the pool
At least you need cognito-identity and apigateway, edit this for your needs
nachoab / cognito-records-example.js
Created Sep 21, 2016
lambda udpate records from a google user using cognito
View cognito-records-example.js
module.exports.auth = (event, context, callback) => {
AWS.config.credentials = new AWS.CognitoIdentityCredentials({
IdentityPoolId: IdentityPoolId,
Logins: {
'': event.id_token
AWS.config.credentials.get(() =>{
if (!AWS.config.credentials.accessKeyId) {
View routes.js
var rendererOptions = {
draggable: true,
polylineOptions: {
strokeColor: "#FF0000"
var directionsDisplay = new google.maps.DirectionsRenderer(rendererOptions);
var directionsService = new google.maps.DirectionsService();
var geocoder;
var map;
nachoab / usage.html
Last active Aug 29, 2015
Avatar google style for Facebook and Google
View usage.html
<user-avatar id="my-ids" class="my-classes" user="userObject"></user-avatar>
You can’t perform that action at this time.