cfndsl 0.17.5 → 1.0.0.pre.1
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/.gitignore +1 -0
- data/.rubocop.yml +4 -4
- data/.travis.yml +6 -1
- data/CHANGELOG.md +32 -34
- data/README.md +68 -21
- data/Rakefile +25 -3
- data/TODO.md +18 -0
- data/UPGRADING.md +22 -0
- data/cfndsl.gemspec +3 -3
- data/exe/cfndsl +5 -0
- data/lib/cfndsl.rb +2 -116
- data/lib/cfndsl/aws/cloud_formation_template.rb +8 -1
- data/lib/cfndsl/aws/patches/000_sam.spec.json +574 -0
- data/lib/cfndsl/aws/patches/100_sam.spec_DeploymentPreference_patch.json +64 -0
- data/lib/cfndsl/aws/patches/500_Cognito_IdentityPoolRoleAttachment_patches.json +25 -0
- data/lib/cfndsl/aws/patches/500_IoT1Click_patch_PlacementTemplate_DeviceTemplates.json +20 -0
- data/lib/cfndsl/aws/patches/500_SAM_Serverless_Function_S3Event_Events_patch.json +16 -0
- data/lib/cfndsl/aws/patches/500_SAM_Serverless_Function_S3Location_Version_patch.json +16 -0
- data/lib/cfndsl/aws/patches/500_SSM_AssociationName_patch.json +16 -0
- data/lib/cfndsl/aws/patches/500_VPCEndpoint_patch.json +17 -0
- data/lib/cfndsl/aws/patches/510_ElasticSearch_Domain_patches.json +15 -0
- data/lib/cfndsl/aws/patches/600_RefKinds_patch.json +3654 -0
- data/lib/cfndsl/aws/patches/700_SAM_Serverless_Function_InlineCode_patch.json +20 -0
- data/lib/cfndsl/aws/patches/800_List_types_patch.json +115 -0
- data/lib/cfndsl/aws/resource_specification.json +35809 -11627
- data/lib/cfndsl/aws/types.rb +3 -3
- data/lib/cfndsl/cfnlego.rb +34 -0
- data/lib/{cfnlego → cfndsl/cfnlego}/cloudformation.erb +0 -0
- data/lib/{cfnlego → cfndsl/cfnlego}/cloudformation.rb +0 -0
- data/lib/{cfnlego → cfndsl/cfnlego}/resource.rb +3 -8
- data/lib/cfndsl/cloudformation.rb +107 -0
- data/lib/cfndsl/conditions.rb +11 -1
- data/lib/cfndsl/creation_policy.rb +1 -1
- data/lib/cfndsl/deep_merge.rb +4 -0
- data/lib/cfndsl/external_parameters.rb +4 -13
- data/lib/cfndsl/globals.rb +48 -9
- data/lib/cfndsl/jsonable.rb +22 -60
- data/lib/cfndsl/mappings.rb +1 -1
- data/lib/cfndsl/module.rb +16 -5
- data/lib/cfndsl/orchestration_template.rb +185 -83
- data/lib/cfndsl/outputs.rb +5 -1
- data/lib/cfndsl/parameters.rb +1 -1
- data/lib/cfndsl/plurals.rb +12 -1
- data/lib/cfndsl/properties.rb +1 -1
- data/lib/cfndsl/rake_task.rb +206 -12
- data/lib/cfndsl/ref_check.rb +19 -11
- data/lib/cfndsl/resources.rb +6 -19
- data/lib/cfndsl/rules.rb +1 -1
- data/lib/cfndsl/runner.rb +143 -0
- data/lib/cfndsl/specification.rb +80 -95
- data/lib/cfndsl/types.rb +205 -91
- data/lib/cfndsl/update_policy.rb +1 -1
- data/lib/cfndsl/version.rb +1 -1
- data/sample/autoscale.rb +0 -1
- data/sample/autoscale2.rb +0 -1
- data/sample/config_service.rb +2 -2
- data/sample/t1.rb +1 -1
- data/sample/vpc_example.rb +1 -1
- data/sample/vpc_with_vpn_example.rb +1 -1
- data/spec/aws/list_type_patches_spec.rb +35 -0
- data/spec/aws/nested_arrays_spec.rb +155 -3
- data/spec/aws/serverless_spec.rb +0 -2
- data/spec/cfndsl_spec.rb +94 -78
- data/spec/cli_spec.rb +16 -54
- data/spec/cloud_formation_template_spec.rb +233 -0
- data/spec/condition_spec.rb +24 -0
- data/spec/direct_ruby_spec.rb +19 -0
- data/spec/external_parameters_spec.rb +2 -15
- data/spec/fixtures/condition-assertion.json +1 -0
- data/spec/fixtures/test.rb +2 -1
- data/spec/generate_spec.rb +4 -2
- data/spec/resources_spec.rb +0 -7
- data/spec/spec_helper.rb +2 -7
- data/spec/support/shared_examples/orchestration_template.rb +15 -2
- data/spec/types_definition_spec.rb +3 -6
- metadata +52 -23
- data/bin/cfndsl +0 -160
- data/lib/cfndsl/errors.rb +0 -31
- data/lib/cfndsl/os/heat_template.rb +0 -18
- data/lib/cfndsl/os/types.rb +0 -14
- data/lib/cfndsl/os/types.yaml +0 -2423
- data/lib/cfndsl/patches.rb +0 -226
- data/lib/cfnlego.rb +0 -44
- data/spec/fixtures/heattest.rb +0 -24
- data/spec/heat_template_spec.rb +0 -7
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 84bb2754062bcfe3c1e94d9416c7a1ef31110422e092ed272bd9acf205801588
|
|
4
|
+
data.tar.gz: 582d059bd1bc0735b72379b55109d90e99ceb712811d488bbf7093de473fdd58
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: d82c1dab6b7a6ed165e57b24848e5d497b9d34c8208ecac944c76a12ac02801edb762d00bd099a68d7dccc218428ad10b07190c1ab292354b12b4fe747e21491
|
|
7
|
+
data.tar.gz: 1d91a0eda349c5fdfbca5c4bbd824468c7239b949f1b60c068490a69a659459e4dce64db0d7e0e5987f3d778873932481ae1ad2cc406771aafd2a51c206bfd12
|
data/.gitignore
CHANGED
data/.rubocop.yml
CHANGED
|
@@ -21,14 +21,14 @@ Naming/VariableName:
|
|
|
21
21
|
Naming/MethodName:
|
|
22
22
|
Enabled: false
|
|
23
23
|
|
|
24
|
-
# Because of the way FnFormat was developed
|
|
25
|
-
Style/FormatStringToken:
|
|
26
|
-
Enabled: false
|
|
27
|
-
|
|
28
24
|
# Lone String
|
|
29
25
|
Lint/Void:
|
|
30
26
|
Enabled: false
|
|
31
27
|
|
|
28
|
+
Style/SafeNavigation:
|
|
29
|
+
Enabled: false
|
|
30
|
+
|
|
32
31
|
AllCops:
|
|
32
|
+
TargetRubyVersion: 2.3
|
|
33
33
|
Exclude:
|
|
34
34
|
- 'tmp/**/*'
|
data/.travis.yml
CHANGED
data/CHANGELOG.md
CHANGED
|
@@ -1,36 +1,7 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
-
## [0.17.
|
|
4
|
-
[Full Changelog](https://github.com/cfndsl/cfndsl/compare/
|
|
5
|
-
|
|
6
|
-
**Fixed bugs:**
|
|
7
|
-
|
|
8
|
-
- VPCZoneIdentifier is always an array - 1.0.0.pre [\#428](https://github.com/cfndsl/cfndsl/issues/428)
|
|
9
|
-
|
|
10
|
-
**Closed issues:**
|
|
11
|
-
|
|
12
|
-
- Where should we define custom helper methods? [\#433](https://github.com/cfndsl/cfndsl/issues/433)
|
|
13
|
-
- undefined method `EC2\_LaunchTemplate' for \#\<CfnDsl::CloudFormationTemplate:...\> \(NoMethodError\) [\#431](https://github.com/cfndsl/cfndsl/issues/431)
|
|
14
|
-
- cfndsl fails with "uninitialized constant CfnDsl::AWS::Types::AWSWAFv2IPSetTag \(NameError\)" [\#430](https://github.com/cfndsl/cfndsl/issues/430)
|
|
15
|
-
|
|
16
|
-
**Merged pull requests:**
|
|
17
|
-
|
|
18
|
-
- add tag types to new WAFv2, as AWS are not explicitly defining them in the spec [\#435](https://github.com/cfndsl/cfndsl/pull/435) ([gergnz](https://github.com/gergnz))
|
|
19
|
-
|
|
20
|
-
## [v1.0.0.pre.1](https://github.com/cfndsl/cfndsl/tree/v1.0.0.pre.1) (2019-10-27)
|
|
21
|
-
[Full Changelog](https://github.com/cfndsl/cfndsl/compare/v1.0.0.pre.2...v1.0.0.pre.1)
|
|
22
|
-
|
|
23
|
-
## [v1.0.0.pre.2](https://github.com/cfndsl/cfndsl/tree/v1.0.0.pre.2) (2019-10-27)
|
|
24
|
-
[Full Changelog](https://github.com/cfndsl/cfndsl/compare/v0.17.4...v1.0.0.pre.2)
|
|
25
|
-
|
|
26
|
-
**Merged pull requests:**
|
|
27
|
-
|
|
28
|
-
- 1.0.0 pre rake and spec [\#427](https://github.com/cfndsl/cfndsl/pull/427) ([lwoggardner](https://github.com/lwoggardner))
|
|
29
|
-
- 1.0.0.pre merge fix403 [\#426](https://github.com/cfndsl/cfndsl/pull/426) ([lwoggardner](https://github.com/lwoggardner))
|
|
30
|
-
- 1.0.0.pre merge with master [\#425](https://github.com/cfndsl/cfndsl/pull/425) ([lwoggardner](https://github.com/lwoggardner))
|
|
31
|
-
|
|
32
|
-
## [v0.17.4](https://github.com/cfndsl/cfndsl/tree/v0.17.4) (2019-10-06)
|
|
33
|
-
[Full Changelog](https://github.com/cfndsl/cfndsl/compare/v0.17.3...v0.17.4)
|
|
3
|
+
## [0.17.4](https://github.com/cfndsl/cfndsl/tree/0.17.4) (2019-10-06)
|
|
4
|
+
[Full Changelog](https://github.com/cfndsl/cfndsl/compare/v0.17.3...0.17.4)
|
|
34
5
|
|
|
35
6
|
**Closed issues:**
|
|
36
7
|
|
|
@@ -132,7 +103,7 @@
|
|
|
132
103
|
- handle simple resource types [\#397](https://github.com/cfndsl/cfndsl/pull/397) ([gergnz](https://github.com/gergnz))
|
|
133
104
|
|
|
134
105
|
## [v0.16.10](https://github.com/cfndsl/cfndsl/tree/v0.16.10) (2019-02-13)
|
|
135
|
-
[Full Changelog](https://github.com/cfndsl/cfndsl/compare/
|
|
106
|
+
[Full Changelog](https://github.com/cfndsl/cfndsl/compare/v1.0.0.pre...v0.16.10)
|
|
136
107
|
|
|
137
108
|
**Implemented enhancements:**
|
|
138
109
|
|
|
@@ -142,26 +113,53 @@
|
|
|
142
113
|
|
|
143
114
|
- confirm we are using gzip download of cloudfomration specification. [\#394](https://github.com/cfndsl/cfndsl/issues/394)
|
|
144
115
|
- support a version for cfndsl -u [\#393](https://github.com/cfndsl/cfndsl/issues/393)
|
|
116
|
+
|
|
117
|
+
## [v1.0.0.pre](https://github.com/cfndsl/cfndsl/tree/v1.0.0.pre) (2019-01-19)
|
|
118
|
+
[Full Changelog](https://github.com/cfndsl/cfndsl/compare/v0.17.pre.6...v1.0.0.pre)
|
|
119
|
+
|
|
120
|
+
**Closed issues:**
|
|
121
|
+
|
|
145
122
|
- 'require': cannot load such file -- hana \(0.17.pre.5\) [\#387](https://github.com/cfndsl/cfndsl/issues/387)
|
|
146
123
|
|
|
124
|
+
## [v0.17.pre.6](https://github.com/cfndsl/cfndsl/tree/v0.17.pre.6) (2018-12-10)
|
|
125
|
+
[Full Changelog](https://github.com/cfndsl/cfndsl/compare/v0.17.pre.5...v0.17.pre.6)
|
|
126
|
+
|
|
127
|
+
## [v0.17.pre.5](https://github.com/cfndsl/cfndsl/tree/v0.17.pre.5) (2018-12-09)
|
|
128
|
+
[Full Changelog](https://github.com/cfndsl/cfndsl/compare/v0.17.pre.4...v0.17.pre.5)
|
|
129
|
+
|
|
130
|
+
## [v0.17.pre.4](https://github.com/cfndsl/cfndsl/tree/v0.17.pre.4) (2018-12-09)
|
|
131
|
+
[Full Changelog](https://github.com/cfndsl/cfndsl/compare/v0.17.pre.3...v0.17.pre.4)
|
|
132
|
+
|
|
133
|
+
## [v0.17.pre.3](https://github.com/cfndsl/cfndsl/tree/v0.17.pre.3) (2018-12-09)
|
|
134
|
+
[Full Changelog](https://github.com/cfndsl/cfndsl/compare/v0.17.pre.2...v0.17.pre.3)
|
|
135
|
+
|
|
147
136
|
**Merged pull requests:**
|
|
148
137
|
|
|
149
138
|
- implement json patch for patches and pull in patches from CDK [\#386](https://github.com/cfndsl/cfndsl/pull/386) ([gergnz](https://github.com/gergnz))
|
|
150
139
|
|
|
140
|
+
## [v0.17.pre.2](https://github.com/cfndsl/cfndsl/tree/v0.17.pre.2) (2018-12-09)
|
|
141
|
+
[Full Changelog](https://github.com/cfndsl/cfndsl/compare/v0.16.9...v0.17.pre.2)
|
|
142
|
+
|
|
151
143
|
## [v0.16.9](https://github.com/cfndsl/cfndsl/tree/v0.16.9) (2018-12-07)
|
|
152
|
-
[Full Changelog](https://github.com/cfndsl/cfndsl/compare/v0.
|
|
144
|
+
[Full Changelog](https://github.com/cfndsl/cfndsl/compare/v0.17-pre...v0.16.9)
|
|
153
145
|
|
|
154
146
|
**Closed issues:**
|
|
155
147
|
|
|
156
148
|
- uninitialized constant CfnDsl::AWS::Types::Map [\#382](https://github.com/cfndsl/cfndsl/issues/382)
|
|
157
149
|
- Can't get -D option to work [\#360](https://github.com/cfndsl/cfndsl/issues/360)
|
|
158
|
-
- rubocop 0.50.0 errors [\#347](https://github.com/cfndsl/cfndsl/issues/347)
|
|
159
150
|
- CFN schema [\#264](https://github.com/cfndsl/cfndsl/issues/264)
|
|
160
151
|
|
|
161
152
|
**Merged pull requests:**
|
|
162
153
|
|
|
163
154
|
- fix \#382, add Map primitive type [\#383](https://github.com/cfndsl/cfndsl/pull/383) ([gergnz](https://github.com/gergnz))
|
|
164
155
|
|
|
156
|
+
## [v0.17-pre](https://github.com/cfndsl/cfndsl/tree/v0.17-pre) (2018-12-03)
|
|
157
|
+
[Full Changelog](https://github.com/cfndsl/cfndsl/compare/v0.16.8...v0.17-pre)
|
|
158
|
+
|
|
159
|
+
**Closed issues:**
|
|
160
|
+
|
|
161
|
+
- rubocop 0.50.0 errors [\#347](https://github.com/cfndsl/cfndsl/issues/347)
|
|
162
|
+
|
|
165
163
|
## [v0.16.8](https://github.com/cfndsl/cfndsl/tree/v0.16.8) (2018-11-21)
|
|
166
164
|
[Full Changelog](https://github.com/cfndsl/cfndsl/compare/v0.16.7...v0.16.8)
|
|
167
165
|
|
data/README.md
CHANGED
|
@@ -24,7 +24,7 @@ templates by running ruby.
|
|
|
24
24
|
|
|
25
25
|
## Getting Started
|
|
26
26
|
|
|
27
|
-
ruby version > 2.
|
|
27
|
+
ruby version > 2.4 is required to run cfndsl, you should look at using rbenv example for installing with rbenv
|
|
28
28
|
|
|
29
29
|
rbenv exec gem install cfndsl
|
|
30
30
|
|
|
@@ -38,7 +38,7 @@ Update the the cloudformation specification to the latest version.
|
|
|
38
38
|
|
|
39
39
|
or update to a specific version
|
|
40
40
|
|
|
41
|
-
cfndsl -u
|
|
41
|
+
cfndsl -u 7.1.0
|
|
42
42
|
|
|
43
43
|
Now write a template in the dsl
|
|
44
44
|
|
|
@@ -442,13 +442,11 @@ The cfndsl command line program now accepts some command line options.
|
|
|
442
442
|
Usage: cfndsl [options] FILE
|
|
443
443
|
-o, --output FILE Write output to file
|
|
444
444
|
-y, --yaml FILE Import yaml file as local variables
|
|
445
|
-
-r, --ruby FILE Evaluate ruby file before template
|
|
446
445
|
-j, --json FILE Import json file as local variables
|
|
447
446
|
-p, --pretty Pretty-format output JSON
|
|
448
447
|
-f, --format FORMAT Specify the output format (JSON default)
|
|
449
448
|
-D, --define "VARIABLE=VALUE" Directly set local VARIABLE as VALUE
|
|
450
449
|
-v, --verbose Turn on verbose ouptut
|
|
451
|
-
-b, --disable-binding Disable binding configuration
|
|
452
450
|
-m, --disable-deep-merge Disable deep merging of yaml
|
|
453
451
|
-s, --specification-file FILE Location of Cloudformation Resource Specification file
|
|
454
452
|
-u [VERSION], Update the Resource Specification file to latest, or specific version
|
|
@@ -569,38 +567,87 @@ would generate a template with 5 instances declared.
|
|
|
569
567
|
Specifying multiple -y options will default deep_merge all the yaml in the order specified.
|
|
570
568
|
You can disable this with -m.
|
|
571
569
|
|
|
572
|
-
Finally, the -r option gives you the opportunity to execute some
|
|
573
|
-
arbitrary ruby code in the evaluation context before the cloudformation
|
|
574
|
-
template is evaluated (this is not available if `--disable-binding` is used).
|
|
575
|
-
|
|
576
570
|
### Rake task
|
|
577
571
|
Simply add the following to your `Rakefile`:
|
|
578
572
|
|
|
579
573
|
```ruby
|
|
580
574
|
require 'cfndsl/rake_task'
|
|
581
575
|
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
576
|
+
namespace(:cfndsl) do
|
|
577
|
+
CfnDsl::RakeTask.new do |t|
|
|
578
|
+
# Use a custom specification file
|
|
579
|
+
t.specification(file: 'tmp/cloudformation_resources.json')
|
|
580
|
+
|
|
581
|
+
desc 'Generate CloudFormation Json'
|
|
582
|
+
t.json(name: :json, files: FileList.new('sample/*.rb'), pathmap: 'tmp/%f.json')
|
|
583
|
+
|
|
584
|
+
# Generate yaml output, loading an extra file that matches the source file
|
|
585
|
+
t.yaml(name: :yaml, files: 'sample/t1.rb', pathmap: 'tmp/%f.yaml', extras: '%X.yaml')
|
|
586
|
+
end
|
|
593
587
|
end
|
|
594
588
|
```
|
|
595
589
|
|
|
596
590
|
And then use rake to generate the cloudformation:
|
|
597
591
|
|
|
598
592
|
```bash
|
|
599
|
-
$ bin/rake generate
|
|
593
|
+
$ bin/rake cfndsl:generate
|
|
594
|
+
```
|
|
595
|
+
|
|
596
|
+
### Embedded Ruby
|
|
597
|
+
```ruby
|
|
598
|
+
|
|
599
|
+
# Optionally before requiring 'cfndsl' set global options
|
|
600
|
+
require `cfndsl/globals`
|
|
601
|
+
CfnDsl.specification_file(file) # Override location of json spec file
|
|
602
|
+
CfnDsl.disable_deep_merge # Prevent monkey patching of Hash with deep merge capabilities
|
|
603
|
+
|
|
604
|
+
require `cfndsl`
|
|
605
|
+
|
|
606
|
+
# As a function that takes a block of DSL
|
|
607
|
+
template = CloudFormation do
|
|
608
|
+
# Some CfnDsl
|
|
609
|
+
end
|
|
610
|
+
puts JSON.pretty_generate(template.validate)
|
|
611
|
+
|
|
612
|
+
# As a class that is a template
|
|
613
|
+
class MyTemplate < CfnDsl::CloudFormationTemplate
|
|
614
|
+
def initialize
|
|
615
|
+
super do
|
|
616
|
+
# Base DSL
|
|
617
|
+
end
|
|
618
|
+
end
|
|
619
|
+
|
|
620
|
+
def instance(logical_id)
|
|
621
|
+
this = self
|
|
622
|
+
EC2_Instance(logical_id) do
|
|
623
|
+
self.class.name # << 'CfnDsl::ResourceDefinition' not 'MyTemplate' !
|
|
624
|
+
InstanceType this.instance_type
|
|
625
|
+
end
|
|
626
|
+
end
|
|
627
|
+
|
|
628
|
+
#do not make this private!
|
|
629
|
+
def instance_type
|
|
630
|
+
't3.large'
|
|
631
|
+
end
|
|
632
|
+
end
|
|
633
|
+
|
|
634
|
+
# As a builder class
|
|
635
|
+
class Builder
|
|
636
|
+
include CfnDsl::CloudFormation
|
|
637
|
+
|
|
638
|
+
def model
|
|
639
|
+
this = self # the DSL blocks are executed via instance_eval
|
|
640
|
+
ref_param = Ref('param') # and other Fn::*
|
|
641
|
+
template = CloudFormation do
|
|
642
|
+
# Some DSL
|
|
643
|
+
end
|
|
644
|
+
template.validate.to_json
|
|
645
|
+
end
|
|
646
|
+
end
|
|
600
647
|
```
|
|
601
648
|
|
|
602
649
|
### Generating CloudFormation resources from cfndsl
|
|
603
|
-
By supplying the -g
|
|
650
|
+
By supplying the -g parameter you are now able to generate cloudformation resources for supported objects, for a list of supported resources run cfndsl -l
|
|
604
651
|
|
|
605
652
|
Example
|
|
606
653
|
```bash
|
data/Rakefile
CHANGED
|
@@ -6,6 +6,7 @@ require 'cfndsl/version'
|
|
|
6
6
|
require 'rubocop/rake_task'
|
|
7
7
|
require 'yamllint/rake_task'
|
|
8
8
|
require 'github_changelog_generator/task'
|
|
9
|
+
require 'cfndsl/rake_task'
|
|
9
10
|
|
|
10
11
|
RSpec::Core::RakeTask.new
|
|
11
12
|
RuboCop::RakeTask.new
|
|
@@ -18,16 +19,37 @@ end
|
|
|
18
19
|
|
|
19
20
|
YamlLint::RakeTask.new do |t|
|
|
20
21
|
t.paths = %w[
|
|
21
|
-
lib/cfndsl/aws/types.yaml
|
|
22
|
-
lib/cfndsl/os/types.yaml
|
|
23
22
|
sample/t1.yaml
|
|
24
23
|
.travis.yml
|
|
25
24
|
.rubocop.yml
|
|
26
25
|
]
|
|
27
26
|
end
|
|
28
27
|
|
|
29
|
-
task default: %i[spec rubocop yamllint]
|
|
28
|
+
task default: %i[clean spec rubocop yamllint samples:generate]
|
|
30
29
|
|
|
30
|
+
# Test our own rake task and samples
|
|
31
|
+
|
|
32
|
+
directory 'tmp'
|
|
33
|
+
|
|
34
|
+
namespace :samples do
|
|
35
|
+
source_files = FileList.new('sample/*.rb') { |fl| fl.exclude('**/circular.rb') }
|
|
36
|
+
|
|
37
|
+
CfnDsl::RakeTask.new do |t|
|
|
38
|
+
t.specification(file: 'tmp/cloudformation_resources.json')
|
|
39
|
+
desc 'Generate CloudFormation Json'
|
|
40
|
+
t.json(name: :json, files: source_files, pathmap: 'tmp/%f.json', pretty: true, extras: FileList.new('sample/*.yaml'))
|
|
41
|
+
t.yaml(name: :yaml, files: 'sample/t1.rb', pathmap: 'tmp/%f.yaml', extras: '%X.yaml')
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
CLEAN.add 'tmp/*.rb.{json,yaml}', 'tmp/cloudformation_resources.json'
|
|
46
|
+
|
|
47
|
+
CfnDsl::RakeTask.new do |t|
|
|
48
|
+
desc 'Update Embedded Cloudformation specification'
|
|
49
|
+
t.specification(name: :update_cfn_spec, file: CfnDsl::LOCAL_SPEC_FILE, version: 'latest')
|
|
50
|
+
end
|
|
51
|
+
|
|
52
|
+
# TODO: Bump should ensure we have the latest upstream resource spec
|
|
31
53
|
task :bump, :type do |_, args|
|
|
32
54
|
type = args[:type].downcase
|
|
33
55
|
version_path = 'lib/cfndsl/version.rb'
|
data/TODO.md
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# 1.0.0 Release Changes
|
|
2
|
+
|
|
3
|
+
## Prepare for Machine Ingestable Types
|
|
4
|
+
|
|
5
|
+
## ~~Remove OS Heat Support~~
|
|
6
|
+
|
|
7
|
+
## Remove Ruby/Constant Interpolation
|
|
8
|
+
|
|
9
|
+
## ~~Better Ruby Api~~
|
|
10
|
+
|
|
11
|
+
## 100% Test Coverage
|
|
12
|
+
|
|
13
|
+
## Use Ruby Contracts for Resource Validation
|
|
14
|
+
|
|
15
|
+
## Style Guide/Wiki/README/Examples Update
|
|
16
|
+
|
|
17
|
+
## Fully implement ExternalParameters as a Mash
|
|
18
|
+
|
data/UPGRADING.md
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
# Major version upgrades
|
|
2
|
+
|
|
3
|
+
## 0.x to 1.x
|
|
4
|
+
|
|
5
|
+
### Deprecations
|
|
6
|
+
|
|
7
|
+
* FnFormat => FnSub
|
|
8
|
+
* addTag => add_tag
|
|
9
|
+
* checkRefs => check_refs
|
|
10
|
+
* Ruby versions < 2.4
|
|
11
|
+
* Legacy cfndsl resource specification files
|
|
12
|
+
|
|
13
|
+
### Validation
|
|
14
|
+
|
|
15
|
+
* Tighter validation including for null values and cyclic references in Resources, Outputs, Rules and Conditions
|
|
16
|
+
* Tighter definition of duplicates. eg. Route must be EC2_Route because another service now has a Route resource.
|
|
17
|
+
* Requires the specification file to exist at the time it is explicitly set with CfnDsl.specification_file=
|
|
18
|
+
|
|
19
|
+
#### Spec version
|
|
20
|
+
|
|
21
|
+
The AWS cloudformation spec will be regularly updated on every release
|
|
22
|
+
|
data/cfndsl.gemspec
CHANGED
|
@@ -16,11 +16,11 @@ Gem::Specification.new do |s|
|
|
|
16
16
|
s.license = 'MIT'
|
|
17
17
|
s.test_files = s.files.grep(%r{^(test|spec|features)/})
|
|
18
18
|
s.require_paths = ['lib']
|
|
19
|
+
s.bindir = 'exe'
|
|
19
20
|
s.required_ruby_version = '~> 2.3'
|
|
20
21
|
|
|
21
22
|
s.executables << 'cfndsl'
|
|
22
23
|
|
|
23
|
-
s.add_development_dependency 'bundler', '~> 2.
|
|
24
|
-
|
|
25
|
-
s.post_install_message = "'addTag' is now deprecated in favour of 'add_tag'. 'addTag' will be removed in the next major version."
|
|
24
|
+
s.add_development_dependency 'bundler', '~> 2.0'
|
|
25
|
+
s.add_runtime_dependency 'hana', '~> 1.3'
|
|
26
26
|
end
|
data/exe/cfndsl
ADDED
data/lib/cfndsl.rb
CHANGED
|
@@ -1,118 +1,4 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
require 'deep_merge/deep_merge'
|
|
7
|
-
require 'cfndsl/globals'
|
|
8
|
-
require 'cfndsl/module'
|
|
9
|
-
require 'cfndsl/errors'
|
|
10
|
-
require 'cfndsl/ref_check'
|
|
11
|
-
require 'cfndsl/jsonable'
|
|
12
|
-
require 'cfndsl/properties'
|
|
13
|
-
require 'cfndsl/update_policy'
|
|
14
|
-
require 'cfndsl/creation_policy'
|
|
15
|
-
require 'cfndsl/conditions'
|
|
16
|
-
require 'cfndsl/mappings'
|
|
17
|
-
require 'cfndsl/resources'
|
|
18
|
-
require 'cfndsl/rules'
|
|
19
|
-
require 'cfndsl/parameters'
|
|
20
|
-
require 'cfndsl/outputs'
|
|
21
|
-
require 'cfndsl/patches'
|
|
22
|
-
require 'cfndsl/specification'
|
|
23
|
-
require 'cfndsl/aws/cloud_formation_template'
|
|
24
|
-
require 'cfndsl/os/heat_template'
|
|
25
|
-
require 'cfndsl/external_parameters'
|
|
26
|
-
require 'cfndsl/version'
|
|
27
|
-
|
|
28
|
-
# CfnDsl
|
|
29
|
-
module CfnDsl
|
|
30
|
-
# This function handles the eval of the template file and returns the
|
|
31
|
-
# results. It does this with a ruby "eval", but it builds up a customized
|
|
32
|
-
# binding environment before it calls eval. The environment can be
|
|
33
|
-
# customized by passing a list of customizations in the extras parameter.
|
|
34
|
-
#
|
|
35
|
-
# These customizations are expressed as an array of pairs of
|
|
36
|
-
# (type,filename). They are evaluated in the order they appear in the
|
|
37
|
-
# extras array. The types are as follows
|
|
38
|
-
#
|
|
39
|
-
# :yaml - the second element is treated as a file name, which is loaded
|
|
40
|
-
# as a yaml file. The yaml file should contain a top level
|
|
41
|
-
# dictionary. Each of the keys of the top level dictionary is
|
|
42
|
-
# used as a local variable in the evalation context.
|
|
43
|
-
#
|
|
44
|
-
# :json - the second element is treated as a file name, which is loaded
|
|
45
|
-
# as a json file. The yaml file should contain a top level
|
|
46
|
-
# dictionary. Each of the keys of the top level dictionary is
|
|
47
|
-
# used as a local variable in the evalation context.
|
|
48
|
-
#
|
|
49
|
-
# :ruby - the second element is treated as a file name which is evaluated
|
|
50
|
-
# as a ruby file. Any assigments (or other binding affecting
|
|
51
|
-
# side effects) will persist into the context where the template
|
|
52
|
-
# is evaluated
|
|
53
|
-
#
|
|
54
|
-
# :raw - the second element is treated as a ruby statement and is
|
|
55
|
-
# evaluated in the binding context, similar to the contents of
|
|
56
|
-
# a ruby file.
|
|
57
|
-
#
|
|
58
|
-
# Note that the order is important, as later extra sections can overwrite
|
|
59
|
-
# or even undo things that were done by earlier sections.
|
|
60
|
-
|
|
61
|
-
# rubocop:disable all
|
|
62
|
-
def self.eval_file_with_extras(filename, extras = [], logstream = nil)
|
|
63
|
-
b = binding
|
|
64
|
-
params = CfnDsl::ExternalParameters.refresh!
|
|
65
|
-
extras.each do |type, file|
|
|
66
|
-
case type
|
|
67
|
-
when :yaml, :json
|
|
68
|
-
klass_name = type.to_s.upcase
|
|
69
|
-
logstream.puts("Loading #{klass_name} file #{file}") if logstream
|
|
70
|
-
params.load_file file
|
|
71
|
-
params.add_to_binding(b, logstream) unless disable_binding?
|
|
72
|
-
when :ruby
|
|
73
|
-
if disable_binding?
|
|
74
|
-
logstream.puts("Interpreting Ruby files was disabled. #{file} will not be read") if logstream
|
|
75
|
-
else
|
|
76
|
-
logstream.puts("Running ruby file #{file}") if logstream
|
|
77
|
-
b.eval(File.read(file), file)
|
|
78
|
-
end
|
|
79
|
-
when :raw
|
|
80
|
-
file_parts = file.split("=")
|
|
81
|
-
params.set_param(file_parts[0],file_parts[1..-1].join("="))
|
|
82
|
-
unless disable_binding?
|
|
83
|
-
logstream.puts("Running raw ruby code #{file}") if logstream
|
|
84
|
-
b.eval(file, 'raw code')
|
|
85
|
-
end
|
|
86
|
-
end
|
|
87
|
-
end
|
|
88
|
-
|
|
89
|
-
logstream.puts("Loading template file #{filename}") if logstream
|
|
90
|
-
b.eval(File.read(filename), filename)
|
|
91
|
-
end
|
|
92
|
-
end
|
|
93
|
-
|
|
94
|
-
def CloudFormation(&block)
|
|
95
|
-
x = CfnDsl::CloudFormationTemplate.new
|
|
96
|
-
x.declare(&block)
|
|
97
|
-
invalid_references = x.check_refs
|
|
98
|
-
if invalid_references
|
|
99
|
-
abort invalid_references.join("\n")
|
|
100
|
-
elsif CfnDsl::Errors.errors?
|
|
101
|
-
abort CfnDsl::Errors.errors.join("\n")
|
|
102
|
-
else
|
|
103
|
-
return x
|
|
104
|
-
end
|
|
105
|
-
end
|
|
106
|
-
|
|
107
|
-
def Heat(&block)
|
|
108
|
-
x = CfnDsl::HeatTemplate.new
|
|
109
|
-
x.declare(&block)
|
|
110
|
-
invalid_references = x.check_refs
|
|
111
|
-
if invalid_references
|
|
112
|
-
abort invalid_references.join("\n")
|
|
113
|
-
elsif CfnDsl::Errors.errors?
|
|
114
|
-
abort CfnDsl::Errors.errors.join("\n")
|
|
115
|
-
else
|
|
116
|
-
return x
|
|
117
|
-
end
|
|
118
|
-
end
|
|
3
|
+
require_relative 'cfndsl/cloudformation'
|
|
4
|
+
require_relative 'cfndsl/cfnlego'
|