7
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

kelbimで管理するAWS,ELB

Last updated at Posted at 2014-09-10

#kelbim

AWSのELBの設定をRubyのDSLで管理できるCLIツール。

作成者サイト
http://so-wh.at/entry/20131105/p1

Github
https://github.com/winebarrel/kelbim

##手順

###インストール

インストール

➜ gem install kelbim --no-ri --no-rdoc

確認

➜  kelbim -v
kelbim 0.2.6
➜  kelbim  kelbim
Usage: kelbim [options]
    -p, --profile PROFILE_NAME
    -k, --access-key ACCESS_KEY
    -s, --secret-key SECRET_KEY
    -r, --region REGION
    -a, --apply
    -f, --file FILE
    -n, --elb-names NAMES
        --dry-run
        --ec2s VPC_IDS
        --without-deleting-policy
    -e, --export
    -o, --output FILE
        --split
        --split-more
    -t, --test
        --show-load-balancers
        --show-policies
        --no-color
        --debug

security credentialsを記載

➜  vim ~/.aws/credentials
[default]
aws_access_key_id=AKIxxxxxxxxxxxxxxxx
aws_secret_access_key=xxxxxxxxxxxxxxxxxxxxx

###ELBの情報を取得

ELBの確認

➜   kelbim -e -r ap-northeast-1 --show-load-balancers
{
  "vpc-[id]": {
    "[elb-name]": "[elb-dns]ap-northeast-1.elb.amazonaws.com"
  }
}

ELB情報の取得

--ec2オプションで指定のVPCのみ出力

kelbim -e -o ELBfile -r ap-northeast-1 --ec2s vpc-[id]
cat ELBfile

c2 "vpc-[id]" do
  load_balancer "[elb-name]" do
    spec do
      # DNS Name: [elb-dns].ap-northeast-1.elb.amazonaws.com
      pending('This is an example')
      url = URI.parse('http://www.example.com/')
      res = Net::HTTP.start(url.host, url.port) {|http| http.get(url.path) }
      expect(res).to be_a(Net::HTTPOK)
    end

    instances(
      "[instans-name]"
    )
…
…
…

###ELBのテスト、設定適用

RSpecでのテスト

➜ kelbim -t
Test `ELBfile`
*

Pending:
  vpc-[id]> [elb-name]
    # This is an example

Finished in 0.00033 seconds
1 example, 0 failures, 1 pending

ELBの適用

別アカウントの場合はcredentialsを追記し、-pで指定。
別VPCの場合は、ELBfileを書き換えておく。

➜  kelbim  kelbim -a -o ELBfile -p sato -r ap-northeast-1
Apply `ELBfile` to ELB
Comparing vpc-[id]> [elb-name]
Update LoadBalancer: vpc-[id]> [elb-name]
  set attributes={:access_log=>{:enabled=>false}, :connection_settings=>{:idle_timeout=>30}, :cross_zone_load_balancing=>{:enabled=>true}, :connection_draining=>{:enabled=>true, :timeout=>300}}

###etc

お手軽なELBの管理と移行が可能になった!

7
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
7
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?