awspec
RSpec tests for your AWS resources.
https://github.com/k1LoW/awspec
AWS上に展開したリソースがあるべき状態になっている
かどうかをテストするツール
5
福岡Ruby会議02
Slide 6
Slide 6 text
ec2
6
福岡Ruby会議02
describe ec2('my-ec2-tag-name') do
it { should be_running }
its(:instance_id) { should eq 'i-ec12345a' }
its(:instance_type) { should eq ’t2.small' }
its(:public_ip_address) { should eq '123.0.456.789' }
it { should have_security_group('my-sg-name') }
it { should belong_to_vpc('my-vpc') }
it { should have_eip('123.0.456.789') }
end
Slide 7
Slide 7 text
route53_hosted_zone
7
福岡Ruby会議02
describe route53_hosted_zone('example.com.') do
it { should exist }
its(:resource_record_set_count) { should eq 5 }
it { should have_record_set('example.com.').a('123.456.7.890') }
it { should have_record_set('example.com.').mx('10 mail.example.com') }
it { should have_record_set('mail.example.com.')
.a('123.456.7.890').ttl(3600) }
it { should have_record_set('s3.example.com.')
.alias('s3-website-us-east-1.amazonaws.com.', 'Z2ABCDEFGHIJKL') }
end
Serverspec
RSpec tests for your servers.
https://github.com/mizzy/serverspec
サーバに展開したリソースがあるべき状態になっている
かどうかをテストするツール
RSpec tests for your servers configured by CFEngine, Puppet,
Ansible, Itamae or anything else.
16
福岡Ruby会議02
Slide 17
Slide 17 text
Serverspec
17
福岡Ruby会議02
describe service('ntpd') do
it { should be_enabled.with_level(3) }
end
describe iptables do
it { should have_rule('-P INPUT ACCEPT') }
end
describe cgroup('group1') do
its('cpuset.cpus') { should eq 1 }
end
Add tag matching support
40
福岡Ruby会議02
各リソースにおいて、タグの保持をテストするマッチ
ャの追加
#119 PR by igorlg
describe ec2('my-ec2') do
it { should have_tag('Name').value('my-ec2') }
end
Add opened_only matcher
for security groups.
42
福岡Ruby会議02
Slide 43
Slide 43 text
Add opened_only matcher for security groups.
福岡Ruby会議02 43
Security Groupの「このポートだけオープンしている
こと」をテストするマッチャの追加
#121 PR by ceaess
describe security_group('my-sg') do
its(:outbound) do should be_opened_only(50_000)
.protocol('tcp')
.for(%w(100.456.789.012/32 200.567.890.123/32))
end
end
Add ec2 `have_event()` and
`have_events()`.
45
福岡Ruby会議02
Slide 46
Slide 46 text
Add ec2 `have_event()` and `have_events()`
46
福岡Ruby会議02
EC2にイベント(再起動イベントなど)があるか確認
するマッチャの追加
#131 PR by k1LoW
describe ec2('my-ec2') do
it { should have_event('system-reboot') }
end
describe ec2(’other-ec2') do
it { should_not have_events }
end
Add ec2 `have_classiclink_security_group()`
49
福岡Ruby会議02
EC2-ClassicがClassicLink先のSecurity Groupをもっ
ているかどうかを確認するマッチャの追加
#150 PR by matsuzj
describe ec2('my-classic-ec2') do
it { should have_classiclink_security_group('sg-2a3b4cd5') }
it { should have_classiclink_security_group('my-vpc-security-
group-name') }
end
Slide 50
Slide 50 text
EC2-Classicからの脱却
EC2-ClassicをEC2 on VPCへ
https://nulab-inc.com/ja/blog/backlog/move-vpc-ec2-
classic/
コードで管理されていない⼿動で作られた構成にテス
トの恩恵を
50
福岡Ruby会議02
Slide 51
Slide 51 text
Add CloudTrail support to check if
logging is enabled.
51
福岡Ruby会議02
Slide 52
Slide 52 text
Add CloudTrail support to check if logging is
enabled.
52
福岡Ruby会議02
CloudTrailでロギングが有効になっているかをテストす
るマッチャの追加
#164 PR by arimbun
describe cloudtrail('my-trail') do
it { should be_logging }
end
Add shared_context to specify region
by context
54
福岡Ruby会議02
Slide 55
Slide 55 text
Add shared_context to specify region by context
55
福岡Ruby会議02
複数のリージョンをまたいだテストができるようにす
る修正
#187 PR by takaishi
describe ec2('my-ec2’), region: 'us-east-1' do
it { should exist }
end