convection 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.gitignore +17 -0
- data/.rubocop.yml +16 -0
- data/Gemfile +4 -0
- data/LICENSE +23 -0
- data/README.md +224 -0
- data/Rakefile +2 -0
- data/Thorfile +5 -0
- data/convection.gemspec +27 -0
- data/example/iam_role.rb +63 -0
- data/example/s3.rb +13 -0
- data/example/vpc.rb +85 -0
- data/lib/convection.rb +18 -0
- data/lib/convection/control/stack.rb +165 -0
- data/lib/convection/dsl/helpers.rb +15 -0
- data/lib/convection/dsl/intrinsic_functions.rb +79 -0
- data/lib/convection/model/mixin/cidr_block.rb +17 -0
- data/lib/convection/model/mixin/conditional.rb +21 -0
- data/lib/convection/model/mixin/taggable.rb +48 -0
- data/lib/convection/model/template.rb +127 -0
- data/lib/convection/model/template/mapping.rb +42 -0
- data/lib/convection/model/template/output.rb +37 -0
- data/lib/convection/model/template/parameter.rb +44 -0
- data/lib/convection/model/template/resource.rb +64 -0
- data/lib/convection/model/template/resource/aws_ec2_instance.rb +69 -0
- data/lib/convection/model/template/resource/aws_ec2_internet_gateway.rb +55 -0
- data/lib/convection/model/template/resource/aws_ec2_route.rb +55 -0
- data/lib/convection/model/template/resource/aws_ec2_route_table.rb +60 -0
- data/lib/convection/model/template/resource/aws_ec2_security_group.rb +104 -0
- data/lib/convection/model/template/resource/aws_ec2_subnet.rb +66 -0
- data/lib/convection/model/template/resource/aws_ec2_subnet_route_table_association.rb +39 -0
- data/lib/convection/model/template/resource/aws_ec2_vpc.rb +116 -0
- data/lib/convection/model/template/resource/aws_ec2_vpc_gateway_attachment.rb +43 -0
- data/lib/convection/model/template/resource/aws_iam_policy.rb +45 -0
- data/lib/convection/model/template/resource/aws_iam_role.rb +45 -0
- data/lib/convection/model/template/resource/aws_s3_bucket.rb +67 -0
- data/lib/convection/model/template/resource/aws_s3_bucket_policy.rb +40 -0
- data/lib/convection/version.rb +6 -0
- metadata +375 -0
@@ -0,0 +1,66 @@
|
|
1
|
+
require_relative '../resource'
|
2
|
+
require_relative 'aws_ec2_subnet_route_table_association'
|
3
|
+
|
4
|
+
module Convection
|
5
|
+
|
6
|
+
module DSL
|
7
|
+
## Add DSL method to template namespace
|
8
|
+
module Template
|
9
|
+
def ec2_subnet(name, &block)
|
10
|
+
r = Model::Template::Resource::EC2Subnet.new(name, self)
|
11
|
+
|
12
|
+
r.instance_exec(&block) if block
|
13
|
+
resources[name] = r
|
14
|
+
end
|
15
|
+
|
16
|
+
module Resource
|
17
|
+
##
|
18
|
+
# Add DSL for RouteTableAssocaition
|
19
|
+
module EC2Subnet
|
20
|
+
def associate_route_table(table, &block)
|
21
|
+
r = Model::Template::Resource::EC2SubnetRouteTableAssociation.new("#{ name }RouteTableAssociation#{ table.name }", @tamplate)
|
22
|
+
r.route_table(table.reference)
|
23
|
+
r.subnet(reference)
|
24
|
+
|
25
|
+
r.instance_exec(&block) if block
|
26
|
+
@template.resources[r.name] = r
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
module Model
|
34
|
+
class Template
|
35
|
+
class Resource
|
36
|
+
##
|
37
|
+
# AWS::EC2::Subnet
|
38
|
+
##
|
39
|
+
class EC2Subnet < Resource
|
40
|
+
include DSL::Template::Resource::EC2Subnet
|
41
|
+
include Model::Mixin::CIDRBlock
|
42
|
+
include Model::Mixin::Taggable
|
43
|
+
|
44
|
+
def initialize(*args)
|
45
|
+
super
|
46
|
+
type 'AWS::EC2::Subnet'
|
47
|
+
end
|
48
|
+
|
49
|
+
def availability_zone(value)
|
50
|
+
property('AvailabilityZone', value)
|
51
|
+
end
|
52
|
+
|
53
|
+
def vpc_id(value)
|
54
|
+
property('VpcId', value)
|
55
|
+
end
|
56
|
+
|
57
|
+
def render(*args)
|
58
|
+
super.tap do |resource|
|
59
|
+
render_tags(resource)
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
require_relative '../resource'
|
2
|
+
|
3
|
+
module Convection
|
4
|
+
module Model
|
5
|
+
class Template
|
6
|
+
class Resource
|
7
|
+
##
|
8
|
+
# AWS::EC2::SubnetRouteTableAssociation
|
9
|
+
##
|
10
|
+
class EC2SubnetRouteTableAssociation < Resource
|
11
|
+
def initialize(*args)
|
12
|
+
super
|
13
|
+
type 'AWS::EC2::SubnetRouteTableAssociation'
|
14
|
+
end
|
15
|
+
|
16
|
+
def route_table(value)
|
17
|
+
property('RouteTableId', value)
|
18
|
+
end
|
19
|
+
|
20
|
+
def subnet(value)
|
21
|
+
property('SubnetId', value)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
module DSL
|
29
|
+
## Add DSL method to template namespace
|
30
|
+
module Template
|
31
|
+
def ec2_subnet_route_table_association(name, &block)
|
32
|
+
r = Model::Template::Resource::EC2SubnetRouteTableAssociation.new(name, self)
|
33
|
+
|
34
|
+
r.instance_exec(&block) if block
|
35
|
+
resources[name] = r
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,116 @@
|
|
1
|
+
require_relative '../resource'
|
2
|
+
|
3
|
+
module Convection
|
4
|
+
module DSL
|
5
|
+
## Add DSL method to template namespace
|
6
|
+
module Template
|
7
|
+
def ec2_vpc(name, &block)
|
8
|
+
r = Model::Template::Resource::EC2VPC.new(name, self)
|
9
|
+
|
10
|
+
r.instance_exec(&block) if block
|
11
|
+
resources[name] = r
|
12
|
+
end
|
13
|
+
|
14
|
+
module Resource
|
15
|
+
##
|
16
|
+
# DSL For VPC sub-entities
|
17
|
+
##
|
18
|
+
module EC2VPC
|
19
|
+
def stack
|
20
|
+
@template.stack
|
21
|
+
end
|
22
|
+
|
23
|
+
def add_internet_gateway(&block)
|
24
|
+
g = Model::Template::Resource::EC2InternetGateway.new("#{ name }IG", @template)
|
25
|
+
g.attach_to_vpc(self)
|
26
|
+
g.tag('Name', "#{ name }InternetGateway")
|
27
|
+
|
28
|
+
g.instance_exec(&block) if block
|
29
|
+
@template.resources[g.name] = g
|
30
|
+
|
31
|
+
## Store the gateway for later reference
|
32
|
+
@internet_gateway = g
|
33
|
+
end
|
34
|
+
|
35
|
+
def add_route_table(name, options = {}, &block)
|
36
|
+
route_table = Model::Template::Resource::EC2RouteTable.new("#{ self.name }Table#{ name }", @template)
|
37
|
+
route_table.vpc_id(self)
|
38
|
+
route_table.tag('Name', route_table.name)
|
39
|
+
|
40
|
+
route_table.instance_exec(&block) if block
|
41
|
+
|
42
|
+
@template.resources[route_table.name] = route_table
|
43
|
+
return route_table unless options[:gateway_route]
|
44
|
+
|
45
|
+
## Create and associate an InterntGateway
|
46
|
+
add_internet_gateway if @internet_gateway.nil?
|
47
|
+
|
48
|
+
## Create a route to the VPC's InternetGateway
|
49
|
+
vpc_default_route = route_table.route('Default')
|
50
|
+
vpc_default_route.destination('0.0.0.0/0')
|
51
|
+
vpc_default_route.gateway(@internet_gateway)
|
52
|
+
|
53
|
+
route_table
|
54
|
+
end
|
55
|
+
|
56
|
+
def add_subnet(name, &block)
|
57
|
+
s = Model::Template::Resource::EC2Subnet.new("#{ self.name }Subnet#{ name }", @template)
|
58
|
+
s.tag('Name', s.name)
|
59
|
+
s.vpc_id(self)
|
60
|
+
|
61
|
+
## Allocate the next available subnet
|
62
|
+
@subnet_allocated += 1
|
63
|
+
s.network(@network.subnet(
|
64
|
+
:Bits => @subnet_length,
|
65
|
+
:NumSubnets => @subnet_allocated)[@subnet_allocated - 1])
|
66
|
+
|
67
|
+
s.instance_exec(&block) if block
|
68
|
+
@template.resources[s.name] = s
|
69
|
+
end
|
70
|
+
end
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
74
|
+
|
75
|
+
module Model
|
76
|
+
class Template
|
77
|
+
class Resource
|
78
|
+
##
|
79
|
+
# AWS::EC2::VPC
|
80
|
+
##
|
81
|
+
class EC2VPC < Resource
|
82
|
+
include DSL::Template::Resource::EC2VPC
|
83
|
+
include Model::Mixin::CIDRBlock
|
84
|
+
include Model::Mixin::Taggable
|
85
|
+
|
86
|
+
attribute :subnet_length
|
87
|
+
|
88
|
+
def initialize(*args)
|
89
|
+
super
|
90
|
+
|
91
|
+
type 'AWS::EC2::VPC'
|
92
|
+
@subnet_allocated = 0
|
93
|
+
@subnet_length = 24
|
94
|
+
|
95
|
+
@internet_gateway = nil
|
96
|
+
end
|
97
|
+
|
98
|
+
def enable_dns(value)
|
99
|
+
property('EnableDnsSupport', value)
|
100
|
+
property('EnableDnsHostnames', value)
|
101
|
+
end
|
102
|
+
|
103
|
+
def instance_tenancy(value)
|
104
|
+
property('InstanceTenancy', value)
|
105
|
+
end
|
106
|
+
|
107
|
+
def render(*args)
|
108
|
+
super.tap do |resource|
|
109
|
+
render_tags(resource)
|
110
|
+
end
|
111
|
+
end
|
112
|
+
end
|
113
|
+
end
|
114
|
+
end
|
115
|
+
end
|
116
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require_relative '../resource'
|
2
|
+
|
3
|
+
module Convection
|
4
|
+
module Model
|
5
|
+
class Template
|
6
|
+
class Resource
|
7
|
+
##
|
8
|
+
# AWS::EC2::VPCGatewayAttachment
|
9
|
+
##
|
10
|
+
class EC2VPCGatewayAttachment < Resource
|
11
|
+
def initialize(*args)
|
12
|
+
super
|
13
|
+
type 'AWS::EC2::VPCGatewayAttachment'
|
14
|
+
end
|
15
|
+
|
16
|
+
def vpc_id(value)
|
17
|
+
property('VpcId', value)
|
18
|
+
end
|
19
|
+
|
20
|
+
def internet_gateway(value)
|
21
|
+
property('InternetGatewayId', value)
|
22
|
+
end
|
23
|
+
|
24
|
+
def vpn_gateway(value)
|
25
|
+
property('VpnGatewayId', value)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
module DSL
|
33
|
+
## Add DSL method to template namespace
|
34
|
+
module Template
|
35
|
+
def ec2_vpc_gateway_attachment(name, &block)
|
36
|
+
r = Model::Template::Resource::EC2VPCGatewayAttachment.new(name, self)
|
37
|
+
|
38
|
+
r.instance_exec(&block) if block
|
39
|
+
resources[name] = r
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require_relative '../resource'
|
2
|
+
|
3
|
+
module Convection
|
4
|
+
module DSL
|
5
|
+
## Add DSL method to template namespace
|
6
|
+
module Template
|
7
|
+
def iam_policy(name, &block)
|
8
|
+
r = Model::Template::Resource::IAMPolicy.new(name, self)
|
9
|
+
r.instance_exec(&block) if block
|
10
|
+
|
11
|
+
resources[name] = r
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
module Model
|
17
|
+
class Template
|
18
|
+
class Resource
|
19
|
+
##
|
20
|
+
# AWS::IAM::Policy
|
21
|
+
##
|
22
|
+
class IAMPolicy < Resource
|
23
|
+
def initialize(*args)
|
24
|
+
super
|
25
|
+
|
26
|
+
type 'AWS::IAM::Policy'
|
27
|
+
@properties['Roles'] = []
|
28
|
+
end
|
29
|
+
|
30
|
+
def role(value)
|
31
|
+
@properties['Roles'] << value
|
32
|
+
end
|
33
|
+
|
34
|
+
def name(value)
|
35
|
+
property('PolicyName', value)
|
36
|
+
end
|
37
|
+
|
38
|
+
def policy_document(value)
|
39
|
+
property('PolicyDocument', value)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,45 @@
|
|
1
|
+
require_relative '../resource'
|
2
|
+
|
3
|
+
module Convection
|
4
|
+
module DSL
|
5
|
+
## Add DSL method to template namespace
|
6
|
+
module Template
|
7
|
+
def iam_role(name, &block)
|
8
|
+
r = Model::Template::Resource::IAMRole.new(name, self)
|
9
|
+
r.instance_exec(&block) if block
|
10
|
+
|
11
|
+
resources[name] = r
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
module Model
|
17
|
+
class Template
|
18
|
+
class Resource
|
19
|
+
##
|
20
|
+
# AWS::IAM::Role
|
21
|
+
##
|
22
|
+
class IAMRole < Resource
|
23
|
+
def initialize(*args)
|
24
|
+
super
|
25
|
+
|
26
|
+
type 'AWS::IAM::Role'
|
27
|
+
@properties['Policies'] = []
|
28
|
+
end
|
29
|
+
|
30
|
+
def path(value)
|
31
|
+
property('Path', value)
|
32
|
+
end
|
33
|
+
|
34
|
+
def policies(value)
|
35
|
+
@properties['Policies'] << value
|
36
|
+
end
|
37
|
+
|
38
|
+
def assume_role_policy_document(value)
|
39
|
+
property('AssumeRolePolicyDocument', value)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
require_relative '../resource'
|
2
|
+
|
3
|
+
module Convection
|
4
|
+
module Model
|
5
|
+
class Template
|
6
|
+
class Resource
|
7
|
+
##
|
8
|
+
# AWS::S3::Bucket
|
9
|
+
##
|
10
|
+
class S3Bucket < Resource
|
11
|
+
include Model::Mixin::Taggable
|
12
|
+
|
13
|
+
def initialize(*args)
|
14
|
+
super
|
15
|
+
type 'AWS::S3::Bucket'
|
16
|
+
end
|
17
|
+
|
18
|
+
def access_control(value)
|
19
|
+
property('AccessControl', value)
|
20
|
+
end
|
21
|
+
|
22
|
+
def bucket_name(value)
|
23
|
+
property('BucketName', value)
|
24
|
+
end
|
25
|
+
|
26
|
+
def cors_configuration(value)
|
27
|
+
property('CorsConfiguration', value)
|
28
|
+
end
|
29
|
+
|
30
|
+
def lifecycle_configuration(value)
|
31
|
+
property('LifecycleConfiguration', value)
|
32
|
+
end
|
33
|
+
|
34
|
+
def logging_configuration(value)
|
35
|
+
property('LoggingConfiguration', value)
|
36
|
+
end
|
37
|
+
|
38
|
+
def notification_configuration(value)
|
39
|
+
property('NotificationConfiguration', value)
|
40
|
+
end
|
41
|
+
|
42
|
+
def version_configuration(value)
|
43
|
+
property('VersionConfiguration', value)
|
44
|
+
end
|
45
|
+
|
46
|
+
def render(*args)
|
47
|
+
super.tap do |resource|
|
48
|
+
render_tags(resource)
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
module DSL
|
57
|
+
## Add DSL method to template namespace
|
58
|
+
module Template
|
59
|
+
def s3_bucket(name, &block)
|
60
|
+
r = Model::Template::Resource::S3Bucket.new(name, self)
|
61
|
+
|
62
|
+
r.instance_exec(&block) if block
|
63
|
+
resources[name] = r
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
require_relative '../resource'
|
2
|
+
|
3
|
+
module Convection
|
4
|
+
module Model
|
5
|
+
class Template
|
6
|
+
class Resource
|
7
|
+
##
|
8
|
+
# AWS::S3::BucketPolicy
|
9
|
+
##
|
10
|
+
class S3BucketPolicy < Resource
|
11
|
+
|
12
|
+
def initialize(*args)
|
13
|
+
super
|
14
|
+
type 'AWS::S3::BucketPolicy'
|
15
|
+
end
|
16
|
+
|
17
|
+
def bucket(value)
|
18
|
+
property('Bucket', value)
|
19
|
+
end
|
20
|
+
|
21
|
+
def policy_document(value)
|
22
|
+
property('PolicyDocument', value)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
module DSL
|
30
|
+
## Add DSL method to template namespace
|
31
|
+
module Template
|
32
|
+
def s3_bucket_policy(name, &block)
|
33
|
+
r = Model::Template::Resource::S3BucketPolicy.new(name, self)
|
34
|
+
|
35
|
+
r.instance_exec(&block) if block
|
36
|
+
resources[name] = r
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|