Skip to content

Instantly share code, notes, and snippets.

View maimai-swap's full-sized avatar

S. Ishimaru maimai-swap

  • individual
  • Japan
View GitHub Profile
@maimai-swap
maimai-swap / create-default-group-policy.sh
Last active August 29, 2015 14:17
AWS cli をつかってよくありそうなiamのgroupつくる
#!/bin/sh
# オリジナルのポリシー名
POLICY_NAME=$1
# オリジナルのポリシーのjsonの場所 file:// とか http://とか
POLICY_DOCUMENT=$2
# cli の configure 済の profile名いれる
AWS_PROFILE_NAME=$3
# オリジナルのポリシーつくる
@maimai-swap
maimai-swap / ec2stopstart.json
Created March 25, 2015 05:52
AWSEC2StopStartPolicy
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "Stmt1398823591000",
"Effect": "Allow",
"Action": [
"ec2:RunInstances",
"ec2:StartInstances",
"ec2:StopInstances",
@maimai-swap
maimai-swap / s3client_factory_from_ini_credentials.php
Created March 2, 2015 05:44
Elastic BeanstalkでAWS_SECRET_ACCESS_KEYとAWS_ACCESS_KEY_IDを環境変数に入れた時のウェブアプリ内でのS3Client::factoryの仕方
<?php
require __DIR__.'/../vendor/autoload.php';
use Aws\S3\S3Client;
use Aws\Common\Enum\Region;
use Aws\Common\Enum\ClientOptions;
use Aws\Common\Credentials\Credentials;
$credentials = Credentials::fromIni('your-profile-name');
@maimai-swap
maimai-swap / vpc_with_multiple_subnets.template.json
Last active August 29, 2015 14:15
VPCを作るCloudFormationテンプレート。SubnetConfigで正しく書いたら出来上がる
{
"AWSTemplateFormatVersion": "2010-09-09",
"Description": "VPC 120 with multiple subnets",
"Mappings": {
"SubnetConfig": {
"VPC": {
"CIDR": "10.120.0.0/24"
},
"PublicA": {
"CIDR": "10.120.0.0/26",
@maimai-swap
maimai-swap / typehint.php
Created February 16, 2015 08:30
IDEでtypehintだす
<?php
class Hoge {
public static function unchi() {
echo "uncho";
}
}
/* @var $hoge Hoge */
$hoge::unchi();
@maimai-swap
maimai-swap / tools-gist_as-instances-privateip.sh
Created January 29, 2015 06:06
elasticbeanstalk elb autoscaling 使うときのシェルとかqueryがめんどくさいのでメモ
#!/bin/sh
asname=$1
private_key_path="~/.ssh/your-private-key.pem"
instances=$(aws autoscaling describe-auto-scaling-instances --query "AutoScalingInstances[?AutoScalingGroupName==\`$asname\`][InstanceId]" --output text)
query_private_ip='Reservations[].[Instances[][NetworkInterfaces][][][PrivateIpAddresses][][][PrivateIpAddress]]'
dnslist=`aws ec2 describe-instances --instance-ids $instances --query "$query_private_ip" --output text`
for hostname in $dnslist
@maimai-swap
maimai-swap / td.repo
Created January 13, 2015 09:13
TreasureData レポジトリ for Amazon Linux AMI 2014.09 (TreasureData公式のサポートのものではありません)
[treasuredata]
name=TreasureData
baseurl=http://packages.treasuredata.com/2/redhat/7/\$basearch
gpgcheck=1
gpgkey=http://packages.treasuredata.com/GPG-KEY-td-agent
@maimai-swap
maimai-swap / hoge.sh
Created January 13, 2015 07:51
S3 cp stream 標準出力
aws s3 cp s3://bucket/key - | \
bzip2 --best | \
aws s3 cp - s3://bucket/key.bz2
@maimai-swap
maimai-swap / .ebextensions\01-ostimestamp.config
Created January 3, 2015 07:36
elastic beanstalkでs3においたシェルをダウンロードして実行する
files:
/root/os-timeclock.sh:
source: http://my-bucket-name.s3.amazonaws.com/shells/os-timeclock.sh
authentication: S3Access
Resources:
AWSEBAutoScalingGroup:
Metadata:
AWS::CloudFormation::Authentication:
S3Access:
@maimai-swap
maimai-swap / elb-child-instances.sh
Created December 22, 2014 08:25
ELBの配下にあるインスタンスのプライベートIP一覧を取る。
#!/bin/sh
# lb-hogehoge = ELB Tag Name Value
for instance_id in `aws elb describe-load-balancers --query 'LoadBalancerDescriptions[?LoadBalancerName==\`lb-hogehoge\`].["Instances"[]["InstanceId"]]' --output text`
do
ips=`aws ec2 describe-instances --instance-id $instance_id --query Reservations[].["Instances"[]["NetworkInterfaces"][][]["PrivateIpAddresses"][][]["PrivateIpAddress"]] --output text`
for ip in $ips