cfndsl 0.5.0.pre → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,15 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 0c3d2ac765697ae526e12354216d7c45845e07b0
4
- data.tar.gz: 7ea0a5bb2eb5d16a611165bde335400d6fbdf29b
2
+ !binary "U0hBMQ==":
3
+ metadata.gz: !binary |-
4
+ YjJkMDNjNjUzZWQ2NWRmZTFmOWJlMGI0MTc2ODYzM2RjY2I3NzhkNg==
5
+ data.tar.gz: !binary |-
6
+ NDRhNWQyOTIyYThjZmYxYmVhMDBiNmJiZGQxNWUxNTk2NmQyYzc0Mg==
5
7
  SHA512:
6
- metadata.gz: efac56f41113e2ba016d176eeb23c5bf177d57c2ec22008eb029adea4f990d0ddcc975d13e87277efb07d192e227e76559b2bf567f04408e9641a432ba60c753
7
- data.tar.gz: 27ed0952f74bf9841485d5236208b4315820bee91e737bbfa55d823281bc543245cb77e2ff6bd7f7a4fabb18f5472c6d13a0d023235da86d6677baa49958b340
8
+ metadata.gz: !binary |-
9
+ OTE4ZjhjYWVhZWE2ODZmM2RlZTE5ODEzZDc1N2ZjZTcyZmE4NzIwY2RmMWFm
10
+ NmI5MTY4NjgyYzY1MmE2MjQxNmQwNTk0NjVhOTdiMDE1MDJjZWY4M2M3OGE1
11
+ OGIwZTE5YmFmZjE2NzA3YWMzYjJiYThhNjIxMGY1NGMyMmI3MGU=
12
+ data.tar.gz: !binary |-
13
+ ZDgxYjQzNGYwNzg0MGYyMTM2MTc4NWI0NGY5N2IzZTEwNjcyNzE1OTZlYzMz
14
+ MTYwZmZjNWMzZDU1ZTFlNTY3ZjIxM2Q3NDE2MmE3MjQ0ODYwNTEwOTFiYzg2
15
+ ZjFiYThhOTM4YzBlOTIxYTI2MWM3Mzg5MzQ1YjNlYTI1NjExNmI=
data/.gitignore CHANGED
@@ -1,3 +1,4 @@
1
1
  *.gem
2
2
  *~
3
3
  Gemfile.lock
4
+ tmp/
data/.rubocop.yml CHANGED
@@ -21,3 +21,7 @@ Style/MethodName:
21
21
  # Lone String
22
22
  Lint/Void:
23
23
  Enabled: false
24
+
25
+ AllCops:
26
+ Exclude:
27
+ - 'tmp/**/*'
data/Gemfile CHANGED
@@ -9,6 +9,7 @@ group :development, :test do
9
9
  end
10
10
 
11
11
  group :test do
12
+ gem 'aruba'
12
13
  gem 'rake'
13
14
  gem 'rspec'
14
15
  end
data/README.md CHANGED
@@ -91,6 +91,8 @@ There is a more detailed example in the samples directory. The file
91
91
  "autoscale.template" is one of the standard Amazon sample templates.
92
92
  "autoscale.rb" generates an equivalent template file.
93
93
 
94
+ There's also a larger set of examples available at [cfndsl_examples](https://github.com/neillturner/cfndsl_examples) thanks to @neillturner.
95
+
94
96
  ## Command Line Options
95
97
 
96
98
  The cfndsl command line program now accepts some command line options.
@@ -9,6 +9,13 @@ module CfnDsl
9
9
  dsl_attr_setter :Type, :DependsOn, :DeletionPolicy, :Condition
10
10
  dsl_content_object :Property, :Metadata, :UpdatePolicy, :CreationPolicy
11
11
 
12
+ # rubocop:disable UnusedMethodArgument
13
+ # rubocop:disable UselessAssignment
14
+ def addTag(name, value, propagate = nil)
15
+ logstream.puts("This method is deprecated and will be removed in the next major release, please use 'add_tag' instead.") if logstream
16
+ add_tag(name, value, propagate = nil)
17
+ end
18
+
12
19
  def add_tag(name, value, propagate = nil)
13
20
  send(:Tag) do
14
21
  Key name
@@ -1,3 +1,3 @@
1
1
  module CfnDsl
2
- VERSION = '0.5.0.pre'.freeze
2
+ VERSION = '0.5.0'.freeze
3
3
  end
@@ -7,11 +7,11 @@ CloudFormation do
7
7
  EnableDnsSupport true
8
8
  EnableDnsHostnames true
9
9
  CidrBlock '10.1.0.0/16'
10
- addTag('Name', 'Test VPC')
10
+ add_tag('Name', 'Test VPC')
11
11
  end
12
12
 
13
13
  InternetGateway(:InternetGateway) do
14
- addTag('Name', 'Test VPC Gateway')
14
+ add_tag('Name', 'Test VPC Gateway')
15
15
  end
16
16
 
17
17
  VPCGatewayAttachment(:GatewayToInternet) do
@@ -27,12 +27,12 @@ CloudFormation do
27
27
  Subnet(subnet) do
28
28
  VpcId Ref(:VPC)
29
29
  CidrBlock "10.1.#{i}.0/24"
30
- addTag('Name', "test vpc #{subnet}")
30
+ add_tag('Name', "test vpc #{subnet}")
31
31
  end
32
32
 
33
33
  RouteTable(route_table) do
34
34
  VpcId Ref(:VPC)
35
- addTag('Name', route_table)
35
+ add_tag('Name', route_table)
36
36
  end
37
37
 
38
38
  SubnetRouteTableAssociation(route_table_assoc) do
@@ -25,11 +25,11 @@ CloudFormation do
25
25
  EnableDnsSupport true
26
26
  EnableDnsHostnames true
27
27
  CidrBlock '10.1.0.0/16'
28
- addTag('Name', 'Test VPC')
28
+ add_tag('Name', 'Test VPC')
29
29
  end
30
30
 
31
31
  InternetGateway(:InternetGateway) do
32
- addTag('Name', 'Test VPC Gateway')
32
+ add_tag('Name', 'Test VPC Gateway')
33
33
  end
34
34
 
35
35
  VPCGatewayAttachment(:GatewayToInternet) do
@@ -45,12 +45,12 @@ CloudFormation do
45
45
  Subnet(subnet) do
46
46
  VpcId Ref(:VPC)
47
47
  CidrBlock "10.1.#{i}.0/24"
48
- addTag('Name', "test vpc #{subnet}")
48
+ add_tag('Name', "test vpc #{subnet}")
49
49
  end
50
50
 
51
51
  RouteTable(route_table) do
52
52
  VpcId Ref(:VPC)
53
- addTag('Name', route_table)
53
+ add_tag('Name', route_table)
54
54
  end
55
55
 
56
56
  SubnetRouteTableAssociation(route_table_assoc) do
@@ -68,7 +68,7 @@ CloudFormation do
68
68
 
69
69
  VPNGateway(:VirtualPrivateNetworkGateway) do
70
70
  Type 'ipsec.1'
71
- addTag('Name', 'Test VPN Gateway')
71
+ add_tag('Name', 'Test VPN Gateway')
72
72
  end
73
73
 
74
74
  VPCGatewayAttachment(:VPNGatewayAttachment) do
@@ -80,7 +80,7 @@ CloudFormation do
80
80
  Type 'ipsec.1'
81
81
  BgpAsn '65000'
82
82
  IpAddress Ref('RouterIPAddress')
83
- addTag('Name', 'Test Customer VPN Gateway')
83
+ add_tag('Name', 'Test Customer VPN Gateway')
84
84
  end
85
85
 
86
86
  VPNConnection(:VPNConnection) do
data/spec/cli_spec.rb ADDED
@@ -0,0 +1,120 @@
1
+ require 'spec_helper'
2
+
3
+ describe 'cfndsl', type: :aruba do
4
+ let(:usage) do
5
+ <<-USAGE.gsub(/^ {6}/, '').chomp
6
+ Usage: cfndsl [options] FILE
7
+ -o, --output FILE Write output to file
8
+ -y, --yaml FILE Import yaml file as local variables
9
+ -r, --ruby FILE Evaluate ruby file before template
10
+ -j, --json FILE Import json file as local variables
11
+ -p, --pretty Pretty-format output JSON
12
+ -D, --define "VARIABLE=VALUE" Directly set local VARIABLE as VALUE
13
+ -v, --verbose Turn on verbose ouptut
14
+ -h, --help Display this screen
15
+ USAGE
16
+ end
17
+
18
+ let(:template_content) do
19
+ <<-TEMPLATE.gsub(/^ {6}/, '')
20
+ CloudFormation do
21
+ DESC = 'default' unless defined? DESC
22
+ Description DESC
23
+ end
24
+ TEMPLATE
25
+ end
26
+
27
+ before(:each) { write_file('template.rb', template_content) }
28
+
29
+ context 'cfndsl' do
30
+ it 'displays the usage' do
31
+ run 'cfndsl'
32
+ expect(last_command_started).to have_output(usage)
33
+ expect(last_command_started).to have_exit_status(1)
34
+ end
35
+ end
36
+
37
+ context 'cfndsl --help' do
38
+ it 'displays the usage' do
39
+ run_simple 'cfndsl --help'
40
+ expect(last_command_started).to have_output(usage)
41
+ end
42
+ end
43
+
44
+ context 'cfndsl FILE' do
45
+ it 'generates a JSON CloudFormation template' do
46
+ run_simple 'cfndsl template.rb'
47
+ expect(last_command_started).to have_output('{"AWSTemplateFormatVersion":"2010-09-09","Description":"default"}')
48
+ end
49
+ end
50
+
51
+ context 'cfndsl FILE --pretty' do
52
+ it 'generates a pretty JSON CloudFormation template' do
53
+ run_simple 'cfndsl template.rb --pretty'
54
+ expect(last_command_started).to have_output(<<-OUTPUT.gsub(/^ {8}/, '').chomp)
55
+ {
56
+ "AWSTemplateFormatVersion": "2010-09-09",
57
+ "Description": "default"
58
+ }
59
+ OUTPUT
60
+ end
61
+ end
62
+
63
+ context 'cfndsl FILE --output FILE' do
64
+ it 'writes the JSON CloudFormation template to a file' do
65
+ run_simple 'cfndsl template.rb --output template.json'
66
+ expect(read('template.json')).to eq(['{"AWSTemplateFormatVersion":"2010-09-09","Description":"default"}'])
67
+ end
68
+ end
69
+
70
+ context 'cfndsl FILE --yaml FILE' do
71
+ before { write_file('params.yaml', 'DESC: yaml') }
72
+
73
+ it 'interpolates the YAML file in the CloudFormation template' do
74
+ run_simple 'cfndsl template.rb --yaml params.yaml'
75
+ expect(last_command_started).to have_output('{"AWSTemplateFormatVersion":"2010-09-09","Description":"yaml"}')
76
+ end
77
+ end
78
+
79
+ context 'cfndsl FILE --json FILE' do
80
+ before { write_file('params.json', '{"DESC":"json"}') }
81
+
82
+ it 'interpolates the JSON file in the CloudFormation template' do
83
+ run_simple 'cfndsl template.rb --json params.json'
84
+ expect(last_command_started).to have_output('{"AWSTemplateFormatVersion":"2010-09-09","Description":"json"}')
85
+ end
86
+ end
87
+
88
+ context 'cfndsl FILE --ruby FILE' do
89
+ before { write_file('params.rb', 'DESC = "ruby"') }
90
+
91
+ it 'interpolates the JSON file in the CloudFormation template' do
92
+ run_simple 'cfndsl template.rb --ruby params.rb'
93
+ expect(last_command_started).to have_output('{"AWSTemplateFormatVersion":"2010-09-09","Description":"ruby"}')
94
+ end
95
+ end
96
+
97
+ context 'cfndsl FILE --define VARIABLE=VALUE' do
98
+ it 'interpolates the command line variables in the CloudFormation template' do
99
+ run_simple "cfndsl template.rb --define \"DESC='cli'\""
100
+ expect(last_command_started).to have_output('{"AWSTemplateFormatVersion":"2010-09-09","Description":"cli"}')
101
+ end
102
+ end
103
+
104
+ context 'cfndsl FILE --verbose' do
105
+ before { write_file('params.yaml', 'DESC: yaml') }
106
+
107
+ it 'displays the variables as they are interpolated in the CloudFormation template' do
108
+ run_simple 'cfndsl template.rb --yaml params.yaml --verbose'
109
+ verbose = /
110
+ Loading \s YAML \s file \s .* params\.yaml \n
111
+ Setting \s local \s variable \s DESC \s to \s yaml \n
112
+ Loading \s template \s file \s .* template.rb \n
113
+ Writing \s to \s STDOUT
114
+ /x
115
+ template = '{"AWSTemplateFormatVersion":"2010-09-09","Description":"yaml"}'
116
+ expect(last_command_started).to have_output_on_stderr(verbose)
117
+ expect(last_command_started).to have_output_on_stdout(template)
118
+ end
119
+ end
120
+ end
data/spec/spec_helper.rb CHANGED
@@ -1 +1,5 @@
1
1
  require 'cfndsl'
2
+ require 'aruba/rspec'
3
+
4
+ bindir = File.expand_path('../../bin', __FILE__)
5
+ ENV['PATH'] = [ENV['PATH'], bindir].join(':')
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cfndsl
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.0.pre
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Steven Jack
@@ -9,20 +9,20 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-04-01 00:00:00.000000000 Z
12
+ date: 2016-04-13 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
16
16
  requirement: !ruby/object:Gem::Requirement
17
17
  requirements:
18
- - - ">="
18
+ - - ! '>='
19
19
  - !ruby/object:Gem::Version
20
20
  version: '0'
21
21
  type: :development
22
22
  prerelease: false
23
23
  version_requirements: !ruby/object:Gem::Requirement
24
24
  requirements:
25
- - - ">="
25
+ - - ! '>='
26
26
  - !ruby/object:Gem::Version
27
27
  version: '0'
28
28
  description: DSL for creating AWS Cloudformation templates
@@ -34,9 +34,9 @@ executables:
34
34
  extensions: []
35
35
  extra_rdoc_files: []
36
36
  files:
37
- - ".gitignore"
38
- - ".rubocop.yml"
39
- - ".travis.yml"
37
+ - .gitignore
38
+ - .rubocop.yml
39
+ - .travis.yml
40
40
  - Gemfile
41
41
  - LICENSE
42
42
  - README.md
@@ -85,6 +85,7 @@ files:
85
85
  - sample/vpc_example.rb
86
86
  - sample/vpc_with_vpn_example.rb
87
87
  - spec/cfndsl_spec.rb
88
+ - spec/cli_spec.rb
88
89
  - spec/fixtures/heattest.rb
89
90
  - spec/fixtures/test.rb
90
91
  - spec/spec_helper.rb
@@ -98,22 +99,23 @@ require_paths:
98
99
  - lib
99
100
  required_ruby_version: !ruby/object:Gem::Requirement
100
101
  requirements:
101
- - - ">="
102
+ - - ! '>='
102
103
  - !ruby/object:Gem::Version
103
104
  version: '0'
104
105
  required_rubygems_version: !ruby/object:Gem::Requirement
105
106
  requirements:
106
- - - ">"
107
+ - - ! '>='
107
108
  - !ruby/object:Gem::Version
108
- version: 1.3.1
109
+ version: '0'
109
110
  requirements: []
110
111
  rubyforge_project:
111
- rubygems_version: 2.4.8
112
+ rubygems_version: 2.4.5
112
113
  signing_key:
113
114
  specification_version: 4
114
115
  summary: AWS Cloudformation DSL
115
116
  test_files:
116
117
  - spec/cfndsl_spec.rb
118
+ - spec/cli_spec.rb
117
119
  - spec/fixtures/heattest.rb
118
120
  - spec/fixtures/test.rb
119
121
  - spec/spec_helper.rb