cfndsl 0.17.5 → 1.0.0.pre.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (86) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/.rubocop.yml +4 -4
  4. data/.travis.yml +6 -1
  5. data/CHANGELOG.md +32 -34
  6. data/README.md +68 -21
  7. data/Rakefile +25 -3
  8. data/TODO.md +18 -0
  9. data/UPGRADING.md +22 -0
  10. data/cfndsl.gemspec +3 -3
  11. data/exe/cfndsl +5 -0
  12. data/lib/cfndsl.rb +2 -116
  13. data/lib/cfndsl/aws/cloud_formation_template.rb +8 -1
  14. data/lib/cfndsl/aws/patches/000_sam.spec.json +574 -0
  15. data/lib/cfndsl/aws/patches/100_sam.spec_DeploymentPreference_patch.json +64 -0
  16. data/lib/cfndsl/aws/patches/500_Cognito_IdentityPoolRoleAttachment_patches.json +25 -0
  17. data/lib/cfndsl/aws/patches/500_IoT1Click_patch_PlacementTemplate_DeviceTemplates.json +20 -0
  18. data/lib/cfndsl/aws/patches/500_SAM_Serverless_Function_S3Event_Events_patch.json +16 -0
  19. data/lib/cfndsl/aws/patches/500_SAM_Serverless_Function_S3Location_Version_patch.json +16 -0
  20. data/lib/cfndsl/aws/patches/500_SSM_AssociationName_patch.json +16 -0
  21. data/lib/cfndsl/aws/patches/500_VPCEndpoint_patch.json +17 -0
  22. data/lib/cfndsl/aws/patches/510_ElasticSearch_Domain_patches.json +15 -0
  23. data/lib/cfndsl/aws/patches/600_RefKinds_patch.json +3654 -0
  24. data/lib/cfndsl/aws/patches/700_SAM_Serverless_Function_InlineCode_patch.json +20 -0
  25. data/lib/cfndsl/aws/patches/800_List_types_patch.json +115 -0
  26. data/lib/cfndsl/aws/resource_specification.json +35809 -11627
  27. data/lib/cfndsl/aws/types.rb +3 -3
  28. data/lib/cfndsl/cfnlego.rb +34 -0
  29. data/lib/{cfnlego → cfndsl/cfnlego}/cloudformation.erb +0 -0
  30. data/lib/{cfnlego → cfndsl/cfnlego}/cloudformation.rb +0 -0
  31. data/lib/{cfnlego → cfndsl/cfnlego}/resource.rb +3 -8
  32. data/lib/cfndsl/cloudformation.rb +107 -0
  33. data/lib/cfndsl/conditions.rb +11 -1
  34. data/lib/cfndsl/creation_policy.rb +1 -1
  35. data/lib/cfndsl/deep_merge.rb +4 -0
  36. data/lib/cfndsl/external_parameters.rb +4 -13
  37. data/lib/cfndsl/globals.rb +48 -9
  38. data/lib/cfndsl/jsonable.rb +22 -60
  39. data/lib/cfndsl/mappings.rb +1 -1
  40. data/lib/cfndsl/module.rb +16 -5
  41. data/lib/cfndsl/orchestration_template.rb +185 -83
  42. data/lib/cfndsl/outputs.rb +5 -1
  43. data/lib/cfndsl/parameters.rb +1 -1
  44. data/lib/cfndsl/plurals.rb +12 -1
  45. data/lib/cfndsl/properties.rb +1 -1
  46. data/lib/cfndsl/rake_task.rb +206 -12
  47. data/lib/cfndsl/ref_check.rb +19 -11
  48. data/lib/cfndsl/resources.rb +6 -19
  49. data/lib/cfndsl/rules.rb +1 -1
  50. data/lib/cfndsl/runner.rb +143 -0
  51. data/lib/cfndsl/specification.rb +80 -95
  52. data/lib/cfndsl/types.rb +205 -91
  53. data/lib/cfndsl/update_policy.rb +1 -1
  54. data/lib/cfndsl/version.rb +1 -1
  55. data/sample/autoscale.rb +0 -1
  56. data/sample/autoscale2.rb +0 -1
  57. data/sample/config_service.rb +2 -2
  58. data/sample/t1.rb +1 -1
  59. data/sample/vpc_example.rb +1 -1
  60. data/sample/vpc_with_vpn_example.rb +1 -1
  61. data/spec/aws/list_type_patches_spec.rb +35 -0
  62. data/spec/aws/nested_arrays_spec.rb +155 -3
  63. data/spec/aws/serverless_spec.rb +0 -2
  64. data/spec/cfndsl_spec.rb +94 -78
  65. data/spec/cli_spec.rb +16 -54
  66. data/spec/cloud_formation_template_spec.rb +233 -0
  67. data/spec/condition_spec.rb +24 -0
  68. data/spec/direct_ruby_spec.rb +19 -0
  69. data/spec/external_parameters_spec.rb +2 -15
  70. data/spec/fixtures/condition-assertion.json +1 -0
  71. data/spec/fixtures/test.rb +2 -1
  72. data/spec/generate_spec.rb +4 -2
  73. data/spec/resources_spec.rb +0 -7
  74. data/spec/spec_helper.rb +2 -7
  75. data/spec/support/shared_examples/orchestration_template.rb +15 -2
  76. data/spec/types_definition_spec.rb +3 -6
  77. metadata +52 -23
  78. data/bin/cfndsl +0 -160
  79. data/lib/cfndsl/errors.rb +0 -31
  80. data/lib/cfndsl/os/heat_template.rb +0 -18
  81. data/lib/cfndsl/os/types.rb +0 -14
  82. data/lib/cfndsl/os/types.yaml +0 -2423
  83. data/lib/cfndsl/patches.rb +0 -226
  84. data/lib/cfnlego.rb +0 -44
  85. data/spec/fixtures/heattest.rb +0 -24
  86. data/spec/heat_template_spec.rb +0 -7
@@ -1,226 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module CfnDsl
4
- # Module for handling inconsistencies in the published resource specification from AWS
5
- # rubocop:disable Metrics/ModuleLength
6
- module Patches
7
- # Missing/malformed resources from the resource specification
8
- # rubocop:disable Metrics/MethodLength
9
- def self.resources
10
- {
11
- 'AWS::EC2::VPCEndpoint' => {
12
- 'Properties' => {
13
- 'PolicyDocument' => { 'PrimitiveType' => 'Json' },
14
- 'PrivateDnsEnabled' => { 'PrimitiveType' => 'Boolean' },
15
- 'RouteTableIds' => { 'PrimitiveType' => 'String' },
16
- 'SecurityGroupIds' => { 'PrimitiveType' => 'String' },
17
- 'ServiceName' => { 'PrimitiveType' => 'String' },
18
- 'SubnetIds' => { 'PrimitiveType' => 'String' },
19
- 'VpcEndpointType' => { 'PrimitiveType' => 'String' },
20
- 'VpcId' => { 'PrimitiveType' => 'String' }
21
- }
22
- },
23
- 'AWS::CloudWatch::Alarm' => {
24
- 'Properties' => {
25
- 'ActionsEnabled' => { 'PrimitiveType' => 'Boolean' },
26
- 'AlarmActions' => { 'Type' => 'List', 'PrimitiveType' => 'String' },
27
- 'AlarmDescription' => { 'PrimitiveType' => 'String' },
28
- 'AlarmName' => { 'PrimitiveType' => 'String' },
29
- 'ComparisonOperator' => { 'PrimitiveType' => 'String' },
30
- 'DatapointsToAlarm' => { 'PrimitiveType' => 'Integer' },
31
- 'Dimensions' => { 'Type' => 'List', 'ItemType' => 'Dimension' },
32
- 'EvaluateLowSampleCountPercentile' => { 'PrimitiveType' => 'String' },
33
- 'EvaluationPeriods' => { 'PrimitiveType' => 'Integer' },
34
- 'ExtendedStatistic' => { 'PrimitiveType' => 'String' },
35
- 'InsufficientDataActions' => { 'Type' => 'List', 'PrimitiveType' => 'String' },
36
- 'Metrics' => { 'Type' => 'List', 'PrimitiveType' => 'Json' },
37
- 'MetricName' => { 'PrimitiveType' => 'String' },
38
- 'Namespace' => { 'PrimitiveType' => 'String' },
39
- 'OKActions' => { 'Type' => 'List', 'PrimitiveType' => 'String' },
40
- 'Period' => { 'PrimitiveType' => 'Integer' },
41
- 'Statistic' => { 'PrimitiveType' => 'String' },
42
- 'Threshold' => { 'PrimitiveType' => 'Double' },
43
- 'TreatMissingData' => { 'PrimitiveType' => 'String' },
44
- 'Unit' => { 'PrimitiveType' => 'String' }
45
- }
46
- },
47
- 'AWS::Serverless::Function' => {
48
- 'Properties' => {
49
- 'Tags' => { 'PrimitiveType' => 'Json', 'ItemType' => 'String' },
50
- 'Handler' => { 'PrimitiveType' => 'String' },
51
- 'Runtime' => { 'PrimitiveType' => 'String' },
52
- 'CodeUri' => { 'PrimitiveType' => 'String' },
53
- 'InlineCode' => { 'PrimitiveType' => 'String' },
54
- 'FunctionName' => { 'PrimitiveType' => 'String' },
55
- 'Description' => { 'PrimitiveType' => 'String' },
56
- 'MemorySize' => { 'PrimitiveType' => 'Integer' },
57
- 'Timeout' => { 'PrimitiveType' => 'Integer' },
58
- 'Role' => { 'PrimitiveType' => 'String' },
59
- 'Policies' => { 'Type' => 'List', 'ItemType' => 'Policy' },
60
- 'Environment' => { 'PrimitiveType' => 'Json' },
61
- 'VpcConfig' => { 'Type' => 'VpcConfig' },
62
- 'Events' => { 'PrimitiveType' => 'Json' },
63
- 'Tracing' => { 'PrimitiveType' => 'String' },
64
- 'KmsKeyArn' => { 'PrimitiveType' => 'String' },
65
- 'DeadLetterQueue' => { 'PrimitiveType' => 'Json' },
66
- 'DeploymentPreference' => { 'Type' => 'DeploymentPreference' },
67
- 'AutoPublishAlias' => { 'PrimitiveType' => 'String' },
68
- 'ReservedConcurrentExecutions' => { 'PrimitiveType' => 'Integer' }
69
- }
70
- },
71
- 'AWS::IAM::Role' => {
72
- 'Properties' => {
73
- 'Tags' => { 'ItemType' => 'Tag', 'Type' => 'List' },
74
- 'AssumeRolePolicyDocument' => { 'PrimitiveType' => 'Json' },
75
- 'ManagedPolicyArns' => { 'PrimitiveItemType' => 'String', 'Type' => 'List' },
76
- 'Path' => { 'PrimitiveType' => 'String' },
77
- 'Policies' => { 'ItemType' => 'Policy', 'Type' => 'List' },
78
- 'RoleName' => { 'PrimitiveType' => 'String' }
79
- }
80
- },
81
- 'AWS::Serverless::Api' => {
82
- 'Properties' => {
83
- 'Name' => { 'PrimitiveType' => 'String' },
84
- 'StageName' => { 'PrimitiveType' => 'String' },
85
- 'DefinitionUri' => { 'PrimitiveType' => 'String' },
86
- 'DefinitionBody' => { 'PrimitiveType' => 'Json' },
87
- 'CacheClusterEnabled' => { 'PrimitiveType' => 'Boolean' },
88
- 'CacheClusterSize' => { 'PrimitiveType' => 'String' },
89
- 'Variables' => { 'PrimitiveType' => 'Json' },
90
- 'MethodSettings' => { 'PrimitiveType' => 'Json' },
91
- 'EndpointConfiguration' => { 'PrimitiveType' => 'String' },
92
- 'BinaryMediaTypes' => { 'Type' => 'List', 'PrimitiveType' => 'String' },
93
- 'Cors' => { 'PrimitiveType' => 'String' }
94
- }
95
- },
96
- 'AWS::Serverless::SimpleTable' => {
97
- 'Properties' => {
98
- 'PrimaryKey' => { 'Type' => 'PrimaryKey' },
99
- 'ProvisionedThroughput' => { 'Type' => 'ProvisionedThroughput' },
100
- 'Tags' => { 'PrimitiveType' => 'Json', 'ItemType' => 'String' },
101
- 'TableName' => { 'PrimitiveType' => 'String' }
102
- }
103
- },
104
- 'AWS::Serverless::Application' => {
105
- 'Properties' => {
106
- 'Location' => { 'PrimitiveType' => 'String' },
107
- 'Parameters' => { 'PrimitiveType' => 'Json', 'ItemType' => 'String' },
108
- 'NotificationARNs' => { 'PrimitiveType' => 'String' },
109
- 'Tags' => { 'PrimitiveType' => 'Json', 'ItemType' => 'String' },
110
- 'TimeoutInMinutes' => { 'PrimitiveType' => 'Integer' }
111
- }
112
- },
113
- 'AWS::SSM::Parameter' => {
114
- 'Properties' => {
115
- 'Name' => { 'PrimitiveType' => 'String' },
116
- 'Description' => { 'PrimitiveType' => 'String' },
117
- 'Type' => { 'PrimitiveType' => 'String' },
118
- 'Value' => { 'PrimitiveType' => 'String' }
119
- }
120
- }
121
- }
122
- end
123
- # rubocop:enable Metrics/MethodLength
124
-
125
- # Missing/malformed types from the resource specification
126
- # rubocop:disable Metrics/MethodLength
127
- def self.types
128
- {
129
- 'AWS::WAFv2::IPSet.Tag' => {
130
- 'Properties' => {
131
- 'Value' => { 'PrimitiveType' => 'String' },
132
- 'Key' => { 'PrimitiveType' => 'String' }
133
- }
134
- },
135
- 'AWS::WAFv2::RegexPatternSet.Tag' => {
136
- 'Properties' => {
137
- 'Value' => { 'PrimitiveType' => 'String' },
138
- 'Key' => { 'PrimitiveType' => 'String' }
139
- }
140
- },
141
- 'AWS::WAFv2::RuleGroup.Tag' => {
142
- 'Properties' => {
143
- 'Value' => { 'PrimitiveType' => 'String' },
144
- 'Key' => { 'PrimitiveType' => 'String' }
145
- }
146
- },
147
- 'AWS::WAFv2::WebACL.Tag' => {
148
- 'Properties' => {
149
- 'Value' => { 'PrimitiveType' => 'String' },
150
- 'Key' => { 'PrimitiveType' => 'String' }
151
- }
152
- },
153
- 'AWS::EC2::LaunchTemplate.Tag' => {
154
- 'Properties' => {
155
- 'Value' => { 'PrimitiveType' => 'String' },
156
- 'Key' => { 'PrimitiveType' => 'String' }
157
- }
158
- },
159
- 'AWS::EC2::SpotFleet.Tag' => {
160
- 'Properties' => {
161
- 'Value' => { 'PrimitiveType' => 'String' },
162
- 'Key' => { 'PrimitiveType' => 'String' }
163
- }
164
- },
165
- 'AWS::EC2::CapacityReservation.Tag' => {
166
- 'Properties' => {
167
- 'Value' => { 'PrimitiveType' => 'String' },
168
- 'Key' => { 'PrimitiveType' => 'String' }
169
- }
170
- },
171
- 'AWS::DLM::LifecyclePolicy.Tag' => {
172
- 'Properties' => {
173
- 'Value' => { 'PrimitiveType' => 'String' },
174
- 'Key' => { 'PrimitiveType' => 'String' }
175
- }
176
- },
177
- 'AWS::Api::GatewayDeployment.Tag' => {
178
- 'Properties' => {
179
- 'Value' => { 'PrimitiveType' => 'String' },
180
- 'Key' => { 'PrimitiveType' => 'String' }
181
- }
182
- },
183
- 'AWS::EC2::ClientVpnEndpoint.Tag' => {
184
- 'Properties' => {
185
- 'Value' => { 'PrimitiveType' => 'String' },
186
- 'Key' => { 'PrimitiveType' => 'String' }
187
- }
188
- },
189
- 'AWS::Serverless::SimpleTable.PrimaryKey' => {
190
- 'Properties' => {
191
- 'Name' => { 'PrimitiveType' => 'String' },
192
- 'Type' => { 'PrimitiveType' => 'String' }
193
- }
194
- },
195
- 'AWS::Serverless::SimpleTable.ProvisionedThroughput' => {
196
- 'Properties' => {
197
- 'ReadCapacityUnits' => { 'PrimitiveType' => 'Integer' },
198
- 'WriteCapacityUnits' => { 'PrimitiveType' => 'Integer' }
199
- }
200
- },
201
- 'AWS::Serverless::Function.Policy' => {
202
- 'Properties' => {
203
- 'PolicyDocument' => { 'PrimitiveType' => 'Json' },
204
- 'PolicyName' => { 'PrimitiveType' => 'String' }
205
- }
206
- },
207
- 'AWS::Serverless::Function.VpcConfig' => {
208
- 'Properties' => {
209
- 'SecurityGroupIds' => { 'Type' => 'List', 'PrimitiveType' => 'String' },
210
- 'SubnetIds' => { 'Type' => 'List', 'PrimitiveType' => 'String' }
211
- }
212
- },
213
- 'AWS::Serverless::Function.DeploymentPreference' => {
214
- 'Properties' => {
215
- 'Enabled' => { 'PrimitiveType' => 'Boolean' },
216
- 'Type' => { 'PrimitiveType' => 'String' },
217
- 'Alarms' => { 'Type' => 'List', 'PrimitiveType' => 'String' },
218
- 'Hooks' => { 'Type' => 'List', 'PrimitiveType' => 'String' }
219
- }
220
- }
221
- }
222
- end
223
- # rubocop:enable Metrics/MethodLength
224
- end
225
- # rubocop:enable Metrics/ModuleLength
226
- end
data/lib/cfnlego.rb DELETED
@@ -1,44 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'yaml'
4
- require 'erb'
5
- require 'cfnlego/cloudformation'
6
- require 'cfnlego/resource'
7
- require 'net/http'
8
- require 'uri'
9
-
10
- # Cfnlego
11
- module Cfnlego
12
- def self.Resources
13
- content = fetch_resource_content
14
- supported_resources = JSON.parse(content)
15
- resources = []
16
- supported_resources['ResourceTypes'].each_key do |resource|
17
- resources << resource
18
- end
19
- resources
20
- end
21
-
22
- def self.fetch_resource_content
23
- File.read(CfnDsl.specification_file)
24
- end
25
-
26
- def self.run(options)
27
- # Constructure Resources
28
- resources = []
29
- options[:resources].each do |r|
30
- /(.*),(.*)/.match(r) do |m|
31
- type = m[1]
32
- name = m[2]
33
- resources << Cfnlego::Resource.new(type, name)
34
- end
35
- end
36
-
37
- begin
38
- return Cfnlego::CloudFormation.new(resources).render
39
- rescue RuntimeError => e
40
- warn "Error: #{e.message}"
41
- end
42
- nil
43
- end
44
- end
@@ -1,24 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- Heat do
4
- Description 'Test'
5
-
6
- Parameter('One') do
7
- String
8
- Default 'Test'
9
- MaxLength 15
10
- end
11
-
12
- Parameter('Two') do
13
- String
14
- Default 'Test'
15
- MaxLength 15
16
- end
17
-
18
- Output(:One, FnBase64(Ref('One')))
19
-
20
- Server('MyInstance') do
21
- flavor 'asdfa'
22
- image 'asdad'
23
- end
24
- end
@@ -1,7 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
-
5
- describe CfnDsl::HeatTemplate do
6
- it_behaves_like 'an orchestration template'
7
- end