sparkle_formation 0.2.2 → 0.2.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +6 -0
  3. data/README.md +7 -1
  4. data/bin/generate_sparkle_docs +31 -0
  5. data/lib/sparkle_formation/aws.rb +6 -7
  6. data/lib/sparkle_formation/sparkle_attribute.rb +97 -0
  7. data/lib/sparkle_formation/translation/heat.rb +184 -2
  8. data/lib/sparkle_formation/translation/rackspace.rb +7 -3
  9. data/lib/sparkle_formation/translation.rb +28 -2
  10. data/lib/sparkle_formation/version.rb +1 -1
  11. data/sparkle_formation.gemspec +2 -1
  12. metadata +5 -33
  13. data/CONTRIBUTING.md +0 -25
  14. data/Gemfile +0 -3
  15. data/Gemfile.lock +0 -18
  16. data/bin/aws_resources +0 -85
  17. data/bin/heat_resources +0 -33
  18. data/docs/README.md +0 -177
  19. data/docs/anatomy.md +0 -203
  20. data/docs/building-blocks.md +0 -275
  21. data/docs/examples/cloudformation/components/base.rb +0 -25
  22. data/docs/examples/cloudformation/dynamics/elb.rb +0 -23
  23. data/docs/examples/cloudformation/templates/website.rb +0 -30
  24. data/docs/examples/template_json/website.json +0 -88
  25. data/docs/examples/website.rb +0 -74
  26. data/docs/functions.md +0 -41
  27. data/docs/properties.md +0 -32
  28. data/docs/provisioning.md +0 -82
  29. data/docs/resource-reference.md +0 -49
  30. data/examples/allinone/cloudformation/ec2_example.rb +0 -59
  31. data/examples/allinone/parse.rb +0 -14
  32. data/examples/ami_component/cloudformation/components/ami.rb +0 -21
  33. data/examples/ami_component/cloudformation/ec2_example.rb +0 -39
  34. data/examples/ami_component/parse.rb +0 -14
  35. data/test/spec.rb +0 -6
  36. data/test/specs/attribute.rb +0 -72
  37. data/test/specs/basic.rb +0 -76
  38. data/test/specs/cloudformation/components/ami.rb +0 -14
  39. data/test/specs/cloudformation/dynamics/node.rb +0 -16
  40. data/test/specs/results/base.json +0 -43
  41. data/test/specs/results/base_with_map.json +0 -50
  42. data/test/specs/results/component.json +0 -27
@@ -1,49 +0,0 @@
1
- ## Resource Reference
2
-
3
- This is a best-effort list of commonly used cloudformation resources and their
4
- availability/feature set in supported cloud providers. This list does
5
- not cover everything that may be offered by a specific provider, and
6
- is not intended as a comparison of cloud providers.
7
-
8
- #### Auto Scaling Groups
9
-
10
- |Provider |Available |Caveats & Limitations |
11
- |------------|----------|-----------------------------------------------------------------------------|
12
- |AWS |Yes |EC2 Classic and VPC use mutually exclusive properties. |
13
- |Rackspace |Yes |Autoscaling will not replace lost instances, only does policy based scaling. |
14
-
15
- #### Compute Instances
16
-
17
- |Provider |Available |Caveats & Limitations |
18
- |------------|----------|-----------------------------------------------------------------------------|
19
- |AWS |Yes | |
20
- |Rackspace |Yes | |
21
-
22
- #### Load Balancers
23
-
24
- |Provider |Available |Caveats & Limitations |
25
- |------------|----------|-----------------------------------------------------------------------------|
26
- |AWS |Yes |Security Group Ingress is not automatic. Must be defined separately. |
27
- |Rackspace |Yes |Multiple ports generates new template resources. |
28
-
29
- #### Security Groups
30
-
31
- |Provider |Available |Caveats & Limitations |
32
- |------------|----------|-----------------------------------------------------------------------------|
33
- |AWS |Yes | |
34
- |Rackspace |No | |
35
-
36
- #### Storage
37
-
38
- |Provider |Available |Caveats & Limitations |
39
- |------------|----------|-----------------------------------------------------------------------------|
40
- |AWS |Yes | |
41
- |Rackspace |No | |
42
-
43
-
44
- #### Stack Users
45
-
46
- |Provider |Available |Caveats & Limitations |
47
- |------------|----------|-----------------------------------------------------------------------------|
48
- |AWS |Yes | |
49
- |Rackspace |No | |
@@ -1,59 +0,0 @@
1
- SparkleFormation.new('ec2_example') do
2
- description "AWS CloudFormation Sample Template EC2InstanceSample..."
3
-
4
- parameters do
5
- key_name do
6
- description 'Name of an existing EC2 KeyPair to enable SSH access to the instance'
7
- type 'String'
8
- end
9
- end
10
-
11
- mappings.region_map do
12
- _set('us-east-1', :ami => 'ami-7f418316')
13
- _set('us-east-1', :ami => 'ami-7f418316')
14
- _set('us-west-1', :ami => 'ami-951945d0')
15
- _set('us-west-2', :ami => 'ami-16fd7026')
16
- _set('eu-west-1', :ami => 'ami-24506250')
17
- _set('sa-east-1', :ami => 'ami-3e3be423')
18
- _set('ap-southeast-1', :ami => 'ami-74dda626')
19
- _set('ap-northeast-1', :ami => 'ami-dcfa4edd')
20
- end
21
-
22
- resources do
23
- my_instance do
24
- type 'AWS::EC2::Instance'
25
- properties do
26
- key_name _cf_ref(:key_name)
27
- image_id _cf_map(:region_map, 'AWS::Region', :ami)
28
- user_data _cf_base64('80')
29
- end
30
- end
31
- end
32
-
33
- outputs do
34
- instance_id do
35
- description 'InstanceId of the newly created EC2 instance'
36
- value _cf_ref(:my_instance)
37
- end
38
- az do
39
- description 'Availability Zone of the newly created EC2 instance'
40
- value _cf_attr(:my_instance, :availability_zone)
41
- end
42
- public_ip do
43
- description 'Public IP address of the newly created EC2 instance'
44
- value _cf_attr(:my_instance, :public_ip)
45
- end
46
- private_ip do
47
- description 'Private IP address of the newly created EC2 instance'
48
- value _cf_attr(:my_instance, :private_ip)
49
- end
50
- public_dns do
51
- description 'Public DNSName of the newly created EC2 instance'
52
- value _cf_attr(:my_instance, :public_dns_name)
53
- end
54
- private_dns do
55
- description 'Private DNSName of the newly created EC2 instance'
56
- value _cf_attr(:my_instance, :private_dns_name)
57
- end
58
- end
59
- end
@@ -1,14 +0,0 @@
1
- require 'sparkle_formation'
2
- require 'pp'
3
- require 'json'
4
-
5
- SparkleFormation.sparkle_path = File.join(File.dirname(__FILE__), 'cloudformation')
6
-
7
- puts JSON.pretty_generate(
8
- SparkleFormation.compile(
9
- File.join(
10
- File.dirname(__FILE__),
11
- 'cloudformation/ec2_example.rb'
12
- )
13
- )
14
- )
@@ -1,21 +0,0 @@
1
- SparkleFormation.build do
2
-
3
- parameters do
4
- key_name do
5
- description 'Name of an existing EC2 KeyPair to enable SSH access to the instance'
6
- type 'String'
7
- end
8
- end
9
-
10
- mappings.region_map do
11
- _set('us-east-1', :ami => 'ami-7f418316')
12
- _set('us-east-1', :ami => 'ami-7f418316')
13
- _set('us-west-1', :ami => 'ami-951945d0')
14
- _set('us-west-2', :ami => 'ami-16fd7026')
15
- _set('eu-west-1', :ami => 'ami-24506250')
16
- _set('sa-east-1', :ami => 'ami-3e3be423')
17
- _set('ap-southeast-1', :ami => 'ami-74dda626')
18
- _set('ap-northeast-1', :ami => 'ami-dcfa4edd')
19
- end
20
-
21
- end
@@ -1,39 +0,0 @@
1
- SparkleFormation.new('ec2_example').load(:ami).overrides do
2
-
3
- description "AWS CloudFormation Sample Template EC2InstanceSample..."
4
-
5
- dynamic!(:ec2_instance, :my) do
6
- properties do
7
- key_name ref!(:key_name)
8
- image_id map!(:region_map, 'AWS::Region', :ami)
9
- user_data base64!('80')
10
- end
11
- end
12
-
13
- outputs do
14
- instance_id do
15
- description 'InstanceId of the newly created EC2 instance'
16
- value ref!(:my_ec2_instance)
17
- end
18
- az do
19
- description 'Availability Zone of the newly created EC2 instance'
20
- value attr!(:my_ec2_instance, :availability_zone)
21
- end
22
- public_ip do
23
- description 'Public IP address of the newly created EC2 instance'
24
- value attr!(:my_ec2_instance, :public_ip)
25
- end
26
- private_ip do
27
- description 'Private IP address of the newly created EC2 instance'
28
- value attr!(:my_ec2_instance, :private_ip)
29
- end
30
- public_dns do
31
- description 'Public DNSName of the newly created EC2 instance'
32
- value attr!(:my_ec2_instance, :public_dns_name)
33
- end
34
- private_dns do
35
- description 'Private DNSName of the newly created EC2 instance'
36
- value attr!(:my_ec2_instance, :private_dns_name)
37
- end
38
- end
39
- end
@@ -1,14 +0,0 @@
1
- require 'sparkle_formation'
2
- require 'pp'
3
- require 'json'
4
-
5
- SparkleFormation.sparkle_path = File.join(File.dirname(__FILE__), 'cloudformation')
6
-
7
- puts JSON.pretty_generate(
8
- SparkleFormation.compile(
9
- File.join(
10
- File.dirname(__FILE__),
11
- 'cloudformation/ec2_example.rb'
12
- )
13
- )
14
- )
data/test/spec.rb DELETED
@@ -1,6 +0,0 @@
1
- require 'sparkle_formation'
2
- require 'minitest/autorun'
3
-
4
- Dir.glob(File.join(File.expand_path(File.dirname(__FILE__)), 'specs/*.rb')).each do |path|
5
- require path
6
- end
@@ -1,72 +0,0 @@
1
- describe SparkleFormation::SparkleAttribute do
2
-
3
- before do
4
- @attr = Object.new
5
- @attr.extend(SparkleFormation::SparkleAttribute)
6
- end
7
-
8
- it 'should generate Fn::Join' do
9
- @attr.join!('a', 'b', 'c').must_equal 'Fn::Join' => ['', ['a', 'b', 'c']]
10
- end
11
-
12
- it 'should generate Fn::Join with custom delimiter' do
13
- @attr.join!('a', 'b', 'c', :options => {:delimiter => '-'}).
14
- must_equal 'Fn::Join' => ['-', ['a', 'b', 'c']]
15
- end
16
-
17
- it 'should generate Ref' do
18
- @attr.ref!('Item').must_equal 'Ref' => 'Item'
19
- end
20
-
21
- it 'should process symbol when generating Ref' do
22
- SparkleFormation.new(:dummy) do
23
- thing ref!(:item)
24
- end.dump.must_equal 'Thing' => {'Ref' => 'Item'}
25
- end
26
-
27
- it 'should generate Fn::FindInMap' do
28
- SparkleFormation.new(:dummy) do
29
- thing find_in_map!('MyMap', 'MyKey', 'SubKey')
30
- end.dump.
31
- must_equal 'Thing' => {'Fn::FindInMap' => ['MyMap', {'Ref' => 'MyKey'}, 'SubKey']}
32
- end
33
-
34
- it 'should generate Fn::GetAtt' do
35
- SparkleFormation.new(:dummy) do
36
- thing attr!(:resource, 'my_instance', :ip_address)
37
- end.dump.
38
- must_equal 'Thing' => {'Fn::GetAtt' => ['Resource', 'my_instance', 'IpAddress']}
39
- end
40
-
41
- it 'should generate Fn::Base64' do
42
- @attr.base64!('my string!').must_equal 'Fn::Base64' => 'my string!'
43
- end
44
-
45
- it 'should generate Fn::GetAZs' do
46
- @attr.azs!.must_equal 'Fn::GetAZs' => ''
47
- end
48
-
49
- it 'should generate Fn::GetAZs with argument' do
50
- @attr.azs!('fubar').must_equal 'Fn::GetAZs' => 'fubar'
51
- end
52
-
53
- it 'should generate Fn::GetAZs with Ref when provided symbol' do
54
- SparkleFormation.new(:dummy) do
55
- thing azs!(:item)
56
- end.dump.
57
- must_equal 'Thing' => {'Fn::GetAZs' => {'Ref' => 'Item'}}
58
- end
59
-
60
- it 'should generate Fn::Select' do
61
- @attr.select!(1, 'fubar').must_equal 'Fn::Select' => [1, 'fubar']
62
- @attr.select!('1', 'fubar').must_equal 'Fn::Select' => ['1', 'fubar']
63
- end
64
-
65
- it 'should generate Fn::Select with Ref when provided symbol' do
66
- SparkleFormation.new(:dummy) do
67
- thing select!(:param, :fubar)
68
- end.dump.
69
- must_equal 'Thing' => {'Fn::Select' => [{'Ref' => 'Param'}, {'Ref' => 'Fubar'}]}
70
- end
71
-
72
- end
data/test/specs/basic.rb DELETED
@@ -1,76 +0,0 @@
1
- describe SparkleFormation do
2
-
3
- before do
4
- SparkleFormation.sparkle_path = File.join(
5
- File.dirname(__FILE__), 'cloudformation'
6
- )
7
- end
8
-
9
- describe 'Basic Usage' do
10
-
11
- it 'should dump hashes' do
12
- SparkleFormation.new(:dummy) do
13
- test true
14
- end.dump.must_equal 'Test' => true
15
- end
16
-
17
- it 'should include components' do
18
- SparkleFormation.new(:dummy).load(:ami).
19
- dump.keys.must_include 'Mappings'
20
- end
21
-
22
- it 'should process overrides' do
23
- SparkleFormation.new(:dummy).overrides do
24
- test true
25
- end.dump.must_equal 'Test' => true
26
- end
27
-
28
- it 'should apply components on top of initial block' do
29
- result = SparkleFormation.new(:dummy) do
30
- mappings true
31
- end.load(:ami).dump
32
- result['Mappings'].must_be :is_a?, Hash
33
- end
34
-
35
- it 'should apply overrides on top of initial block and components' do
36
- SparkleFormation.new(:dummy) do
37
- mappings true
38
- end.load(:ami).overrides do
39
- mappings true
40
- end.dump.must_equal 'Mappings' => true
41
- end
42
-
43
- it 'should should build component hash' do
44
- component = MultiJson.load(File.read(File.join(File.dirname(__FILE__), 'results', 'component.json')))
45
- SparkleFormation.new(:dummy).load(:ami).dump.must_equal component
46
- end
47
-
48
- it 'should build full stack' do
49
- full_stack = MultiJson.load(File.read(File.join(File.dirname(__FILE__), 'results', 'base.json')))
50
- SparkleFormation.new(:dummy).load(:ami).overrides do
51
- dynamic!(:node, :my)
52
- end.dump.must_equal full_stack
53
- end
54
-
55
- it 'should allow dynamic customization' do
56
- full_stack = MultiJson.load(File.read(File.join(File.dirname(__FILE__), 'results', 'base_with_map.json')))
57
- SparkleFormation.new(:dummy).load(:ami).overrides do
58
- dynamic!(:node, :my) do
59
- properties do
60
- image_id map!(:region_map, 'AWS::Region', :ami)
61
- end
62
- end
63
- end.dump.must_equal full_stack
64
- end
65
-
66
- it 'should allow customization of defined items' do
67
- full_stack = MultiJson.load(File.read(File.join(File.dirname(__FILE__), 'results', 'base_with_map.json')))
68
- SparkleFormation.new(:dummy).load(:ami).overrides do
69
- dynamic!(:node, :my)
70
- resources.my_ec2_instance.properties.image_id map!(:region_map, 'AWS::Region', :ami)
71
- end.dump.must_equal full_stack
72
- end
73
-
74
- end
75
-
76
- end
@@ -1,14 +0,0 @@
1
- SparkleFormation.build do
2
-
3
- mappings.region_map do
4
- _set('us-east-1', :ami => 'ami-7f418316')
5
- _set('us-east-1', :ami => 'ami-7f418316')
6
- _set('us-west-1', :ami => 'ami-951945d0')
7
- _set('us-west-2', :ami => 'ami-16fd7026')
8
- _set('eu-west-1', :ami => 'ami-24506250')
9
- _set('sa-east-1', :ami => 'ami-3e3be423')
10
- _set('ap-southeast-1', :ami => 'ami-74dda626')
11
- _set('ap-northeast-1', :ami => 'ami-dcfa4edd')
12
- end
13
-
14
- end
@@ -1,16 +0,0 @@
1
- SparkleFormation.dynamic(:node) do |_name, _config|
2
-
3
- parameters do
4
- key_name do
5
- description 'Name of an existing EC2 KeyPair to enable SSH access to the instance'
6
- type 'String'
7
- end
8
- end
9
-
10
- dynamic!(:ec2_instance, _name) do
11
- properties do
12
- key_name ref!(:key_name)
13
- end
14
- end
15
-
16
- end
@@ -1,43 +0,0 @@
1
- {
2
- "Parameters": {
3
- "KeyName": {
4
- "Description": "Name of an existing EC2 KeyPair to enable SSH access to the instance",
5
- "Type": "String"
6
- }
7
- },
8
- "Mappings": {
9
- "RegionMap": {
10
- "Us-east-1": {
11
- "Ami": "ami-7f418316"
12
- },
13
- "Us-west-1": {
14
- "Ami": "ami-951945d0"
15
- },
16
- "Us-west-2": {
17
- "Ami": "ami-16fd7026"
18
- },
19
- "Eu-west-1": {
20
- "Ami": "ami-24506250"
21
- },
22
- "Sa-east-1": {
23
- "Ami": "ami-3e3be423"
24
- },
25
- "Ap-southeast-1": {
26
- "Ami": "ami-74dda626"
27
- },
28
- "Ap-northeast-1": {
29
- "Ami": "ami-dcfa4edd"
30
- }
31
- }
32
- },
33
- "Resources": {
34
- "MyEc2Instance": {
35
- "Type": "AWS::EC2::Instance",
36
- "Properties": {
37
- "KeyName": {
38
- "Ref": "KeyName"
39
- }
40
- }
41
- }
42
- }
43
- }
@@ -1,50 +0,0 @@
1
- {
2
- "Parameters": {
3
- "KeyName": {
4
- "Description": "Name of an existing EC2 KeyPair to enable SSH access to the instance",
5
- "Type": "String"
6
- }
7
- },
8
- "Mappings": {
9
- "RegionMap": {
10
- "Us-east-1": {
11
- "Ami": "ami-7f418316"
12
- },
13
- "Us-west-1": {
14
- "Ami": "ami-951945d0"
15
- },
16
- "Us-west-2": {
17
- "Ami": "ami-16fd7026"
18
- },
19
- "Eu-west-1": {
20
- "Ami": "ami-24506250"
21
- },
22
- "Sa-east-1": {
23
- "Ami": "ami-3e3be423"
24
- },
25
- "Ap-southeast-1": {
26
- "Ami": "ami-74dda626"
27
- },
28
- "Ap-northeast-1": {
29
- "Ami": "ami-dcfa4edd"
30
- }
31
- }
32
- },
33
- "Resources": {
34
- "MyEc2Instance": {
35
- "Type": "AWS::EC2::Instance",
36
- "Properties": {
37
- "KeyName": {
38
- "Ref": "KeyName"
39
- },
40
- "ImageId": {
41
- "Fn::FindInMap": [
42
- "RegionMap",
43
- {"Ref": "AWS::Region"},
44
- "Ami"
45
- ]
46
- }
47
- }
48
- }
49
- }
50
- }
@@ -1,27 +0,0 @@
1
- {
2
- "Mappings": {
3
- "RegionMap": {
4
- "Us-east-1": {
5
- "Ami": "ami-7f418316"
6
- },
7
- "Us-west-1": {
8
- "Ami": "ami-951945d0"
9
- },
10
- "Us-west-2": {
11
- "Ami": "ami-16fd7026"
12
- },
13
- "Eu-west-1": {
14
- "Ami": "ami-24506250"
15
- },
16
- "Sa-east-1": {
17
- "Ami": "ami-3e3be423"
18
- },
19
- "Ap-southeast-1": {
20
- "Ami": "ami-74dda626"
21
- },
22
- "Ap-northeast-1": {
23
- "Ami": "ami-dcfa4edd"
24
- }
25
- }
26
- }
27
- }