cfndsl 0.11.3 → 0.11.4

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,15 +1,15 @@
1
1
  ---
2
2
  !binary "U0hBMQ==":
3
3
  metadata.gz: !binary |-
4
- NDEyMTg0ZmVkZjIxYjk2MjAxOGM0MDZiM2E2MDhlMTViYWYyOTMxZg==
4
+ N2UzMWFmNmYxM2E2MTQ4M2U1NmM2MDk3NGFkNzUwMzI5ZjJmZmI4ZQ==
5
5
  data.tar.gz: !binary |-
6
- ZTY2MjdlMjY4N2VjMjMyNmYwNTk3NDM2ZjljY2MwN2MzMTliZjQ3MA==
6
+ YmYyNzZlM2RkNzRmNzE2YmYwOGI2OWVlMTM4MGZhYzE2Yjk4ODFlYw==
7
7
  SHA512:
8
8
  metadata.gz: !binary |-
9
- OWZiZDEzZGUyNWQ3MzdmZGIyZWUwODc5MmM1OTdhNjJiNjI4YWE4YTgwNTE0
10
- OTIyY2EwYjllNjgyMDJmMWY1ZWY2NmI5NmNlMThlNGZhMjlhYzQxYzUxM2I4
11
- YmUwZjczZjBkYzNhZTYyYWU1ZmVjMzY2MDVhOTJiN2ZkNzE0ODU=
9
+ MzY3ZjVjZDU4NGQ3ZTNlMTdmNmM1N2RkYmMzZjIwZmYxZGRkZjM3NTIwNGEx
10
+ OGFkMTJmZTViZWQ5MTEzNGU3MjAxYzQyYjNmZDVlN2JkNmVhMGM2YTBjOTEy
11
+ MTI0M2U1MDRhZDVjMjc3ZDVkN2FmMGFmZTA1ZjhiMWJjNGNkMDE=
12
12
  data.tar.gz: !binary |-
13
- MTI5Mjk2OTJmMDRiZGVjY2E3YmFiNmEzNDFkZDUxNzhiNjBiZTFlNTllZDhl
14
- NmZiN2Q1MjI1NTVhNWMxNDkwMzNlNDBjZTgxNWUzNDYxYjJiOTRkNDgwZjIy
15
- ZDNkOTZkYTFmOTE2N2MxNzJkZjFlOGMwMjIxNTkyMTJiNzA2YjI=
13
+ YTVhZTA1NTIxODg2ZmM5NjJlNzZhZWViNTg2NjAwZWJmMDFlNzlhOTYzMzM1
14
+ NGU0NzdlNDBlMDMwZDllODRmMDlmOTZiZTU0MmZiZTdkZjhkY2ZkMjk0MjFm
15
+ ZjBhNzFjY2RjYTQwN2FmOTYyNmU0ZDFjMmUxMThhMzFjZjdlOWU=
data/README.md CHANGED
@@ -324,7 +324,7 @@ end
324
324
 
325
325
  ### Resource Types
326
326
 
327
- When using the generic `Resource` method, rather than the dsl methods, specify the type of resource using `Type` amd the properties using `Property`. See [Template Resources](#template-resources) for an example.
327
+ When using the generic `Resource` method, rather than the dsl methods, specify the type of resource using `Type` and the properties using `Property`. See [Template Resources](#template-resources) for an example.
328
328
 
329
329
  ### Resource Conditions
330
330
 
data/bin/cfndsl CHANGED
@@ -33,6 +33,11 @@ optparse = OptionParser.new do |opts|
33
33
  options[:pretty] = true
34
34
  end
35
35
 
36
+ opts.on('-f', '--format FORMAT', 'Specify the output format (JSON default)') do |format|
37
+ raise "Format #{format} not supported" unless format == 'json' || format == 'yaml'
38
+ options[:outformat] = format
39
+ end
40
+
36
41
  opts.on('-D', '--define "VARIABLE=VALUE"', 'Directly set local VARIABLE as VALUE') do |file|
37
42
  options[:extras].push([:raw, file])
38
43
  end
@@ -83,4 +88,9 @@ elsif verbose
83
88
  verbose.puts('Writing to STDOUT')
84
89
  end
85
90
 
86
- output.puts options[:pretty] ? JSON.pretty_generate(model) : model.to_json
91
+ if options[:outformat] == 'yaml'
92
+ data = model.to_json
93
+ output.puts JSON.parse(data).to_yaml
94
+ else
95
+ output.puts options[:pretty] ? JSON.pretty_generate(model) : model.to_json
96
+ end
@@ -1015,7 +1015,8 @@ Resources:
1015
1015
  Name: String
1016
1016
  XssMatchTuples: [ XssMatchTuple ]
1017
1017
  "AWS::ECS::Cluster" :
1018
- Properties: {}
1018
+ Properties:
1019
+ ClusterName: String
1019
1020
  "AWS::ECS::Service" :
1020
1021
  Properties:
1021
1022
  Cluster: String
@@ -76,6 +76,11 @@ module CfnDsl
76
76
  Fn.new('Select', [index, array])
77
77
  end
78
78
 
79
+ # Equivalent to the CloudFormation template built in function Fn::ImportValue
80
+ def FnImportValue(value)
81
+ Fn.new('ImportValue', value)
82
+ end
83
+
79
84
  # Usage
80
85
  # FnFormat('This is a %0. It is 100%% %1', 'test', 'effective')
81
86
  # or
@@ -5,6 +5,10 @@ module CfnDsl
5
5
  class OutputDefinition < JSONable
6
6
  dsl_attr_setter :Value, :Description, :Condition
7
7
 
8
+ def Export(value)
9
+ @Export = { 'Name' => value } if value
10
+ end
11
+
8
12
  def initialize(value = nil)
9
13
  @Value = value if value
10
14
  end
@@ -1,3 +1,3 @@
1
1
  module CfnDsl
2
- VERSION = '0.11.3'.freeze
2
+ VERSION = '0.11.4'.freeze
3
3
  end
@@ -0,0 +1,24 @@
1
+ CloudFormation do
2
+ EC2_SecurityGroup(:webSecurityGroup) do
3
+ GroupDescription 'Allow incoming HTTP traffic from anywhere'
4
+ SecurityGroupIngress [
5
+ {
6
+ 'CidrIp' => '0.0.0.0/0',
7
+ 'IpProtocol' => 'tcp',
8
+ 'FromPort' => 80,
9
+ 'ToPort' => 80
10
+ }
11
+ ]
12
+ end
13
+
14
+ EC2_Instance(:webInstance) do
15
+ ImageId 'ami-59e8964e'
16
+ InstanceType 'm3.large'
17
+ SecurityGroups [Ref(:webSecurityGroup)]
18
+ end
19
+
20
+ Output(:securityGroupId) do
21
+ Value FnGetAtt(:webSecurityGroup, :GroupId)
22
+ Export :webSecurityGroupId
23
+ end
24
+ end
@@ -0,0 +1,19 @@
1
+ CloudFormation do
2
+ EC2_SecurityGroup(:databaseSecurityGroup) do
3
+ GroupDescription 'Allow access from only web instances'
4
+ SecurityGroupIngress [
5
+ {
6
+ 'SourceSecurityGroupId' => FnImportValue(:webSecurityGroupId),
7
+ 'IpProtocol' => 'tcp',
8
+ 'FromPort' => 7777,
9
+ 'ToPort' => 7777
10
+ }
11
+ ]
12
+ end
13
+
14
+ EC2_Instance(:databaseInstance) do
15
+ ImageId 'ami-59e8964e'
16
+ InstanceType 'm3.large'
17
+ SecurityGroups [Ref(:databaseSecurityGroup)]
18
+ end
19
+ end
@@ -154,6 +154,13 @@ describe CfnDsl::CloudFormationTemplate do
154
154
  expect(func.to_json).to eq('{"Fn::GetAZs":"reg"}')
155
155
  end
156
156
 
157
+ context 'FnImportValue' do
158
+ it 'formats correctly' do
159
+ func = subject.FnImportValue 'ExternalResource'
160
+ expect(func.to_json).to eq('{"Fn::ImportValue":"ExternalResource"}')
161
+ end
162
+ end
163
+
157
164
  context 'FnNot', 'Array' do
158
165
  it 'FnNot' do
159
166
  func = subject.FnNot(['foo'])
@@ -9,6 +9,7 @@ describe 'cfndsl', type: :aruba do
9
9
  -r, --ruby FILE Evaluate ruby file before template
10
10
  -j, --json FILE Import json file as local variables
11
11
  -p, --pretty Pretty-format output JSON
12
+ -f, --format FORMAT Specify the output format (JSON default)
12
13
  -D, --define "VARIABLE=VALUE" Directly set local VARIABLE as VALUE
13
14
  -v, --verbose Turn on verbose ouptut
14
15
  -b, --disable-binding Disable binding configuration
@@ -0,0 +1,15 @@
1
+ require 'spec_helper'
2
+
3
+ describe CfnDsl::OutputDefinition do
4
+ let(:template) { CfnDsl::OrchestrationTemplate.new }
5
+
6
+ context '#Export' do
7
+ it 'formats correctly' do
8
+ output = template.Output(:testOutput) do
9
+ Value 'stuff'
10
+ Export 'publishedValue'
11
+ end
12
+ expect(output.to_json).to eq('{"Value":"stuff","Export":{"Name":"publishedValue"}}')
13
+ end
14
+ end
15
+ end
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.11.3
4
+ version: 0.11.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Steven Jack
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2016-09-20 00:00:00.000000000 Z
12
+ date: 2016-10-05 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: bundler
@@ -78,7 +78,9 @@ files:
78
78
  - sample/codedeploy.rb
79
79
  - sample/config_service.rb
80
80
  - sample/ecs.rb
81
+ - sample/export.rb
81
82
  - sample/iam_policies.rb
83
+ - sample/import.rb
82
84
  - sample/lambda.rb
83
85
  - sample/s3.rb
84
86
  - sample/t1.rb
@@ -95,6 +97,7 @@ files:
95
97
  - spec/jsonable_spec.rb
96
98
  - spec/metadata_spec.rb
97
99
  - spec/names_spec.rb
100
+ - spec/output_spec.rb
98
101
  - spec/plurals_spec.rb
99
102
  - spec/resources_spec.rb
100
103
  - spec/spec_helper.rb
@@ -135,6 +138,7 @@ test_files:
135
138
  - spec/jsonable_spec.rb
136
139
  - spec/metadata_spec.rb
137
140
  - spec/names_spec.rb
141
+ - spec/output_spec.rb
138
142
  - spec/plurals_spec.rb
139
143
  - spec/resources_spec.rb
140
144
  - spec/spec_helper.rb