Skip to content

Instantly share code, notes, and snippets.

View ryo0301's full-sized avatar
🏠
Working from home

ryo0301 ryo0301

🏠
Working from home
View GitHub Profile
@ryo0301
ryo0301 / file0.txt
Created September 26, 2014 11:11
シェルスクリプトでtry-catch-finally ref: http://qiita.com/ryo0301/items/7bf1eaf00b037c38e2ea
#!/bin/sh
set -eu
trap catch ERR
trap finally EXIT
function catch {
echo CATCH
}
@ryo0301
ryo0301 / $LSB
Last active August 29, 2015 14:08
LSB(Linux Standard Base)を見ながらinitスクリプトを書いた ref: http://qiita.com/ryo0301/items/0bc0f1db423b2da352fe
LSB=1
@ryo0301
ryo0301 / credentials
Last active August 29, 2015 14:09
aws-sdk-coreでcredentialsのプロファイルを切り替える ref: http://qiita.com/ryo0301/items/39308a5dc457b5df59ee
[default]
aws_access_key_id = DEFAULT_ACCESS_KEY_ID
aws_secret_access_key = DEFAULT_SECRET_ACCESS_KEY
aws_session_token = DEFAULT_SESSION_TOKEN
[dev]
aws_access_key_id = DEV_ACCESS_KEY_ID
aws_secret_access_key = DEV_SECRET_ACCESS_KEY
@ryo0301
ryo0301 / cf-audit-cloudtrail.template
Last active August 11, 2017 08:29
CloudFormation - CloudTrail template
{
"AWSTemplateFormatVersion" : "2010-09-09",
"Parameters" : {
"BucketName" : {
"Description" : "Name of the S3 bucket.",
"Type" : "String"
},
"TopicName" : {
"Description" : "Name of the SNS topic.",
"Type" : "String",
@ryo0301
ryo0301 / access-policy
Last active August 29, 2015 14:10
S3に画像をアップロードしたらLambdaでサムネイルを生成する(node-imagemagick) ref: http://qiita.com/ryo0301/items/7f9fd8024987526cbc30
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"lambda:InvokeFunction"
],
"Resource": [
"*"
@ryo0301
ryo0301 / do.js
Last active August 29, 2015 14:10
Kinesisにリクエストを流してLambdaからS3上のJSを動的に実行する ref: http://qiita.com/ryo0301/items/c07690a4181290a3f053
exports.do = function(event, callback) {
console.log('doing');
callback(null, 'done');
};
@ryo0301
ryo0301 / err
Last active March 16, 2017 09:20
S3、Kinesis/DynamoDB StreamsでのLambdaリトライ処理 ref: http://qiita.com/ryo0301/items/de5d965381d2273cf0a5
{
"message": "At least one of the pre-conditions you specified did not hold",
"code": "PreconditionFailed",
"time": "2014-12-03T02:54:39.101Z",
"statusCode": 412,
"retryable": false
}
@ryo0301
ryo0301 / .pryrc
Last active March 17, 2016 09:14
MacからAWSにアクセスする時はAssumeRoleすることにした ref: http://qiita.com/ryo0301/items/0730e4b1068707a37c31
begin
require 'aws-sdk-core'
rescue LoadError
else
# aws.rb may already have been initialized
Aws.config[:region] ||= 'ap-northeast-1'
Pry::Commands.import(Pry::CommandSet.new {
block_command 'aws-assume-role' do |role_name, external_id, token_code|
system "~/bin/aws-assume-role #{role_name} #{external_id} #{token_code}"
@ryo0301
ryo0301 / file0.txt
Last active August 29, 2015 14:19
CloudFormationで新旧LaunchConfigurationをrolling updateで切り替える ref: http://qiita.com/ryo0301/items/7b9ab1d74c230806f492
{
"Resources": {
"Group": {
"Type": "AWS::AutoScaling::AutoScalingGroup",
"UpdatePolicy": {
"AutoScalingRollingUpdate": {
"MaxBatchSize": "2",
"MinInstancesInService": "5",
"PauseTime": "PT10M",
"WaitOnResourceSignals": "true"
@ryo0301
ryo0301 / access-policy
Last active August 29, 2015 14:20
ImportImageによるVMインポート ref: http://qiita.com/ryo0301/items/e36f7602fbd762e739b2
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "1",
"Effect": "Allow",
"Action": [
"s3:GetBucketLocation",
"s3:ListBucket"
],