Skip to content

Instantly share code, notes, and snippets.

@jpbarto
jpbarto / Vagrantfile
Created May 6, 2016 08:48
Vagrantfile and docker-compose file for deploying HBase two different ways
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure(2) do |config|
config.vm.box = "blinkreaction/boot2docker"
config.vm.define "hbase" do |v|
v.vm.provision :docker do |d|
d.run "hbase",
@jpbarto
jpbarto / Vagrantfile
Last active May 9, 2016 09:30
Vagrantfile for the creation of a Docker host within either a local Virtualbox or a VSphere cloud environment
# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure(2) do |config|
config.vm.box = "dummy"
config.vm.provider :virtualbox do |vbox, override|
override.vm.box = 'blinkreaction/boot2docker'
end
@jpbarto
jpbarto / aws_lambda_self_destruct.py
Created December 7, 2016 23:46
AWS Lambda function that deletes itself
import os
import boto3
lclient = boto3.client ('lambda')
print ('function loaded')
def lambda_handler(event, context):
lclient.delete_function (FunctionName = context.function_name)
print ('I am deleted')
return True
@jpbarto
jpbarto / secure_iam_get.js
Created May 18, 2017 23:17
NodeJS SigV4 Invocation of AWS IAM authorized API Gateway endpoint
/** The following is a NodeJS port of the AWS SigV4 signing sample code (Python) to NodeJS
* The addition of the Authorization header has been informed by the use of Postman
* For more information see the following documentation:
* http://docs.aws.amazon.com/general/latest/gr/sigv4-signed-request-examples.html
*/
var https = require('https');
var crypto = require('crypto');
function sign(key, message) {
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"logs:CreateLogGroup",
"logs:CreateLogStream",
"logs:PutLogEvents"
],
'''
Copyright 2016 Amazon.com, Inc. or its affiliates. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with the License. A copy of the License is located at
http://aws.amazon.com/apache2.0/
or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
'''
import logging
import boto3
from botocore.exceptions import ClientError
import hashlib
{
"Records": [
{
"EventVersion": "1.0",
"EventSubscriptionArn": "arn:aws:sns:EXAMPLE",
"EventSource": "aws:sns",
"Sns": {
"SignatureVersion": "1",
"Timestamp": "1970-01-01T00:00:00.000Z",
"Signature": "EXAMPLE",
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"logs:CreateLogGroup",
"logs:CreateLogStream",
"logs:PutLogEvents"
],
#
# Ensure all EC2 Instances that do not have an 'exempt' tag value set are attached to any security groups that are tagged 'mandatory'
# Description: Checks that all EC2 instances that have a certain tag format also have a specific security group
#
import logging
import boto3
import json
import sys
{
"version": "0",
"id": "cbdd5653-b2b9-8c4e-c7de-bd6a0e879c9a",
"detail-type": "EC2 Instance State-change Notification",
"source": "aws.ec2",
"account": "776347453069",
"time": "2017-10-29T23:07:54Z",
"region": "ap-southeast-2",
"resources": [
"arn:aws:ec2:ap-southeast-2:776347453069:instance/i-0533ccc4be7f511af"