Skip to content

Instantly share code, notes, and snippets.

cat UserData.sh |sed 's/\"/\\\"/g' | sed 's/^/\"/g' | sed 's/$/\\n\",/g' | sed '$s/.$//'
var AWS = require('aws-sdk');
AWS.config.update({region: 'ap-northeast-1'});
var codedeploy = new AWS.CodeDeploy();
// getDeployment
function getDeployment(deploymentId, callback) {
var status = '';
var params = {
deploymentId: deploymentId
};

基本課金情報

EC2

  • インスタンスを起動している時間に応じて課金
  • t2.microの場合、1時間辺り0.020$

通信

  • 同一AZ内での通信は無料(他のEC2との通信やRDSとの通信)
#!/bin/bash
DIR="hoge-dir"
cd $DIR
files=`ls`
for file in ${files[@]}; do
echo $file
done
$yum install rpm-build
# not su user
$cd
$mkdir rpmbuild
$mkdir rpmbuild/BUILD
$mkdir rpmbuild/BUILDROOT
$mkdir rpmbuild/RPMS
$mkdir rpmbuild/SOURCES
$mkdir rpmbuild/SPECS
@toshihirock
toshihirock / countELBLog.sh
Created May 27, 2015 04:35
ELBアクセスログのステータスコード毎の集計(分単位)
$sed -e 's/:[0-9][0-9]\.[0-9][0-9][0-9][0-9][0-9][0-9]Z//g' access.log |awk -F " " '{ print $1,$8; }'| sort | uniq -c
#!/bin/bash
ip=192.168.0.1
if [[ $ip =~ ^[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}$ ]]; then
echo "ip address"
else
echo "not ip"
fi

条件

  • カスタムレイヤー.PublicIPaddress以外はデフォルト
  • 実験のタイミングではインスタンスは再起動ではなく、常にdelete,create
  • t2.micro
  • AmazonLinux2015.03
  • EBS backed
  • GeneralPurpose(SSD)

起動時間結果

# キューの作成。MessageRetentionPeriodでメッセージの保持期間を14日に設定。また、ReceiveMessageWaitTimeSecondでロングポーリング時の待ち時間を20秒に設定。
aws sqs create-queue --queue-name test-sqs --attributes MessageRetentionPeriod=1209600,ReceiveMessageWaitTimeSeconds=20
# キューの表示
aws sqs list-queues
# メッセージの送信
aws sqs send-message --queue-url https://ap-northeast-1.queue.amazonaws.com/hogefuga/test-sqs --message-body 'hello world!'
# send-message-batchを使うことで最大10個のメッセージを同時に送信できる
@toshihirock
toshihirock / getRemoteExitStatus.rb
Created April 27, 2015 09:21
踏み台の先のサーバーで任意のコマンドを実行し、その終了ステータスを取得する
require 'net/ssh'
require 'fileutils'
PASSWORD="password"
CONFIG='./config_file'
def write_config_file
File.open(CONFIG, 'w') { |f|
f << "Host fumidai\n"
f << "HostName hoge\n"