Skip to content

Instantly share code, notes, and snippets.

View miyamoto-daisuke's full-sized avatar

都元ダイスケ@Classmethod miyamoto-daisuke

  • Classmethod, Inc.
  • Tokyo
View GitHub Profile
@miyamoto-daisuke
miyamoto-daisuke / main.js
Created December 18, 2014 08:59
TriSens
console.log("TriSens");
var mraa = require('mraa');
console.log('MRAA Version: ' + mraa.getVersion());
var tempPin = new mraa.Aio(0);
var lightPin = new mraa.Aio(1);
var soundPin = new mraa.Aio(2);
console.log("start BiriBiriWorkerBox");
// ==== config
var accountId = "123456789012";
var cognitoRoleArn = "arn:aws:iam::123456789012:role/Cognito_WorkerBoxUnauth_DefaultRole";
var cognitoIdentityPoolId = "us-east-1:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx";
var queueUrl = "https://sqs.ap-northeast-1.amazonaws.com/123456789012/workerbox";
// ==== mraa
var mraa = require('mraa');
@miyamoto-daisuke
miyamoto-daisuke / vpc-knowhow-2014-04.template
Last active October 20, 2020 07:02
VPC knownhow 2014-04
{
"AWSTemplateFormatVersion": "2010-09-09",
"Description": "VPC knowhow template",
"Parameters": {
"KeyName": {
"Description": "Name of an existing EC2 KeyPair to enable SSH access to the instances",
"Type": "String",
"MinLength": "1",
"MaxLength": "64",
"AllowedPattern": "[-_ a-zA-Z0-9]*",
@miyamoto-daisuke
miyamoto-daisuke / bgd-php.template
Created March 14, 2014 09:35
AWS CloudFormation tempate for PHP Blue-Green Deployment environment
{
"AWSTemplateFormatVersion" : "2010-09-09",
"Description" : "PHP Blue-Green Deployment environment template",
"Parameters" : {
"KeyName" : {
"Description" : "Name of an existing EC2 KeyPair to enable SSH access to the instances",
"Type" : "String",
"MinLength" : "1",
"MaxLength" : "64",
"AllowedPattern" : "[-_ a-zA-Z0-9]*",
{
"AWSTemplateFormatVersion": "2010-09-09",
"Description": "VPC knowhow template",
"Parameters": {
"KeyName": {
"Description": "Name of an existing EC2 KeyPair to enable SSH access to the instances",
"Type": "String",
"MinLength": "1",
"MaxLength": "64",
"AllowedPattern": "[-_ a-zA-Z0-9]*",
{
"AWSTemplateFormatVersion": "2010-09-09",
"Description": "fluentd template",
"Parameters": {
"KeyName": {
"Description": "Name of an existing EC2 KeyPair to enable SSH access to the instances",
"Type": "String",
"MinLength": "1",
"MaxLength": "64",
"AllowedPattern": "[-_ a-zA-Z0-9]*",
{
"AWSTemplateFormatVersion": "2010-09-09",
"Description": "simple template",
"Parameters": {
"KeyName": {
"Description": "Name of an existing EC2 KeyPair to enable SSH access to the web server",
"Type": "String",
"MinLength": "1",
"MaxLength": "64",
"AllowedPattern": "[-_ a-zA-Z0-9]*",
{
"AWSTemplateFormatVersion": "2010-09-09",
"Description": "Tungsten Replicator evaluation",
"Parameters" : {
"KeyName" : {
"Description" : "Name of an existing EC2 KeyPair to enable SSH access to the web server",
"Type" : "String"
},
"SlaveMasterPassword" : {
"Description" : "Password of RDS master user",
{
"AWSTemplateFormatVersion": "2010-09-09",
"Description": "Multiple VPN Connection between VPCs.",
"Parameters" : {
"KeyName" : {
"Description" : "Name of an existing EC2 KeyPair to enable SSH access to the web server",
"Type" : "String"
},
"SSHFrom": {
"Description": "Lockdown SSH access to the bastion host (default can be accessed from anywhere)",
#! /bin/bash
SELF_INSTANCE_ID=`curl -s http://169.254.169.254/latest/meta-data/instance-id`
ELB_NAME=elbfailover
SLEEPTIME=2
while :; do
TIMESTAMP=`date -u +"%Y-%m-%dT%H:%M:%SZ"`
ELB_STATUS=`aws elb describe-instance-health --load-balancer-name $ELB_NAME`
HEALTHY_HOST_COUNT=`echo $ELB_STATUS | jq "[ .InstanceStates[] | select(.InstanceId != \"$SELF_INSTANCE_ID\" and .State == \"InService\") ] | length"`