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 +8 -8
- data/README.md +1 -1
- data/bin/cfndsl +11 -1
- data/lib/cfndsl/aws/types.yaml +2 -1
- data/lib/cfndsl/jsonable.rb +5 -0
- data/lib/cfndsl/outputs.rb +4 -0
- data/lib/cfndsl/version.rb +1 -1
- data/sample/export.rb +24 -0
- data/sample/import.rb +19 -0
- data/spec/cfndsl_spec.rb +7 -0
- data/spec/cli_spec.rb +1 -0
- data/spec/output_spec.rb +15 -0
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
N2UzMWFmNmYxM2E2MTQ4M2U1NmM2MDk3NGFkNzUwMzI5ZjJmZmI4ZQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
YmYyNzZlM2RkNzRmNzE2YmYwOGI2OWVlMTM4MGZhYzE2Yjk4ODFlYw==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MzY3ZjVjZDU4NGQ3ZTNlMTdmNmM1N2RkYmMzZjIwZmYxZGRkZjM3NTIwNGEx
|
10
|
+
OGFkMTJmZTViZWQ5MTEzNGU3MjAxYzQyYjNmZDVlN2JkNmVhMGM2YTBjOTEy
|
11
|
+
MTI0M2U1MDRhZDVjMjc3ZDVkN2FmMGFmZTA1ZjhiMWJjNGNkMDE=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
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`
|
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
|
-
|
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
|
data/lib/cfndsl/aws/types.yaml
CHANGED
data/lib/cfndsl/jsonable.rb
CHANGED
@@ -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
|
data/lib/cfndsl/outputs.rb
CHANGED
data/lib/cfndsl/version.rb
CHANGED
data/sample/export.rb
ADDED
@@ -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
|
data/sample/import.rb
ADDED
@@ -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
|
data/spec/cfndsl_spec.rb
CHANGED
@@ -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'])
|
data/spec/cli_spec.rb
CHANGED
@@ -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
|
data/spec/output_spec.rb
ADDED
@@ -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.
|
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-
|
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
|