25. Code例(Serverspec)
25
describe command('ls -al /') do
its(:stdout) { should match /bin/ }
end
describe command('ls /foo') do
its(:stderr) { should match /No such file or directory/ }
end
describe command('ls /foo') do
its(:exit_status) { should eq 0 }
end
35. テンプレート作成(CloudFormation)
35
service
server server
Load balancing
Fire Wall CloudFormerで各リソースの
情報を取得しテンプレート化
CloudFormation(amazon web service社)
https://docs.aws.amazon.com/ja_jp/AWSCloudFormation/latest/UserGuide/Welco
me.html
CloudFormer(amazon web service社)
https://docs.aws.amazon.com/ja_jp/AWSCloudFormation/latest/UserGuide/cfn-
using-cloudformer.html
※CloudFormerを活用することでウィザード形式でテンプレートを簡単に作成で
きる。但し余分なゴミがテンプレートに残っている場合があるので編集が必要。
※CloudFormer専用のEC2インスタンスも立てる必要がある。
テンプレート作成時にはその分コストも発生するため注意。
36. テンプレート例(CloudFormation)
36
{
"AWSTemplateFormatVersion" : "2010-09-09",
"Description" : "AWS CloudFormation Sample Template EC2_Instance_With_Ephemeral_Drives:
Example to show how to attach ephemeral drives using EC2 block device mappings. **WARNING**
This template creates an Amazon EC2 instance. You will be billed for the AWS resources used if
you create a stack from this template.",
"Parameters" : {
"KeyName": {
"Description" : "Name of an existing EC2 KeyPair to enable SSH access to the web server",
"Type": "AWS::EC2::KeyPair::KeyName",
"ConstraintDescription" : "must be the name of an existing EC2 KeyPair.”
〜以下省略〜
38. テンプレート作成(Terraform)
38
service
server server
Load balancing
Fire Wall Terraformingで各リソースの
情報を取得しテンプレート化
Terraform(Hasicorp社)
https://www.terraform.io/
Terraforming(GitHub)
https://github.com/dtan4/terraforming
※TerraformingはHasicorp製ではなく非公式ツール。
テンプレート化対応されていないリソースもあるので注意。
39. テンプレート例(Terraform)
39
provider "aws" {
region = "us-west-2"
}
data "aws_ami" "ubuntu" {
most_recent = true
filter {
name = "name"
values = ["ubuntu/images/hvm-ssd/ubuntu-trusty-14.04-amd64-server-*"]
}
〜以下省略〜