cfndsl 1.0.0.pre.1 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +67 -32
- data/README.md +1 -1
- data/cfndsl.gemspec +1 -1
- data/lib/cfndsl/aws/patches/000_CloudFormationResourceSpecification.json +51726 -0
- data/lib/cfndsl/aws/patches/000_sam.spec.json +673 -5
- data/lib/cfndsl/aws/patches/200_Scrutinies_patch.json +86 -0
- data/lib/cfndsl/aws/patches/500_NetworkAclEntry_patch.json +16 -0
- data/lib/cfndsl/aws/patches/520_ServiceDiscovery_InstanceAttributes_patch.json +16 -0
- data/lib/cfndsl/cloudformation.rb +8 -1
- data/lib/cfndsl/jsonable.rb +14 -0
- data/lib/cfndsl/version.rb +1 -1
- data/sample/config_service.rb +1 -1
- data/spec/cli_spec.rb +14 -0
- data/spec/resource_name_spec.rb +21 -0
- data/spec/spec_helper.rb +1 -1
- metadata +12 -6
@@ -0,0 +1,86 @@
|
|
1
|
+
{
|
2
|
+
"ResourceTypes": {
|
3
|
+
"AWS::Lambda::Permission": {
|
4
|
+
"patch": {
|
5
|
+
"description": "Permission scrutiny",
|
6
|
+
"operations": [
|
7
|
+
{
|
8
|
+
"op": "add",
|
9
|
+
"path": "/ScrutinyType",
|
10
|
+
"value": "LambdaPermission"
|
11
|
+
}
|
12
|
+
]
|
13
|
+
}
|
14
|
+
},
|
15
|
+
"AWS::SNS::Subscription": {
|
16
|
+
"patch": {
|
17
|
+
"description": "SNS: These are not IAM policies",
|
18
|
+
"operations": [
|
19
|
+
{
|
20
|
+
"op": "add",
|
21
|
+
"path": "/Properties/DeliveryPolicy/ScrutinyType",
|
22
|
+
"value": "None"
|
23
|
+
},
|
24
|
+
{
|
25
|
+
"op": "add",
|
26
|
+
"path": "/Properties/FilterPolicy/ScrutinyType",
|
27
|
+
"value": "None"
|
28
|
+
}
|
29
|
+
]
|
30
|
+
}
|
31
|
+
},
|
32
|
+
"AWS::SQS::Queue": {
|
33
|
+
"patch": {
|
34
|
+
"description": "SQS: Not an IAM policy",
|
35
|
+
"operations": [
|
36
|
+
{
|
37
|
+
"op": "add",
|
38
|
+
"path": "/Properties/RedrivePolicy/ScrutinyType",
|
39
|
+
"value": "None"
|
40
|
+
}
|
41
|
+
]
|
42
|
+
}
|
43
|
+
},
|
44
|
+
"AWS::EC2::SecurityGroup": {
|
45
|
+
"patch": {
|
46
|
+
"description": "SecurityGroup: Mark ingress/egress rules",
|
47
|
+
"operations": [
|
48
|
+
{
|
49
|
+
"op": "add",
|
50
|
+
"path": "/Properties/SecurityGroupIngress/ScrutinyType",
|
51
|
+
"value": "IngressRules"
|
52
|
+
},
|
53
|
+
{
|
54
|
+
"op": "add",
|
55
|
+
"path": "/Properties/SecurityGroupEgress/ScrutinyType",
|
56
|
+
"value": "EgressRules"
|
57
|
+
}
|
58
|
+
]
|
59
|
+
}
|
60
|
+
},
|
61
|
+
"AWS::EC2::SecurityGroupIngress": {
|
62
|
+
"patch": {
|
63
|
+
"description": "SecurityGroupIngress: Mark ingress rules",
|
64
|
+
"operations": [
|
65
|
+
{
|
66
|
+
"op": "add",
|
67
|
+
"path": "/ScrutinyType",
|
68
|
+
"value": "IngressRuleResource"
|
69
|
+
}
|
70
|
+
]
|
71
|
+
}
|
72
|
+
},
|
73
|
+
"AWS::EC2::SecurityGroupEgress": {
|
74
|
+
"patch": {
|
75
|
+
"description": "SecurityGroupEgress: Mark egress rules",
|
76
|
+
"operations": [
|
77
|
+
{
|
78
|
+
"op": "add",
|
79
|
+
"path": "/ScrutinyType",
|
80
|
+
"value": "EgressRuleResource"
|
81
|
+
}
|
82
|
+
]
|
83
|
+
}
|
84
|
+
}
|
85
|
+
}
|
86
|
+
}
|
@@ -0,0 +1,16 @@
|
|
1
|
+
{
|
2
|
+
"ResourceTypes": {
|
3
|
+
"AWS::EC2::NetworkAclEntry": {
|
4
|
+
"patch": {
|
5
|
+
"description": "https://github.com/aws/aws-cdk/issues/1517",
|
6
|
+
"operations": [
|
7
|
+
{
|
8
|
+
"op": "add",
|
9
|
+
"path": "/Properties/CidrBlock/Required",
|
10
|
+
"value": false
|
11
|
+
}
|
12
|
+
]
|
13
|
+
}
|
14
|
+
}
|
15
|
+
}
|
16
|
+
}
|
@@ -0,0 +1,16 @@
|
|
1
|
+
{
|
2
|
+
"ResourceTypes": {
|
3
|
+
"AWS::ServiceDiscovery::Instance": {
|
4
|
+
"patch": {
|
5
|
+
"description": "Treat Map primitive type as Json",
|
6
|
+
"operations": [
|
7
|
+
{
|
8
|
+
"op": "replace",
|
9
|
+
"path": "/Properties/InstanceAttributes/PrimitiveType",
|
10
|
+
"value": "Json"
|
11
|
+
}
|
12
|
+
]
|
13
|
+
}
|
14
|
+
}
|
15
|
+
}
|
16
|
+
}
|
@@ -42,7 +42,14 @@ module CfnDsl
|
|
42
42
|
logstream.puts("Loading #{klass_name} file #{file}") if logstream
|
43
43
|
params.load_file file
|
44
44
|
when :raw
|
45
|
-
|
45
|
+
file_parts = file.split('=')
|
46
|
+
if file_parts[1].downcase == 'true'
|
47
|
+
params.set_param(file_parts[0], true)
|
48
|
+
elsif file_parts[1].downcase == 'false'
|
49
|
+
params.set_param(file_parts[0], false)
|
50
|
+
else
|
51
|
+
params.set_param(*file.split('='))
|
52
|
+
end
|
46
53
|
end
|
47
54
|
end
|
48
55
|
|
data/lib/cfndsl/jsonable.rb
CHANGED
@@ -133,6 +133,7 @@ module CfnDsl
|
|
133
133
|
# Instance variables that begin with two underscores have one of
|
134
134
|
# them removed.
|
135
135
|
def as_json(_options = {})
|
136
|
+
check_names
|
136
137
|
hash = {}
|
137
138
|
instance_variables.each do |var|
|
138
139
|
name = var[1..-1]
|
@@ -162,6 +163,19 @@ module CfnDsl
|
|
162
163
|
instance_eval(&block) if block_given?
|
163
164
|
self
|
164
165
|
end
|
166
|
+
|
167
|
+
private
|
168
|
+
|
169
|
+
def check_names
|
170
|
+
return if instance_variable_get('@Resources').nil?
|
171
|
+
|
172
|
+
instance_variable_get('@Resources').keys.each do |name|
|
173
|
+
next unless name !~ /\A\p{Alnum}+\z/
|
174
|
+
|
175
|
+
warn "Resource name: #{name} is invalid"
|
176
|
+
exit 1
|
177
|
+
end
|
178
|
+
end
|
165
179
|
end
|
166
180
|
|
167
181
|
# Handles all of the Fn:: objects
|
data/lib/cfndsl/version.rb
CHANGED
data/sample/config_service.rb
CHANGED
data/spec/cli_spec.rb
CHANGED
@@ -135,6 +135,20 @@ Specification ([0-9]+\.){2}[0-9]+ successfully written to #{ENV['HOME']}/.cfndsl
|
|
135
135
|
end
|
136
136
|
end
|
137
137
|
|
138
|
+
context 'cfndsl FILE --define VARIABLE=true' do
|
139
|
+
it 'interpolates the command line variable with value true in the CloudFormation template ' do
|
140
|
+
run_command 'cfndsl template.rb --define "DESC=true"'
|
141
|
+
expect(last_command_started).to have_output_on_stdout('{"AWSTemplateFormatVersion":"2010-09-09","Description":true}')
|
142
|
+
end
|
143
|
+
end
|
144
|
+
|
145
|
+
context 'cfndsl FILE --define VARIABLE=false' do
|
146
|
+
it 'interpolates the command line variable with value false in the CloudFormation template ' do
|
147
|
+
run_command 'cfndsl template.rb --define "DESC=false"'
|
148
|
+
expect(last_command_started).to have_output_on_stdout('{"AWSTemplateFormatVersion":"2010-09-09","Description":"default"}')
|
149
|
+
end
|
150
|
+
end
|
151
|
+
|
138
152
|
context 'cfndsl FILE --verbose' do
|
139
153
|
before { write_file('params.yaml', 'DESC: yaml') }
|
140
154
|
|
@@ -0,0 +1,21 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe 'cfndsl', type: :aruba do
|
6
|
+
let(:template_content) do
|
7
|
+
<<-TEMPLATE.gsub(/^ {6}/, '')
|
8
|
+
CloudFormation do
|
9
|
+
EC2_Instance(:my_instance) do
|
10
|
+
end
|
11
|
+
end
|
12
|
+
TEMPLATE
|
13
|
+
end
|
14
|
+
before(:each) { write_file('template.rb', template_content) }
|
15
|
+
context 'cfndsl FILE' do
|
16
|
+
it 'errors because the name is invalid' do
|
17
|
+
run_command 'cfndsl template.rb'
|
18
|
+
expect(last_command_started).to have_output_on_stderr('Resource name: my_instance is invalid')
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/spec/spec_helper.rb
CHANGED
@@ -15,4 +15,4 @@ require 'cfndsl/globals'
|
|
15
15
|
# use local fixture for tests
|
16
16
|
CfnDsl.specification_file CfnDsl::LOCAL_SPEC_FILE
|
17
17
|
require 'cfndsl'
|
18
|
-
Dir[File.expand_path('support/**/*.rb', __dir__)].each { |f| require f }
|
18
|
+
Dir[File.expand_path('support/**/*.rb', __dir__)].sort.each { |f| require f }
|
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: 1.0.0
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Steven Jack
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: exe
|
13
13
|
cert_chain: []
|
14
|
-
date:
|
14
|
+
date: 2020-01-16 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: bundler
|
@@ -19,14 +19,14 @@ dependencies:
|
|
19
19
|
requirements:
|
20
20
|
- - "~>"
|
21
21
|
- !ruby/object:Gem::Version
|
22
|
-
version: '2.
|
22
|
+
version: '2.1'
|
23
23
|
type: :development
|
24
24
|
prerelease: false
|
25
25
|
version_requirements: !ruby/object:Gem::Requirement
|
26
26
|
requirements:
|
27
27
|
- - "~>"
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version: '2.
|
29
|
+
version: '2.1'
|
30
30
|
- !ruby/object:Gem::Dependency
|
31
31
|
name: hana
|
32
32
|
requirement: !ruby/object:Gem::Requirement
|
@@ -66,15 +66,19 @@ files:
|
|
66
66
|
- exe/cfndsl
|
67
67
|
- lib/cfndsl.rb
|
68
68
|
- lib/cfndsl/aws/cloud_formation_template.rb
|
69
|
+
- lib/cfndsl/aws/patches/000_CloudFormationResourceSpecification.json
|
69
70
|
- lib/cfndsl/aws/patches/000_sam.spec.json
|
70
71
|
- lib/cfndsl/aws/patches/100_sam.spec_DeploymentPreference_patch.json
|
72
|
+
- lib/cfndsl/aws/patches/200_Scrutinies_patch.json
|
71
73
|
- lib/cfndsl/aws/patches/500_Cognito_IdentityPoolRoleAttachment_patches.json
|
72
74
|
- lib/cfndsl/aws/patches/500_IoT1Click_patch_PlacementTemplate_DeviceTemplates.json
|
75
|
+
- lib/cfndsl/aws/patches/500_NetworkAclEntry_patch.json
|
73
76
|
- lib/cfndsl/aws/patches/500_SAM_Serverless_Function_S3Event_Events_patch.json
|
74
77
|
- lib/cfndsl/aws/patches/500_SAM_Serverless_Function_S3Location_Version_patch.json
|
75
78
|
- lib/cfndsl/aws/patches/500_SSM_AssociationName_patch.json
|
76
79
|
- lib/cfndsl/aws/patches/500_VPCEndpoint_patch.json
|
77
80
|
- lib/cfndsl/aws/patches/510_ElasticSearch_Domain_patches.json
|
81
|
+
- lib/cfndsl/aws/patches/520_ServiceDiscovery_InstanceAttributes_patch.json
|
78
82
|
- lib/cfndsl/aws/patches/600_RefKinds_patch.json
|
79
83
|
- lib/cfndsl/aws/patches/700_SAM_Serverless_Function_InlineCode_patch.json
|
80
84
|
- lib/cfndsl/aws/patches/800_List_types_patch.json
|
@@ -159,6 +163,7 @@ files:
|
|
159
163
|
- spec/names_spec.rb
|
160
164
|
- spec/output_spec.rb
|
161
165
|
- spec/plurals_spec.rb
|
166
|
+
- spec/resource_name_spec.rb
|
162
167
|
- spec/resources_spec.rb
|
163
168
|
- spec/rule_spec.rb
|
164
169
|
- spec/spec_helper.rb
|
@@ -180,9 +185,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
180
185
|
version: '2.3'
|
181
186
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
182
187
|
requirements:
|
183
|
-
- - "
|
188
|
+
- - ">="
|
184
189
|
- !ruby/object:Gem::Version
|
185
|
-
version:
|
190
|
+
version: '0'
|
186
191
|
requirements: []
|
187
192
|
rubyforge_project:
|
188
193
|
rubygems_version: 2.7.7
|
@@ -221,6 +226,7 @@ test_files:
|
|
221
226
|
- spec/names_spec.rb
|
222
227
|
- spec/output_spec.rb
|
223
228
|
- spec/plurals_spec.rb
|
229
|
+
- spec/resource_name_spec.rb
|
224
230
|
- spec/resources_spec.rb
|
225
231
|
- spec/rule_spec.rb
|
226
232
|
- spec/spec_helper.rb
|