sparkle-pack-aws-vpc 0.1.0
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/lib/sparkle-pack-aws-vpc.rb +1 -0
- data/lib/sparkleformation/components/base.rb +9 -0
- data/lib/sparkleformation/components/vpc.rb +124 -0
- data/lib/sparkleformation/dynamics/security_group.rb +79 -0
- data/lib/sparkleformation/dynamics/vpc_nat_routing.rb +27 -0
- data/lib/sparkleformation/dynamics/vpc_subnet.rb +33 -0
- data/sparkle-pack-aws-vpc.gemspec +12 -0
- metadata +66 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 0db74389ca7a47f5556e4276a3f21774169a3dca
|
4
|
+
data.tar.gz: 35026fcd1afda361f4587ec7ea8a092b7710a2d4
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: 3345ea844a987c88767da99527e433b4226dc4d4d610bd1a2643fc39c35e4c44d7bd7f68b7a722bb468f4dce174a8097d5fb3c446dc1bb0af58adbb6434ead66
|
7
|
+
data.tar.gz: 0aa72f84534e521bec04dfa4db72cde2cfe8d62488a21171e860bd545f074df340061f66abd68cc3517876ea800a309178cb05c18c0c72b01d83b3810167b85b
|
@@ -0,0 +1 @@
|
|
1
|
+
SparkleFormation::SparklePack.register!
|
@@ -0,0 +1,124 @@
|
|
1
|
+
SparkleFormation.component(:vpc) do |_config ={}|
|
2
|
+
|
3
|
+
parameters(:vpc_cidr) do
|
4
|
+
description 'VPC Subnet'
|
5
|
+
type 'String'
|
6
|
+
default '10.0.0.0/16'
|
7
|
+
end
|
8
|
+
|
9
|
+
parameters(:dns_support) do
|
10
|
+
description 'Enable VPC DNS Support'
|
11
|
+
type 'String'
|
12
|
+
default 'true'
|
13
|
+
allowed_values %w(true false)
|
14
|
+
end
|
15
|
+
|
16
|
+
parameters(:dns_hostnames) do
|
17
|
+
description 'Enable VPC DNS Hostname Support'
|
18
|
+
type 'String'
|
19
|
+
default 'true'
|
20
|
+
allowed_values %w(true false)
|
21
|
+
end
|
22
|
+
|
23
|
+
parameters(:instance_tenancy) do
|
24
|
+
description 'Enable VPC Instance Tenancy'
|
25
|
+
type 'String'
|
26
|
+
default 'default'
|
27
|
+
allowed_values %w(default dedicated)
|
28
|
+
end
|
29
|
+
|
30
|
+
resources(:dhcp_options) do
|
31
|
+
type 'AWS::EC2::DHCPOptions'
|
32
|
+
properties do
|
33
|
+
domain_name 'ec2.internal'
|
34
|
+
domain_name_servers ['AmazonProvidedDNS']
|
35
|
+
tags _array(
|
36
|
+
-> {
|
37
|
+
key 'Name'
|
38
|
+
value stack_name!
|
39
|
+
}
|
40
|
+
)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
resources(:vpc) do
|
45
|
+
type 'AWS::EC2::VPC'
|
46
|
+
properties do
|
47
|
+
cidr_block ref!(:vpc_cidr)
|
48
|
+
enable_dns_support ref!(:dns_support)
|
49
|
+
enable_dns_hostnames ref!(:dns_hostnames)
|
50
|
+
instance_tenancy ref!(:instance_tenancy)
|
51
|
+
tags _array(
|
52
|
+
-> {
|
53
|
+
key 'Name'
|
54
|
+
value stack_name!
|
55
|
+
}
|
56
|
+
)
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
resources(:vpc_dhcp_options_association) do
|
61
|
+
type 'AWS::EC2::VPCDHCPOptionsAssociation'
|
62
|
+
properties do
|
63
|
+
vpc_id ref!(:vpc)
|
64
|
+
dhcp_options_id ref!(:dhcp_options)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
|
68
|
+
%w( public private ).each do |type|
|
69
|
+
resources("#{type}_route_table".to_sym) do
|
70
|
+
type 'AWS::EC2::RouteTable'
|
71
|
+
properties do
|
72
|
+
vpc_id ref!(:vpc)
|
73
|
+
tags _array(
|
74
|
+
-> {
|
75
|
+
key 'Name'
|
76
|
+
value join!(stack_name!, " #{type}")
|
77
|
+
}
|
78
|
+
)
|
79
|
+
end
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
resources(:internet_gateway) do
|
84
|
+
type 'AWS::EC2::InternetGateway'
|
85
|
+
properties do
|
86
|
+
tags _array(
|
87
|
+
-> {
|
88
|
+
key 'Name'
|
89
|
+
value stack_name!
|
90
|
+
}
|
91
|
+
)
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
resources(:internet_gateway_attachment) do
|
96
|
+
type 'AWS::EC2::VPCGatewayAttachment'
|
97
|
+
properties do
|
98
|
+
internet_gateway_id ref!(:internet_gateway)
|
99
|
+
vpc_id ref!(:vpc)
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
resources(:public_subnet_internet_route) do
|
104
|
+
type 'AWS::EC2::Route'
|
105
|
+
properties do
|
106
|
+
destination_cidr_block '0.0.0.0/0'
|
107
|
+
gateway_id ref!(:internet_gateway)
|
108
|
+
route_table_id ref!(:public_route_table)
|
109
|
+
end
|
110
|
+
end
|
111
|
+
|
112
|
+
outputs(:vpc_id) do
|
113
|
+
value ref!(:vpc)
|
114
|
+
end
|
115
|
+
|
116
|
+
[ :vpc_cidr, :public_route_table, :private_route_table, :internet_gateway ].each do |x|
|
117
|
+
outputs do
|
118
|
+
set!(x) do
|
119
|
+
value ref!(x)
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
end
|
@@ -0,0 +1,79 @@
|
|
1
|
+
SparkleFormation.dynamic(:security_group_with_rules) do |_name, _config = {}|
|
2
|
+
|
3
|
+
## Usage:
|
4
|
+
##
|
5
|
+
## Security Group rules are defined via 'ingress' and 'egress'
|
6
|
+
## hashes of named rules passed in the _config argument. Each rule
|
7
|
+
## supports the following keys:
|
8
|
+
##
|
9
|
+
## :protocol (required) - the protocol ('tcp', 'udp', '-1')
|
10
|
+
## :ports (required) - an array of 1 or 2 port numbers. If specifying
|
11
|
+
## a range, the lower port must be first.
|
12
|
+
## :source_group/:destination_group (optional) - a Security Group to
|
13
|
+
## grant ingress (source) or egress (destination) access to. If not
|
14
|
+
## specified, assumes a CIDR block.
|
15
|
+
## :cidr_ip (optional) - The CIDR block the rule applies to. If
|
16
|
+
## neither a source/destination group nor a CIDR block is passed,
|
17
|
+
## defaults to allow all (0.0.0.0/0).
|
18
|
+
|
19
|
+
|
20
|
+
rules = _config.fetch(:rules, {})
|
21
|
+
|
22
|
+
resources do
|
23
|
+
|
24
|
+
set!("#{_name}_security_group") do
|
25
|
+
type 'AWS::EC2::SecurityGroup'
|
26
|
+
properties do
|
27
|
+
group_description "Security Group for #{_name}"
|
28
|
+
vpc_id _config.fetch(:vpc_id, ref!(:vpc_id))
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
if _config[:ingress]
|
33
|
+
|
34
|
+
_config[:ingress].each do |rule, settings|
|
35
|
+
|
36
|
+
ports = [ settings[:ports] ].flatten
|
37
|
+
|
38
|
+
set!("#{_name}_#{rule}_security_group_ingress") do
|
39
|
+
type 'AWS::EC2::SecurityGroupIngress'
|
40
|
+
properties do
|
41
|
+
group_id ref!("#{_name}_security_group".to_sym)
|
42
|
+
ip_protocol settings[:protocol]
|
43
|
+
from_port ports.first
|
44
|
+
to_port ports.last
|
45
|
+
if settings[:source_group]
|
46
|
+
source_security_group_id settings[:source_group]
|
47
|
+
else
|
48
|
+
cidr_ip settings.fetch(:cidr_ip, '0.0.0.0/0')
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
if _config[:egress]
|
56
|
+
|
57
|
+
_config[:egress].each do |rule, settings|
|
58
|
+
|
59
|
+
ports = [ settings[:ports] ].flatten
|
60
|
+
|
61
|
+
set!("#{_name}_#{rule}_security_group_egress") do
|
62
|
+
type 'AWS::EC2::SecurityGroupEgress'
|
63
|
+
properties do
|
64
|
+
group_id ref!("#{_name}_security_group".to_sym)
|
65
|
+
ip_protocol settings[:protocol]
|
66
|
+
from_port ports.first
|
67
|
+
to_port ports.last
|
68
|
+
if settings[:destination_group]
|
69
|
+
destination_security_group_id settings[:destination_group]
|
70
|
+
else
|
71
|
+
cidr_ip settings.fetch(:cidr_ip, '0.0.0.0/0')
|
72
|
+
end
|
73
|
+
end
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
SparkleFormation.dynamic(:vpc_nat_routing) do |_name, _config = {}|
|
2
|
+
|
3
|
+
resources("#{_name}_nat_eip".to_sym) do
|
4
|
+
type 'AWS::EC2::EIP'
|
5
|
+
properties do
|
6
|
+
domain 'vpc'
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
resources("#{_name}_nat_gateway".to_sym) do
|
11
|
+
type 'AWS::EC2::NatGateway'
|
12
|
+
properties do
|
13
|
+
allocation_id attr!("#{_name}_nat_eip".to_sym, :allocation_id)
|
14
|
+
subnet_id _config.fetch(:nat_subnet)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
resources("#{_name}_nat_route".to_sym) do
|
19
|
+
type 'AWS::EC2::Route'
|
20
|
+
depends_on process_key!("#{_name}_nat_gateway".to_sym)
|
21
|
+
properties do
|
22
|
+
route_table_id _config.fetch(:nat_route_table)
|
23
|
+
destination_cidr_block _config.fetch(:nat_destination, '0.0.0.0/0')
|
24
|
+
nat_gateway_id ref!("#{_name}_nat_gateway".to_sym)
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
SparkleFormation.dynamic(:vpc_subnet) do |_name, _config = {}|
|
2
|
+
|
3
|
+
parameters("#{_name}_subnet_cidr".to_sym) do
|
4
|
+
type 'String'
|
5
|
+
end
|
6
|
+
|
7
|
+
resources("#{_name}_subnet".to_sym) do
|
8
|
+
type 'AWS::EC2::Subnet'
|
9
|
+
properties do
|
10
|
+
vpc_id _config[:vpc_id]
|
11
|
+
cidr_block ref!("#{_name}_subnet_cidr".to_sym)
|
12
|
+
availability_zone _config[:availability_zone]
|
13
|
+
tags _array(
|
14
|
+
-> {
|
15
|
+
key 'Name'
|
16
|
+
value join!(ref!('AWS::StackName'), " #{_name}")
|
17
|
+
}
|
18
|
+
)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
resources("#{_name}_subnet_route_table_association".to_sym) do
|
23
|
+
type 'AWS::EC2::SubnetRouteTableAssociation'
|
24
|
+
properties do
|
25
|
+
route_table_id _config[:route_table]
|
26
|
+
subnet_id ref!("#{_name}_subnet".to_sym)
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
outputs("#{_name}_subnet".to_sym) do
|
31
|
+
value ref!("#{_name}_subnet".to_sym)
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
Gem::Specification.new do |s|
|
2
|
+
s.name = 'sparkle-pack-aws-vpc'
|
3
|
+
s.version = '0.1.0'
|
4
|
+
s.licenses = ['MIT']
|
5
|
+
s.summary = 'AWS VPC SparklePack'
|
6
|
+
s.description = 'SparklePack to create a VPC on AWS'
|
7
|
+
s.authors = ['Cameron Johnston', 'Michael F. Weinberg']
|
8
|
+
s.email = 'support@heavywater.io'
|
9
|
+
s.homepage = 'http://sparkleformation.io'
|
10
|
+
s.files = Dir[ 'lib/sparkleformation/*/*' ] + %w(sparkle-pack-aws-vpc.gemspec lib/sparkle-pack-aws-vpc.rb)
|
11
|
+
s.add_runtime_dependency 'sparkle-pack-aws-availability-zones'
|
12
|
+
end
|
metadata
ADDED
@@ -0,0 +1,66 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: sparkle-pack-aws-vpc
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Cameron Johnston
|
8
|
+
- Michael F. Weinberg
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2016-03-16 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: sparkle-pack-aws-availability-zones
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - ">="
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: '0'
|
21
|
+
type: :runtime
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - ">="
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: '0'
|
28
|
+
description: SparklePack to create a VPC on AWS
|
29
|
+
email: support@heavywater.io
|
30
|
+
executables: []
|
31
|
+
extensions: []
|
32
|
+
extra_rdoc_files: []
|
33
|
+
files:
|
34
|
+
- lib/sparkle-pack-aws-vpc.rb
|
35
|
+
- lib/sparkleformation/components/base.rb
|
36
|
+
- lib/sparkleformation/components/vpc.rb
|
37
|
+
- lib/sparkleformation/dynamics/security_group.rb
|
38
|
+
- lib/sparkleformation/dynamics/vpc_nat_routing.rb
|
39
|
+
- lib/sparkleformation/dynamics/vpc_subnet.rb
|
40
|
+
- sparkle-pack-aws-vpc.gemspec
|
41
|
+
homepage: http://sparkleformation.io
|
42
|
+
licenses:
|
43
|
+
- MIT
|
44
|
+
metadata: {}
|
45
|
+
post_install_message:
|
46
|
+
rdoc_options: []
|
47
|
+
require_paths:
|
48
|
+
- lib
|
49
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - ">="
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
55
|
+
requirements:
|
56
|
+
- - ">="
|
57
|
+
- !ruby/object:Gem::Version
|
58
|
+
version: '0'
|
59
|
+
requirements: []
|
60
|
+
rubyforge_project:
|
61
|
+
rubygems_version: 2.2.2
|
62
|
+
signing_key:
|
63
|
+
specification_version: 4
|
64
|
+
summary: AWS VPC SparklePack
|
65
|
+
test_files: []
|
66
|
+
has_rdoc:
|