awspec 0.6.1 → 0.6.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +10 -0
- data/doc/_resource_types/rds_db_parameter_group.md +8 -0
- data/doc/resource_types.md +32 -25
- data/lib/awspec.rb +2 -0
- data/lib/awspec/bin/toolbox +5 -0
- data/lib/awspec/generator.rb +5 -1
- data/lib/awspec/generator/doc/type.rb +26 -0
- data/lib/awspec/generator/doc/type/auto_scaling_group.rb +16 -0
- data/lib/awspec/generator/doc/type/base.rb +89 -0
- data/lib/awspec/generator/doc/type/ebs.rb +17 -0
- data/lib/awspec/generator/doc/type/ec2.rb +17 -0
- data/lib/awspec/generator/doc/type/elb.rb +20 -0
- data/lib/awspec/generator/doc/type/rds.rb +17 -0
- data/lib/awspec/generator/doc/type/rds_db_parameter_group.rb +16 -0
- data/lib/awspec/generator/doc/type/route53_hosted_zone.rb +16 -0
- data/lib/awspec/generator/doc/type/route_table.rb +16 -0
- data/lib/awspec/generator/doc/type/s3.rb +16 -0
- data/lib/awspec/generator/doc/type/security_group.rb +16 -0
- data/lib/awspec/generator/doc/type/subnet.rb +16 -0
- data/lib/awspec/generator/doc/type/vpc.rb +17 -0
- data/lib/awspec/generator/template.rb +100 -0
- data/lib/awspec/stub.rb +7 -0
- data/lib/awspec/stub/auto_scaling_group.rb +87 -0
- data/lib/awspec/stub/ebs.rb +66 -0
- data/lib/awspec/stub/ec2.rb +117 -0
- data/lib/awspec/stub/elb.rb +129 -0
- data/lib/awspec/stub/rds.rb +93 -0
- data/lib/awspec/stub/rds_db_parameter_group.rb +16 -0
- data/lib/awspec/stub/route53_hosted_zone.rb +83 -0
- data/lib/awspec/stub/route_table.rb +60 -0
- data/lib/awspec/stub/s3.rb +14 -0
- data/lib/awspec/stub/security_group.rb +66 -0
- data/lib/awspec/stub/subnet.rb +33 -0
- data/lib/awspec/stub/vpc.rb +69 -0
- data/lib/awspec/toolbox.rb +13 -0
- data/lib/awspec/version.rb +1 -1
- metadata +33 -16
- data/lib/awspec/docgen.rb +0 -23
- data/lib/awspec/generator/doc/auto_scaling_group.rb +0 -15
- data/lib/awspec/generator/doc/base.rb +0 -74
- data/lib/awspec/generator/doc/ebs.rb +0 -15
- data/lib/awspec/generator/doc/ec2.rb +0 -15
- data/lib/awspec/generator/doc/elb.rb +0 -18
- data/lib/awspec/generator/doc/rds.rb +0 -15
- data/lib/awspec/generator/doc/rds_db_parameter_group.rb +0 -15
- data/lib/awspec/generator/doc/route53_hosted_zone.rb +0 -15
- data/lib/awspec/generator/doc/route_table.rb +0 -15
- data/lib/awspec/generator/doc/s3.rb +0 -15
- data/lib/awspec/generator/doc/security_group.rb +0 -15
- data/lib/awspec/generator/doc/subnet.rb +0 -15
- data/lib/awspec/generator/doc/vpc.rb +0 -15
@@ -0,0 +1,16 @@
|
|
1
|
+
module Awspec::Generator
|
2
|
+
module Doc
|
3
|
+
module Type
|
4
|
+
class Route53HostedZone < Base
|
5
|
+
def initialize
|
6
|
+
super
|
7
|
+
@type = Awspec::Type::Route53HostedZone.new('example.com.')
|
8
|
+
@ret = @type.hosted_zone
|
9
|
+
@matchers = []
|
10
|
+
@ignore_matchers = []
|
11
|
+
@describes = []
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Awspec::Generator
|
2
|
+
module Doc
|
3
|
+
module Type
|
4
|
+
class RouteTable < Base
|
5
|
+
def initialize
|
6
|
+
super
|
7
|
+
@type = Awspec::Type::RouteTable.new('my-route-table')
|
8
|
+
@ret = @type.route_table
|
9
|
+
@matchers = []
|
10
|
+
@ignore_matchers = []
|
11
|
+
@describes = []
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Awspec::Generator
|
2
|
+
module Doc
|
3
|
+
module Type
|
4
|
+
class S3 < Base
|
5
|
+
def initialize
|
6
|
+
super
|
7
|
+
@type = Awspec::Type::S3.new('my-bucket')
|
8
|
+
@ret = @type.bucket
|
9
|
+
@matchers = []
|
10
|
+
@ignore_matchers = []
|
11
|
+
@describes = []
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Awspec::Generator
|
2
|
+
module Doc
|
3
|
+
module Type
|
4
|
+
class SecurityGroup < Base
|
5
|
+
def initialize
|
6
|
+
super
|
7
|
+
@type = Awspec::Type::SecurityGroup.new('my-security-group-name')
|
8
|
+
@ret = @type.sg
|
9
|
+
@matchers = ['its(:inbound), its(:outbound)']
|
10
|
+
@ignore_matchers = %w(be_opened be_inbound_opened be_outbound_opened)
|
11
|
+
@describes = %w(ip_permissions_count ip_permissions_egress_count)
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
module Awspec::Generator
|
2
|
+
module Doc
|
3
|
+
module Type
|
4
|
+
class Subnet < Base
|
5
|
+
def initialize
|
6
|
+
super
|
7
|
+
@type = Awspec::Type::Subnet.new('my-route-table')
|
8
|
+
@ret = @type.subnet
|
9
|
+
@matchers = []
|
10
|
+
@ignore_matchers = []
|
11
|
+
@describes = []
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Awspec::Generator
|
2
|
+
module Doc
|
3
|
+
module Type
|
4
|
+
class Vpc < Base
|
5
|
+
def initialize
|
6
|
+
super
|
7
|
+
@type_name = 'VPC'
|
8
|
+
@type = Awspec::Type::Vpc.new('my-vpc')
|
9
|
+
@ret = @type.vpc
|
10
|
+
@matchers = []
|
11
|
+
@ignore_matchers = []
|
12
|
+
@describes = []
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,100 @@
|
|
1
|
+
module Awspec::Generator
|
2
|
+
class Template
|
3
|
+
def self.generate(type)
|
4
|
+
@type = type
|
5
|
+
@root_path = File.dirname(__FILE__) + '/../../../'
|
6
|
+
generate_stub
|
7
|
+
generate_type
|
8
|
+
generate_type_spec
|
9
|
+
generate_generator_doc
|
10
|
+
put_message
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.generate_type
|
14
|
+
path = 'lib/awspec/type/' + @type.to_snake_case + '.rb'
|
15
|
+
full_path = @root_path + path
|
16
|
+
content = <<-"EOF"
|
17
|
+
module Awspec::Type
|
18
|
+
class #{@type.to_camel_case} < Base
|
19
|
+
def initialize(id)
|
20
|
+
super
|
21
|
+
# @id = # @FIXME
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
EOF
|
26
|
+
self.file_check_and_puts(path, content)
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.generate_stub
|
30
|
+
path = 'lib/awspec/stub/' + @type.to_snake_case + '.rb'
|
31
|
+
full_path = @root_path + path
|
32
|
+
content = <<-"EOF"
|
33
|
+
# Aws.config[:ec2]= {
|
34
|
+
# stub_responses: true
|
35
|
+
# }
|
36
|
+
EOF
|
37
|
+
self.file_check_and_puts(path, content)
|
38
|
+
end
|
39
|
+
|
40
|
+
def self.generate_type_spec
|
41
|
+
path = 'spec/type/' + @type.to_snake_case + '_spec.rb'
|
42
|
+
full_path = @root_path + path
|
43
|
+
content = <<-"EOF"
|
44
|
+
require 'spec_helper'
|
45
|
+
Awspec::Stub.load '#{@type.to_snake_case}'
|
46
|
+
|
47
|
+
describe #{@type.to_snake_case}('my-#{@type.to_snake_case.tr('_', '-')}') do
|
48
|
+
it { should exist }
|
49
|
+
end
|
50
|
+
EOF
|
51
|
+
self.file_check_and_puts(path, content)
|
52
|
+
end
|
53
|
+
|
54
|
+
def self.generate_generator_doc
|
55
|
+
path = 'lib/awspec/generator/doc/type/' + @type.to_snake_case + '.rb'
|
56
|
+
full_path = @root_path + path
|
57
|
+
content = <<-"EOF"
|
58
|
+
module Awspec::Generator
|
59
|
+
module Doc
|
60
|
+
module Type
|
61
|
+
class #{@type.to_camel_case} < Base
|
62
|
+
def initialize
|
63
|
+
super
|
64
|
+
@type_name = '#{@type.to_camel_case}'
|
65
|
+
@type = Awspec::Type::#{@type.to_camel_case}.new('my-#{@type.to_snake_case.tr('_', '-')}')
|
66
|
+
# @ret = # @FIXME
|
67
|
+
@matchers = []
|
68
|
+
@ignore_matchers = []
|
69
|
+
@describes = []
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
EOF
|
76
|
+
self.file_check_and_puts(path, content)
|
77
|
+
end
|
78
|
+
|
79
|
+
def self.put_message
|
80
|
+
content = <<-"EOF"
|
81
|
+
|
82
|
+
Genarate #{@type.to_camel_case} template files.
|
83
|
+
|
84
|
+
* !! AND add '#{@type.to_snake_case}' to Awspec::Helper::Type::TYPES in awspec/lib/helper/type.rb *
|
85
|
+
|
86
|
+
EOF
|
87
|
+
end
|
88
|
+
|
89
|
+
def self.file_check_and_puts(path, content)
|
90
|
+
if File.exist? @root_path + path
|
91
|
+
$stderr.puts "!! #{path} already exists"
|
92
|
+
else
|
93
|
+
File.open(@root_path + path, 'w') do |f|
|
94
|
+
f.puts content
|
95
|
+
end
|
96
|
+
puts " + #{path}"
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
data/lib/awspec/stub.rb
ADDED
@@ -0,0 +1,87 @@
|
|
1
|
+
Aws.config[:autoscaling] = {
|
2
|
+
stub_responses: {
|
3
|
+
describe_auto_scaling_groups: {
|
4
|
+
auto_scaling_groups: [
|
5
|
+
{
|
6
|
+
auto_scaling_group_name: 'my-auto-scaling-group',
|
7
|
+
auto_scaling_group_arn: 'arn:aws:autoscaling:::autoScalingGroup::autoScalingGroupName/my-auto-scaling-group',
|
8
|
+
launch_configuration_name: 'my-lc',
|
9
|
+
min_size: 4,
|
10
|
+
max_size: 20,
|
11
|
+
desired_capacity: 4,
|
12
|
+
default_cooldown: 300,
|
13
|
+
availability_zones: [
|
14
|
+
'ap-northeast-1a',
|
15
|
+
'ap-northeast-1c'
|
16
|
+
],
|
17
|
+
load_balancer_names: [
|
18
|
+
'my-elb'
|
19
|
+
],
|
20
|
+
health_check_type: 'EC2',
|
21
|
+
health_check_grace_period: 0,
|
22
|
+
instances: [
|
23
|
+
{
|
24
|
+
instance_id: 'i-ec12345a',
|
25
|
+
availability_zone: 'ap-northeast-1a',
|
26
|
+
lifecycle_state: 'InService',
|
27
|
+
health_status: 'Healthy',
|
28
|
+
launch_configuration_name: 'my-lc'
|
29
|
+
}
|
30
|
+
],
|
31
|
+
created_time: Time.local(2015)
|
32
|
+
}
|
33
|
+
]
|
34
|
+
}
|
35
|
+
}
|
36
|
+
}
|
37
|
+
|
38
|
+
Aws.config[:ec2] = {
|
39
|
+
stub_responses: {
|
40
|
+
describe_instances: {
|
41
|
+
reservations: [
|
42
|
+
{
|
43
|
+
instances: [
|
44
|
+
{
|
45
|
+
instance_id: 'i-ec12345a',
|
46
|
+
image_id: 'ami-abc12def',
|
47
|
+
vpc_id: 'vpc-ab123cde',
|
48
|
+
subnet_id: 'subnet-1234a567',
|
49
|
+
public_ip_address: '123.0.456.789',
|
50
|
+
private_ip_address: '10.0.1.1',
|
51
|
+
instance_type: 't2.small',
|
52
|
+
state: {
|
53
|
+
name: 'running'
|
54
|
+
},
|
55
|
+
security_groups: [
|
56
|
+
{
|
57
|
+
group_id: 'sg-1a2b3cd4',
|
58
|
+
group_name: 'my-security-group-name'
|
59
|
+
}
|
60
|
+
],
|
61
|
+
tags: [
|
62
|
+
{
|
63
|
+
key: 'Name',
|
64
|
+
value: 'my-ec2'
|
65
|
+
}
|
66
|
+
]
|
67
|
+
}
|
68
|
+
]
|
69
|
+
}
|
70
|
+
]
|
71
|
+
},
|
72
|
+
describe_subnets: {
|
73
|
+
subnets: [
|
74
|
+
{
|
75
|
+
vpc_id: 'vpc-ab123cde',
|
76
|
+
subnet_id: 'subnet-1234a567',
|
77
|
+
tags: [
|
78
|
+
{
|
79
|
+
key: 'Name',
|
80
|
+
value: 'my-subnet'
|
81
|
+
}
|
82
|
+
]
|
83
|
+
}
|
84
|
+
]
|
85
|
+
}
|
86
|
+
}
|
87
|
+
}
|
@@ -0,0 +1,66 @@
|
|
1
|
+
Aws.config[:ec2] = {
|
2
|
+
stub_responses: {
|
3
|
+
describe_instances: {
|
4
|
+
reservations: [
|
5
|
+
{
|
6
|
+
instances: [
|
7
|
+
{
|
8
|
+
instance_id: 'i-ec12345a',
|
9
|
+
image_id: 'ami-abc12def',
|
10
|
+
vpc_id: 'vpc-ab123cde',
|
11
|
+
subnet_id: 'subnet-1234a567',
|
12
|
+
public_ip_address: '123.0.456.789',
|
13
|
+
private_ip_address: '10.0.1.1',
|
14
|
+
instance_type: 't2.small',
|
15
|
+
state: {
|
16
|
+
name: 'running'
|
17
|
+
},
|
18
|
+
security_groups: [
|
19
|
+
{
|
20
|
+
group_id: 'sg-1a2b3cd4',
|
21
|
+
group_name: 'my-security-group-name'
|
22
|
+
}
|
23
|
+
],
|
24
|
+
block_device_mappings: [
|
25
|
+
{
|
26
|
+
device_name: '/dev/sda',
|
27
|
+
ebs: {
|
28
|
+
volume_id: 'vol-123a123b'
|
29
|
+
}
|
30
|
+
}
|
31
|
+
],
|
32
|
+
tags: [
|
33
|
+
{
|
34
|
+
key: 'Name',
|
35
|
+
value: 'my-ec2'
|
36
|
+
}
|
37
|
+
]
|
38
|
+
}
|
39
|
+
]
|
40
|
+
}
|
41
|
+
]
|
42
|
+
},
|
43
|
+
describe_volumes: {
|
44
|
+
volumes: [
|
45
|
+
{
|
46
|
+
volume_id: 'vpc-ab123cde',
|
47
|
+
state: 'in-use',
|
48
|
+
size: 100,
|
49
|
+
attachments: [
|
50
|
+
{
|
51
|
+
instance_id: 'i-ec12345a',
|
52
|
+
volume_id: 'vpc-ab123cde',
|
53
|
+
state: 'attached'
|
54
|
+
}
|
55
|
+
],
|
56
|
+
tags: [
|
57
|
+
{
|
58
|
+
key: 'Name',
|
59
|
+
value: 'my-volume'
|
60
|
+
}
|
61
|
+
]
|
62
|
+
}
|
63
|
+
]
|
64
|
+
}
|
65
|
+
}
|
66
|
+
}
|
@@ -0,0 +1,117 @@
|
|
1
|
+
Aws.config[:ec2] = {
|
2
|
+
stub_responses: {
|
3
|
+
describe_instances: {
|
4
|
+
reservations: [
|
5
|
+
{
|
6
|
+
instances: [
|
7
|
+
{
|
8
|
+
instance_id: 'i-ec12345a',
|
9
|
+
image_id: 'ami-abc12def',
|
10
|
+
vpc_id: 'vpc-ab123cde',
|
11
|
+
subnet_id: 'subnet-1234a567',
|
12
|
+
public_ip_address: '123.0.456.789',
|
13
|
+
private_ip_address: '10.0.1.1',
|
14
|
+
instance_type: 't2.small',
|
15
|
+
state: {
|
16
|
+
name: 'running'
|
17
|
+
},
|
18
|
+
security_groups: [
|
19
|
+
{
|
20
|
+
group_id: 'sg-1a2b3cd4',
|
21
|
+
group_name: 'my-security-group-name'
|
22
|
+
}
|
23
|
+
],
|
24
|
+
block_device_mappings: [
|
25
|
+
{
|
26
|
+
device_name: '/dev/sda',
|
27
|
+
ebs: {
|
28
|
+
volume_id: 'vol-123a123b'
|
29
|
+
}
|
30
|
+
}
|
31
|
+
],
|
32
|
+
tags: [
|
33
|
+
{
|
34
|
+
key: 'Name',
|
35
|
+
value: 'my-ec2'
|
36
|
+
}
|
37
|
+
]
|
38
|
+
}
|
39
|
+
]
|
40
|
+
}
|
41
|
+
]
|
42
|
+
},
|
43
|
+
describe_vpcs: {
|
44
|
+
vpcs: [
|
45
|
+
{
|
46
|
+
vpc_id: 'vpc-ab123cde',
|
47
|
+
tags: [
|
48
|
+
{
|
49
|
+
key: 'Name',
|
50
|
+
value: 'my-vpc'
|
51
|
+
}
|
52
|
+
]
|
53
|
+
}
|
54
|
+
]
|
55
|
+
},
|
56
|
+
describe_subnets: {
|
57
|
+
subnets: [
|
58
|
+
{
|
59
|
+
state: 'available',
|
60
|
+
vpc_id: 'vpc-ab123cde',
|
61
|
+
subnet_id: 'subnet-1234a567',
|
62
|
+
cidr_block: '10.0.1.0/24',
|
63
|
+
tags: [
|
64
|
+
{
|
65
|
+
key: 'Name',
|
66
|
+
value: 'my-subnet'
|
67
|
+
}
|
68
|
+
]
|
69
|
+
}
|
70
|
+
]
|
71
|
+
},
|
72
|
+
describe_addresses: {
|
73
|
+
addresses: [
|
74
|
+
{
|
75
|
+
public_ip: '123.0.456.789',
|
76
|
+
instance_id: 'i-ec12345a'
|
77
|
+
}
|
78
|
+
]
|
79
|
+
},
|
80
|
+
describe_security_groups: {
|
81
|
+
security_groups: [
|
82
|
+
{
|
83
|
+
group_id: 'sg-1a2b3cd4',
|
84
|
+
group_name: 'my-security-group-name',
|
85
|
+
tags: [
|
86
|
+
{
|
87
|
+
key: 'Name',
|
88
|
+
value: 'my-security-group-tag-name'
|
89
|
+
}
|
90
|
+
]
|
91
|
+
}
|
92
|
+
]
|
93
|
+
},
|
94
|
+
describe_volumes: {
|
95
|
+
volumes: [
|
96
|
+
{
|
97
|
+
volume_id: 'vpc-ab123cde',
|
98
|
+
state: 'in-use',
|
99
|
+
size: 100,
|
100
|
+
attachments: [
|
101
|
+
{
|
102
|
+
instance_id: 'i-ec12345a',
|
103
|
+
volume_id: 'vpc-ab123cde',
|
104
|
+
state: 'attached'
|
105
|
+
}
|
106
|
+
],
|
107
|
+
tags: [
|
108
|
+
{
|
109
|
+
key: 'Name',
|
110
|
+
value: 'my-volume'
|
111
|
+
}
|
112
|
+
]
|
113
|
+
}
|
114
|
+
]
|
115
|
+
}
|
116
|
+
}
|
117
|
+
}
|