active_aws 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (40) hide show
  1. checksums.yaml +7 -0
  2. data/.ruby-gemset +1 -0
  3. data/.ruby-version +1 -0
  4. data/Gemfile +32 -0
  5. data/Gemfile.lock +153 -0
  6. data/LICENSE.txt +20 -0
  7. data/README.md +19 -0
  8. data/Rakefile +44 -0
  9. data/VERSION +1 -0
  10. data/active_aws.gemspec +120 -0
  11. data/config/cucumber.yml +2 -0
  12. data/features/cloud_formation/cloud_formation.feature +160 -0
  13. data/features/cloud_formation/dsl/parameterized_initializer.feature +15 -0
  14. data/features/cloud_formation/dsl/properties.feature +2 -0
  15. data/features/cloud_formation/dsl/resource_definition.feature +0 -0
  16. data/features/cloud_formation/templates/ec2_instances.feature +79 -0
  17. data/features/ec2/client/ec2_client.feature +19 -0
  18. data/features/step_definitions/common_steps.rb +79 -0
  19. data/features/step_definitions/ec2_client_steps.rb +7 -0
  20. data/features/support/env.rb +15 -0
  21. data/features/support/vcr.rb +11 -0
  22. data/fixtures/vcr_cassettes/ActiveAws_EC2_client_feature/It_has_availability_zones_.yml +68 -0
  23. data/fixtures/vcr_cassettes/ActiveAws_EC2_client_feature/It_has_instances_.yml +143 -0
  24. data/fixtures/vcr_cassettes/ActiveAws_EC2_client_feature/It_has_regions_.yml +92 -0
  25. data/lib/active_aws.rb +13 -0
  26. data/lib/active_aws/cloud_formation.rb +11 -0
  27. data/lib/active_aws/cloud_formation/template.rb +111 -0
  28. data/lib/active_aws/cloud_formation/template/dsl_block.rb +48 -0
  29. data/lib/active_aws/cloud_formation/template/mappings.rb +22 -0
  30. data/lib/active_aws/cloud_formation/template/parameter.rb +50 -0
  31. data/lib/active_aws/cloud_formation/template/properties.rb +80 -0
  32. data/lib/active_aws/cloud_formation/template/resource.rb +218 -0
  33. data/lib/active_aws/cloud_formation/template/resource/auto_scaling_group.rb +11 -0
  34. data/lib/active_aws/cloud_formation/template/resource/ec2_instance.rb +21 -0
  35. data/lib/active_aws/cloud_formation/template/resource/launch_config.rb +11 -0
  36. data/lib/active_aws/cloud_formation/template/resource/load_balancer.rb +40 -0
  37. data/lib/active_aws/cloud_formation/template/resource/metadata.rb +11 -0
  38. data/lib/active_aws/ec2.rb +27 -0
  39. data/lib/active_aws/parameterized_initializer.rb +15 -0
  40. metadata +294 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 4f6adf31236e146c225847e90e22e5f0ffc15c62
4
+ data.tar.gz: eea323eeb9caee1ddc09cdb480a4d613b2c5bced
5
+ SHA512:
6
+ metadata.gz: 5c4c9c7ae163b72034c18c4e5c32a23ed50223dec254fb762f14119e3a57b28405695d60e7e5ca93635dc4bfe9ec98c7deede6c50e80ebede588539eecd9e048
7
+ data.tar.gz: aad84d8dd668efbc3f0e47fe40a4008fc593e7c0b3d600b1049b76231d66cc5cdbefa88003424336a7e2fd51dd537a4423b843796430e98ef5b72e47ad4958a4
data/.ruby-gemset ADDED
@@ -0,0 +1 @@
1
+ active_aws
data/.ruby-version ADDED
@@ -0,0 +1 @@
1
+ ruby-2.2.2
data/Gemfile ADDED
@@ -0,0 +1,32 @@
1
+ source 'http://rubygems.org'
2
+
3
+ gem 'activesupport', '4.2.1'
4
+ gem 'aws-sdk', '~> 2.0'
5
+ gem 'dotenv'
6
+
7
+ # Add dependencies to develop your gem here.
8
+ # Include everything needed to run rake, tests, features, etc.
9
+ group :development do
10
+ gem 'bundler', '~> 1.0'
11
+ gem 'jeweler', '~> 2.0.1'
12
+
13
+ # Use cucumber & rspec for tests
14
+ gem 'rspec', '~> 3.2'
15
+ gem 'cucumber', '~> 2.0'
16
+ # https://github.com/cucumber/aruba
17
+ gem 'aruba', '0.6.2'
18
+
19
+ gem 'webmock'
20
+ gem 'vcr', '2.9.3'
21
+
22
+ # Code coverage using simplecov
23
+ gem 'simplecov', '>= 0', require: false
24
+
25
+ # Code style checking
26
+ gem 'rubocop', require: false
27
+
28
+ # Documentation
29
+ gem 'rdoc', '~> 4.2.0'
30
+ gem 'yard', '~> 0.8.7', require: false
31
+ gem 'redcarpet'
32
+ end
data/Gemfile.lock ADDED
@@ -0,0 +1,153 @@
1
+ GEM
2
+ remote: http://rubygems.org/
3
+ specs:
4
+ activesupport (4.2.1)
5
+ i18n (~> 0.7)
6
+ json (~> 1.7, >= 1.7.7)
7
+ minitest (~> 5.1)
8
+ thread_safe (~> 0.3, >= 0.3.4)
9
+ tzinfo (~> 1.1)
10
+ addressable (2.3.8)
11
+ aruba (0.6.2)
12
+ childprocess (>= 0.3.6)
13
+ cucumber (>= 1.1.1)
14
+ rspec-expectations (>= 2.7.0)
15
+ ast (2.0.0)
16
+ astrolabe (1.3.0)
17
+ parser (>= 2.2.0.pre.3, < 3.0)
18
+ aws-sdk (2.0.43)
19
+ aws-sdk-resources (= 2.0.43)
20
+ aws-sdk-core (2.0.43)
21
+ builder (~> 3.0)
22
+ jmespath (~> 1.0)
23
+ multi_json (~> 1.0)
24
+ aws-sdk-resources (2.0.43)
25
+ aws-sdk-core (= 2.0.43)
26
+ builder (3.2.2)
27
+ childprocess (0.5.6)
28
+ ffi (~> 1.0, >= 1.0.11)
29
+ crack (0.4.2)
30
+ safe_yaml (~> 1.0.0)
31
+ cucumber (2.0.0)
32
+ builder (>= 2.1.2)
33
+ cucumber-core (~> 1.1.3)
34
+ diff-lcs (>= 1.1.3)
35
+ gherkin (~> 2.12)
36
+ multi_json (>= 1.7.5, < 2.0)
37
+ multi_test (>= 0.1.2)
38
+ cucumber-core (1.1.3)
39
+ gherkin (~> 2.12.0)
40
+ descendants_tracker (0.0.4)
41
+ thread_safe (~> 0.3, >= 0.3.1)
42
+ diff-lcs (1.2.5)
43
+ docile (1.1.5)
44
+ dotenv (2.0.1)
45
+ faraday (0.9.1)
46
+ multipart-post (>= 1.2, < 3)
47
+ ffi (1.9.8)
48
+ gherkin (2.12.2)
49
+ multi_json (~> 1.3)
50
+ git (1.2.9.1)
51
+ github_api (0.12.3)
52
+ addressable (~> 2.3)
53
+ descendants_tracker (~> 0.0.4)
54
+ faraday (~> 0.8, < 0.10)
55
+ hashie (>= 3.3)
56
+ multi_json (>= 1.7.5, < 2.0)
57
+ nokogiri (~> 1.6.3)
58
+ oauth2
59
+ hashie (3.4.1)
60
+ highline (1.7.2)
61
+ i18n (0.7.0)
62
+ jeweler (2.0.1)
63
+ builder
64
+ bundler (>= 1.0)
65
+ git (>= 1.2.5)
66
+ github_api
67
+ highline (>= 1.6.15)
68
+ nokogiri (>= 1.5.10)
69
+ rake
70
+ rdoc
71
+ jmespath (1.0.2)
72
+ multi_json (~> 1.0)
73
+ json (1.8.2)
74
+ jwt (1.5.0)
75
+ mini_portile (0.6.2)
76
+ minitest (5.7.0)
77
+ multi_json (1.11.0)
78
+ multi_test (0.1.2)
79
+ multi_xml (0.5.5)
80
+ multipart-post (2.0.0)
81
+ nokogiri (1.6.6.2)
82
+ mini_portile (~> 0.6.0)
83
+ oauth2 (1.0.0)
84
+ faraday (>= 0.8, < 0.10)
85
+ jwt (~> 1.0)
86
+ multi_json (~> 1.3)
87
+ multi_xml (~> 0.5)
88
+ rack (~> 1.2)
89
+ parser (2.2.2.3)
90
+ ast (>= 1.1, < 3.0)
91
+ powerpack (0.1.1)
92
+ rack (1.6.1)
93
+ rainbow (2.0.0)
94
+ rake (10.4.2)
95
+ rdoc (4.2.0)
96
+ redcarpet (3.2.3)
97
+ rspec (3.2.0)
98
+ rspec-core (~> 3.2.0)
99
+ rspec-expectations (~> 3.2.0)
100
+ rspec-mocks (~> 3.2.0)
101
+ rspec-core (3.2.3)
102
+ rspec-support (~> 3.2.0)
103
+ rspec-expectations (3.2.1)
104
+ diff-lcs (>= 1.2.0, < 2.0)
105
+ rspec-support (~> 3.2.0)
106
+ rspec-mocks (3.2.1)
107
+ diff-lcs (>= 1.2.0, < 2.0)
108
+ rspec-support (~> 3.2.0)
109
+ rspec-support (3.2.2)
110
+ rubocop (0.31.0)
111
+ astrolabe (~> 1.3)
112
+ parser (>= 2.2.2.1, < 3.0)
113
+ powerpack (~> 0.1)
114
+ rainbow (>= 1.99.1, < 3.0)
115
+ ruby-progressbar (~> 1.4)
116
+ ruby-progressbar (1.7.5)
117
+ safe_yaml (1.0.4)
118
+ simplecov (0.10.0)
119
+ docile (~> 1.1.0)
120
+ json (~> 1.8)
121
+ simplecov-html (~> 0.10.0)
122
+ simplecov-html (0.10.0)
123
+ thread_safe (0.3.5)
124
+ tzinfo (1.2.2)
125
+ thread_safe (~> 0.1)
126
+ vcr (2.9.3)
127
+ webmock (1.21.0)
128
+ addressable (>= 2.3.6)
129
+ crack (>= 0.3.2)
130
+ yard (0.8.7.6)
131
+
132
+ PLATFORMS
133
+ ruby
134
+
135
+ DEPENDENCIES
136
+ activesupport (= 4.2.1)
137
+ aruba (= 0.6.2)
138
+ aws-sdk (~> 2.0)
139
+ bundler (~> 1.0)
140
+ cucumber (~> 2.0)
141
+ dotenv
142
+ jeweler (~> 2.0.1)
143
+ rdoc (~> 4.2.0)
144
+ redcarpet
145
+ rspec (~> 3.2)
146
+ rubocop
147
+ simplecov
148
+ vcr (= 2.9.3)
149
+ webmock
150
+ yard (~> 0.8.7)
151
+
152
+ BUNDLED WITH
153
+ 1.10.3
data/LICENSE.txt ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2015 Alistair A. Israel
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,19 @@
1
+ = active_aws
2
+
3
+ Description goes here.
4
+
5
+ == Contributing to active_aws
6
+
7
+ * Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet.
8
+ * Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it.
9
+ * Fork the project.
10
+ * Start a feature/bugfix branch.
11
+ * Commit and push until you are happy with your contribution.
12
+ * Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
13
+ * Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
14
+
15
+ == Copyright
16
+
17
+ Copyright (c) 2015 Alistair A. Israel. See LICENSE.txt for
18
+ further details.
19
+
data/Rakefile ADDED
@@ -0,0 +1,44 @@
1
+ # encoding: utf-8
2
+
3
+ require 'rubygems'
4
+ require 'bundler'
5
+ begin
6
+ Bundler.setup(:default, :development)
7
+ rescue Bundler::BundlerError => e
8
+ $stderr.puts e.message
9
+ $stderr.puts 'Run `bundle install` to install missing gems'
10
+ exit e.status_code
11
+ end
12
+ require 'rake'
13
+
14
+ require 'jeweler'
15
+ Jeweler::Tasks.new do |gem|
16
+ # gem is a Gem::Specification... see http://guides.rubygems.org/specification-reference/ for more options
17
+ gem.name = 'active_aws'
18
+ gem.homepage = 'http://github.com/aisrael/active_aws'
19
+ gem.license = 'MIT'
20
+ gem.summary = 'Provides utility classes, helpers and decorators to the AWS Ruby SDK v2'
21
+ gem.description = 'Provides utility classes, helpers and decorators to the AWS Ruby SDK v2'
22
+ gem.email = 'aisrael@gmail.com'
23
+ gem.authors = ['Alistair A. Israel']
24
+ # dependencies defined in Gemfile
25
+ end
26
+ Jeweler::RubygemsDotOrgTasks.new
27
+
28
+ require 'cucumber'
29
+ require 'cucumber/rake/task'
30
+ Cucumber::Rake::Task.new(:features) do |t|
31
+ t.cucumber_opts = '--format pretty'
32
+ end
33
+
34
+ desc 'Code coverage detail'
35
+ task :simplecov do
36
+ ENV['COVERAGE'] = 'true'
37
+ Rake::Task['features'].execute
38
+ end
39
+
40
+ task :default => :features
41
+
42
+ require 'yard'
43
+ YARD::Rake::YardocTask.new do |t|
44
+ end
data/VERSION ADDED
@@ -0,0 +1 @@
1
+ 0.1.0
@@ -0,0 +1,120 @@
1
+ # Generated by jeweler
2
+ # DO NOT EDIT THIS FILE DIRECTLY
3
+ # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
+ # -*- encoding: utf-8 -*-
5
+ # stub: active_aws 0.1.0 ruby lib
6
+
7
+ Gem::Specification.new do |s|
8
+ s.name = "active_aws"
9
+ s.version = "0.1.0"
10
+
11
+ s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
12
+ s.require_paths = ["lib"]
13
+ s.authors = ["Alistair A. Israel"]
14
+ s.date = "2015-06-10"
15
+ s.description = "Provides utility classes, helpers and decorators to the AWS Ruby SDK v2"
16
+ s.email = "aisrael@gmail.com"
17
+ s.extra_rdoc_files = [
18
+ "LICENSE.txt",
19
+ "README.md"
20
+ ]
21
+ s.files = [
22
+ ".ruby-gemset",
23
+ ".ruby-version",
24
+ "Gemfile",
25
+ "Gemfile.lock",
26
+ "LICENSE.txt",
27
+ "README.md",
28
+ "Rakefile",
29
+ "VERSION",
30
+ "active_aws.gemspec",
31
+ "config/cucumber.yml",
32
+ "features/cloud_formation/cloud_formation.feature",
33
+ "features/cloud_formation/dsl/parameterized_initializer.feature",
34
+ "features/cloud_formation/dsl/properties.feature",
35
+ "features/cloud_formation/dsl/resource_definition.feature",
36
+ "features/cloud_formation/templates/ec2_instances.feature",
37
+ "features/ec2/client/ec2_client.feature",
38
+ "features/step_definitions/common_steps.rb",
39
+ "features/step_definitions/ec2_client_steps.rb",
40
+ "features/support/env.rb",
41
+ "features/support/vcr.rb",
42
+ "fixtures/vcr_cassettes/ActiveAws_EC2_client_feature/It_has_availability_zones_.yml",
43
+ "fixtures/vcr_cassettes/ActiveAws_EC2_client_feature/It_has_instances_.yml",
44
+ "fixtures/vcr_cassettes/ActiveAws_EC2_client_feature/It_has_regions_.yml",
45
+ "lib/active_aws.rb",
46
+ "lib/active_aws/cloud_formation.rb",
47
+ "lib/active_aws/cloud_formation/template.rb",
48
+ "lib/active_aws/cloud_formation/template/dsl_block.rb",
49
+ "lib/active_aws/cloud_formation/template/mappings.rb",
50
+ "lib/active_aws/cloud_formation/template/parameter.rb",
51
+ "lib/active_aws/cloud_formation/template/properties.rb",
52
+ "lib/active_aws/cloud_formation/template/resource.rb",
53
+ "lib/active_aws/cloud_formation/template/resource/auto_scaling_group.rb",
54
+ "lib/active_aws/cloud_formation/template/resource/ec2_instance.rb",
55
+ "lib/active_aws/cloud_formation/template/resource/launch_config.rb",
56
+ "lib/active_aws/cloud_formation/template/resource/load_balancer.rb",
57
+ "lib/active_aws/cloud_formation/template/resource/metadata.rb",
58
+ "lib/active_aws/ec2.rb",
59
+ "lib/active_aws/parameterized_initializer.rb"
60
+ ]
61
+ s.homepage = "http://github.com/aisrael/active_aws"
62
+ s.licenses = ["MIT"]
63
+ s.rubygems_version = "2.4.6"
64
+ s.summary = "Provides utility classes, helpers and decorators to the AWS Ruby SDK v2"
65
+
66
+ if s.respond_to? :specification_version then
67
+ s.specification_version = 4
68
+
69
+ if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
70
+ s.add_runtime_dependency(%q<activesupport>, ["= 4.2.1"])
71
+ s.add_runtime_dependency(%q<aws-sdk>, ["~> 2.0"])
72
+ s.add_runtime_dependency(%q<dotenv>, [">= 0"])
73
+ s.add_development_dependency(%q<bundler>, ["~> 1.0"])
74
+ s.add_development_dependency(%q<jeweler>, ["~> 2.0.1"])
75
+ s.add_development_dependency(%q<rspec>, ["~> 3.2"])
76
+ s.add_development_dependency(%q<cucumber>, ["~> 2.0"])
77
+ s.add_development_dependency(%q<aruba>, ["= 0.6.2"])
78
+ s.add_development_dependency(%q<webmock>, [">= 0"])
79
+ s.add_development_dependency(%q<vcr>, ["= 2.9.3"])
80
+ s.add_development_dependency(%q<simplecov>, [">= 0"])
81
+ s.add_development_dependency(%q<rubocop>, [">= 0"])
82
+ s.add_development_dependency(%q<rdoc>, ["~> 4.2.0"])
83
+ s.add_development_dependency(%q<yard>, ["~> 0.8.7"])
84
+ s.add_development_dependency(%q<redcarpet>, [">= 0"])
85
+ else
86
+ s.add_dependency(%q<activesupport>, ["= 4.2.1"])
87
+ s.add_dependency(%q<aws-sdk>, ["~> 2.0"])
88
+ s.add_dependency(%q<dotenv>, [">= 0"])
89
+ s.add_dependency(%q<bundler>, ["~> 1.0"])
90
+ s.add_dependency(%q<jeweler>, ["~> 2.0.1"])
91
+ s.add_dependency(%q<rspec>, ["~> 3.2"])
92
+ s.add_dependency(%q<cucumber>, ["~> 2.0"])
93
+ s.add_dependency(%q<aruba>, ["= 0.6.2"])
94
+ s.add_dependency(%q<webmock>, [">= 0"])
95
+ s.add_dependency(%q<vcr>, ["= 2.9.3"])
96
+ s.add_dependency(%q<simplecov>, [">= 0"])
97
+ s.add_dependency(%q<rubocop>, [">= 0"])
98
+ s.add_dependency(%q<rdoc>, ["~> 4.2.0"])
99
+ s.add_dependency(%q<yard>, ["~> 0.8.7"])
100
+ s.add_dependency(%q<redcarpet>, [">= 0"])
101
+ end
102
+ else
103
+ s.add_dependency(%q<activesupport>, ["= 4.2.1"])
104
+ s.add_dependency(%q<aws-sdk>, ["~> 2.0"])
105
+ s.add_dependency(%q<dotenv>, [">= 0"])
106
+ s.add_dependency(%q<bundler>, ["~> 1.0"])
107
+ s.add_dependency(%q<jeweler>, ["~> 2.0.1"])
108
+ s.add_dependency(%q<rspec>, ["~> 3.2"])
109
+ s.add_dependency(%q<cucumber>, ["~> 2.0"])
110
+ s.add_dependency(%q<aruba>, ["= 0.6.2"])
111
+ s.add_dependency(%q<webmock>, [">= 0"])
112
+ s.add_dependency(%q<vcr>, ["= 2.9.3"])
113
+ s.add_dependency(%q<simplecov>, [">= 0"])
114
+ s.add_dependency(%q<rubocop>, [">= 0"])
115
+ s.add_dependency(%q<rdoc>, ["~> 4.2.0"])
116
+ s.add_dependency(%q<yard>, ["~> 0.8.7"])
117
+ s.add_dependency(%q<redcarpet>, [">= 0"])
118
+ end
119
+ end
120
+
@@ -0,0 +1,2 @@
1
+ ---
2
+ default: -r features
@@ -0,0 +1,160 @@
1
+ Feature: CloudFormation Template Writing
2
+ In order to write CloudFormation templates using a Ruby DSL rather than JSON
3
+
4
+ Scenario: create a blank template
5
+ Given the following code snippet:
6
+ """ruby
7
+ @template = ActiveAws::CloudFormation::Template.new do
8
+ end
9
+ """
10
+ Then the template in JSON should be:
11
+ """json
12
+ {
13
+ "AWSTemplateFormatVersion":"2010-09-09"
14
+ }
15
+ """
16
+
17
+ Scenario: create a template with a description
18
+ Given the following code snippet:
19
+ """ruby
20
+ @template = ActiveAws::CloudFormation::Template.new do
21
+ description "Template description"
22
+ end
23
+ """
24
+ Then the template in JSON should be:
25
+ """json
26
+ {
27
+ "AWSTemplateFormatVersion": "2010-09-09",
28
+ "Description": "Template description"
29
+ }
30
+ """
31
+
32
+ Scenario: create a complex CloudFormation template
33
+ Given the following code snippet:
34
+ """ruby
35
+ @template = ActiveAws::CloudFormation::Template.new do
36
+ description 'Cloud Formation template'
37
+
38
+ # Define parameters one by one
39
+ parameter 'KeyName', :string, description: 'The key name to use to connect to the instances'
40
+
41
+ # Or use a parameters 'block' for some syntatic sugar
42
+ parameters {
43
+ string 'AvailabilityZone', description: 'The availability zone to create instances in'
44
+
45
+ # Also accepts a block
46
+ string 'InstanceType' do
47
+ allowed_values %w(t1.micro m1.small m1.medium m1.large)
48
+ description "EC2 instance type (e.g. #{allowed_values.join(', ')})"
49
+ default 't1.micro'
50
+ end
51
+ }
52
+
53
+ # You can also add mappings in a mappings {} block
54
+ mapping 'RegionMap', {
55
+ 'us-east-1' => { '32' => 'ami-6411e20d'},
56
+ 'us-west-1' => { '32' => 'ami-c9c7978c'},
57
+ 'eu-west-1' => { '32' => 'ami-37c2f643'},
58
+ 'ap-southeast-1' => { '32' => 'ami-66f28c34', '64' => 'ami-e8f1c1ba' },
59
+ 'ap-northeast-1' => { '32' => 'ami-9c03a89d'}
60
+ }
61
+
62
+ resources {
63
+ ec2_instance 'AppInstance1' do
64
+ availability_zone Ref: 'AvailabilityZone'
65
+ image_id 'ami-e8f1c1ba'
66
+ instance_type Ref: 'InstanceType'
67
+ end
68
+ load_balancer 'LoadBalancer' do
69
+ availability_zones Ref: 'AvailabilityZone'
70
+ listener 'HTTP', 80, 'HTTP', 80
71
+ instances Ref: 'AppInstance1'
72
+ end
73
+ }
74
+ end
75
+ """
76
+ Then the template in JSON should be:
77
+ """json
78
+ {
79
+ "AWSTemplateFormatVersion": "2010-09-09",
80
+ "Description": "Cloud Formation template",
81
+ "Parameters": {
82
+ "KeyName": {
83
+ "Type": "String",
84
+ "Description": "The key name to use to connect to the instances"
85
+ },
86
+ "AvailabilityZone": {
87
+ "Type": "String",
88
+ "Description": "The availability zone to create instances in"
89
+ },
90
+ "InstanceType": {
91
+ "Type": "String",
92
+ "Description": "EC2 instance type (e.g. t1.micro, m1.small, m1.medium, m1.large)",
93
+ "Default": "t1.micro",
94
+ "AllowedValues": [
95
+ "t1.micro",
96
+ "m1.small",
97
+ "m1.medium",
98
+ "m1.large"
99
+ ]
100
+ }
101
+ },
102
+ "Mappings": {
103
+ "Mappings": {
104
+ "RegionMap": {
105
+ "us-east-1": {
106
+ "32": "ami-6411e20d"
107
+ },
108
+ "us-west-1": {
109
+ "32": "ami-c9c7978c"
110
+ },
111
+ "eu-west-1": {
112
+ "32": "ami-37c2f643"
113
+ },
114
+ "ap-southeast-1": {
115
+ "32": "ami-66f28c34",
116
+ "64": "ami-e8f1c1ba"
117
+ },
118
+ "ap-northeast-1": {
119
+ "32": "ami-9c03a89d"
120
+ }
121
+ }
122
+ }
123
+ },
124
+ "Resources": {
125
+ "AppInstance1": {
126
+ "Type": "AWS::EC2::Instance",
127
+ "Properties": {
128
+ "AvailabilityZone": {
129
+ "Ref": "AvailabilityZone"
130
+ },
131
+ "ImageId": "ami-e8f1c1ba",
132
+ "InstanceType": {
133
+ "Ref": "InstanceType"
134
+ }
135
+ }
136
+ },
137
+ "LoadBalancer": {
138
+ "Type": "AWS::ElasticLoadBalancing::LoadBalancer",
139
+ "Properties": {
140
+ "AvailabilityZones": [
141
+ {
142
+ "Ref": "AvailabilityZone"
143
+ }
144
+ ],
145
+ "Listeners": [
146
+ {
147
+ "Protocol": "HTTP",
148
+ "LoadBalancerPort": 80,
149
+ "InstanceProtocol": "HTTP",
150
+ "InstancePort": 80
151
+ }
152
+ ],
153
+ "Instances": {
154
+ "Ref": "AppInstance1"
155
+ }
156
+ }
157
+ }
158
+ }
159
+ }
160
+ """