cfndsl 0.15.0 → 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (123) hide show
  1. checksums.yaml +5 -5
  2. data/.gitignore +3 -0
  3. data/.rubocop.yml +6 -6
  4. data/.travis.yml +10 -5
  5. data/CHANGELOG.md +721 -400
  6. data/Gemfile +2 -0
  7. data/README.md +85 -23
  8. data/Rakefile +28 -6
  9. data/TODO.md +18 -0
  10. data/UPGRADING.md +22 -0
  11. data/cfndsl.gemspec +17 -16
  12. data/exe/cfndsl +5 -0
  13. data/lib/cfndsl.rb +3 -113
  14. data/lib/cfndsl/aws/cloud_formation_template.rb +10 -1
  15. data/lib/cfndsl/aws/patches/000_CloudFormationResourceSpecification.json +51726 -0
  16. data/lib/cfndsl/aws/patches/000_sam.spec.json +1242 -0
  17. data/lib/cfndsl/aws/patches/100_sam.spec_DeploymentPreference_patch.json +64 -0
  18. data/lib/cfndsl/aws/patches/200_Scrutinies_patch.json +86 -0
  19. data/lib/cfndsl/aws/patches/500_Cognito_IdentityPoolRoleAttachment_patches.json +25 -0
  20. data/lib/cfndsl/aws/patches/500_IoT1Click_patch_PlacementTemplate_DeviceTemplates.json +20 -0
  21. data/lib/cfndsl/aws/patches/500_NetworkAclEntry_patch.json +16 -0
  22. data/lib/cfndsl/aws/patches/500_SAM_Serverless_Function_S3Event_Events_patch.json +16 -0
  23. data/lib/cfndsl/aws/patches/500_SAM_Serverless_Function_S3Location_Version_patch.json +16 -0
  24. data/lib/cfndsl/aws/patches/500_SSM_AssociationName_patch.json +16 -0
  25. data/lib/cfndsl/aws/patches/500_VPCEndpoint_patch.json +17 -0
  26. data/lib/cfndsl/aws/patches/510_ElasticSearch_Domain_patches.json +15 -0
  27. data/lib/cfndsl/aws/patches/520_ServiceDiscovery_InstanceAttributes_patch.json +16 -0
  28. data/lib/cfndsl/aws/patches/600_RefKinds_patch.json +3654 -0
  29. data/lib/cfndsl/aws/patches/700_SAM_Serverless_Function_InlineCode_patch.json +20 -0
  30. data/lib/cfndsl/aws/patches/800_List_types_patch.json +115 -0
  31. data/lib/cfndsl/aws/resource_specification.json +39955 -9293
  32. data/lib/cfndsl/aws/types.rb +5 -3
  33. data/lib/cfndsl/cfnlego.rb +34 -0
  34. data/lib/{cfnlego → cfndsl/cfnlego}/cloudformation.erb +0 -0
  35. data/lib/{cfnlego → cfndsl/cfnlego}/cloudformation.rb +3 -1
  36. data/lib/{cfnlego → cfndsl/cfnlego}/resource.rb +5 -8
  37. data/lib/cfndsl/cloudformation.rb +114 -0
  38. data/lib/cfndsl/conditions.rb +13 -1
  39. data/lib/cfndsl/creation_policy.rb +3 -1
  40. data/lib/cfndsl/deep_merge.rb +4 -0
  41. data/lib/cfndsl/external_parameters.rb +12 -13
  42. data/lib/cfndsl/globals.rb +51 -10
  43. data/lib/cfndsl/json_serialisable_object.rb +4 -2
  44. data/lib/cfndsl/jsonable.rb +51 -68
  45. data/lib/cfndsl/mappings.rb +3 -1
  46. data/lib/cfndsl/module.rb +18 -5
  47. data/lib/cfndsl/names.rb +2 -0
  48. data/lib/cfndsl/orchestration_template.rb +193 -73
  49. data/lib/cfndsl/outputs.rb +7 -1
  50. data/lib/cfndsl/parameters.rb +3 -1
  51. data/lib/cfndsl/plurals.rb +23 -10
  52. data/lib/cfndsl/properties.rb +3 -1
  53. data/lib/cfndsl/rake_task.rb +217 -15
  54. data/lib/cfndsl/ref_check.rb +21 -11
  55. data/lib/cfndsl/resources.rb +8 -19
  56. data/lib/cfndsl/rules.rb +46 -0
  57. data/lib/cfndsl/runner.rb +143 -0
  58. data/lib/cfndsl/specification.rb +82 -84
  59. data/lib/cfndsl/types.rb +212 -95
  60. data/lib/cfndsl/update_policy.rb +3 -1
  61. data/lib/cfndsl/version.rb +3 -1
  62. data/lib/deep_merge/core.rb +10 -6
  63. data/lib/deep_merge/deep_merge.rb +3 -1
  64. data/sample/autoscale.rb +1 -1
  65. data/sample/autoscale2.rb +4 -3
  66. data/sample/circular.rb +2 -0
  67. data/sample/codedeploy.rb +3 -1
  68. data/sample/config_service.rb +5 -3
  69. data/sample/ecs.rb +3 -1
  70. data/sample/export.rb +5 -3
  71. data/sample/iam_policies.rb +2 -0
  72. data/sample/import.rb +4 -2
  73. data/sample/lambda.rb +3 -1
  74. data/sample/s3.rb +2 -0
  75. data/sample/t1.rb +3 -1
  76. data/sample/vpc_example.rb +3 -1
  77. data/sample/vpc_with_vpn_example.rb +3 -1
  78. data/spec/aws/ec2_security_group_spec.rb +2 -0
  79. data/spec/aws/ecs_task_definition_spec.rb +2 -0
  80. data/spec/aws/iam_managed_policy_spec.rb +2 -0
  81. data/spec/aws/kms_alias_spec.rb +2 -0
  82. data/spec/aws/list_type_patches_spec.rb +35 -0
  83. data/spec/aws/logs_log_group_spec.rb +2 -0
  84. data/spec/aws/nested_arrays_spec.rb +194 -0
  85. data/spec/aws/rds_db_instance_spec.rb +2 -0
  86. data/spec/aws/serverless_spec.rb +2 -2
  87. data/spec/cfndsl_spec.rb +102 -63
  88. data/spec/cli_spec.rb +52 -49
  89. data/spec/cloud_formation_template_spec.rb +235 -0
  90. data/spec/condition_spec.rb +24 -0
  91. data/spec/deep_merge_spec.rb +2 -0
  92. data/spec/direct_ruby_spec.rb +19 -0
  93. data/spec/external_parameters_spec.rb +25 -20
  94. data/spec/fixtures/condition-assertion.json +1 -0
  95. data/spec/fixtures/params.json +1 -0
  96. data/spec/fixtures/params.yaml +2 -0
  97. data/spec/fixtures/params_struct1.yaml +4 -0
  98. data/spec/fixtures/params_struct2.yaml +4 -0
  99. data/spec/fixtures/rule-assertion.json +1 -0
  100. data/spec/fixtures/test.rb +12 -4
  101. data/spec/generate_spec.rb +4 -0
  102. data/spec/jsonable_spec.rb +2 -0
  103. data/spec/metadata_spec.rb +2 -0
  104. data/spec/names_spec.rb +2 -0
  105. data/spec/output_spec.rb +2 -0
  106. data/spec/plurals_spec.rb +2 -0
  107. data/spec/resource_name_spec.rb +21 -0
  108. data/spec/resources_spec.rb +2 -7
  109. data/spec/rule_spec.rb +17 -0
  110. data/spec/spec_helper.rb +4 -7
  111. data/spec/support/shared_examples/orchestration_template.rb +17 -2
  112. data/spec/transform_spec.rb +2 -0
  113. data/spec/types_definition_spec.rb +6 -7
  114. metadata +79 -25
  115. data/bin/cfndsl +0 -143
  116. data/lib/cfndsl/errors.rb +0 -29
  117. data/lib/cfndsl/os/heat_template.rb +0 -16
  118. data/lib/cfndsl/os/types.rb +0 -12
  119. data/lib/cfndsl/os/types.yaml +0 -2423
  120. data/lib/cfndsl/patches.rb +0 -98
  121. data/lib/cfnlego.rb +0 -42
  122. data/spec/fixtures/heattest.rb +0 -22
  123. data/spec/heat_template_spec.rb +0 -5
@@ -1,98 +0,0 @@
1
- module CfnDsl
2
- # Module for handling inconsistencies in the published resource specification from AWS
3
- module Patches
4
- # Missing/malformed resources from the resource specification
5
- # rubocop:disable Metrics/MethodLength
6
- def self.resources
7
- {
8
- 'AWS::Serverless::Function' => {
9
- 'Properties' => {
10
- 'Handler' => { 'PrimitiveType' => 'String' },
11
- 'Runtime' => { 'PrimitiveType' => 'String' },
12
- 'CodeUri' => { 'PrimitiveType' => 'String' },
13
- 'Description' => { 'PrimitiveType' => 'String' },
14
- 'MemorySize' => { 'PrimitiveType' => 'Integer' },
15
- 'Timeout' => { 'PrimitiveType' => 'Integer' },
16
- 'Environment' => { 'PrimitiveType' => 'Json' },
17
- 'Events' => { 'PrimitiveType' => 'Json' },
18
- 'Policies' => { 'Type' => 'List', 'ItemType' => 'Policy' }
19
- }
20
- },
21
- 'AWS::Serverless::Api' => {
22
- 'Properties' => {
23
- 'StageName' => { 'PrimitiveType' => 'String' },
24
- 'DefinitionUri' => { 'PrimitiveType' => 'String' },
25
- 'CacheClusterEnabled' => { 'PrimitiveType' => 'Boolean' },
26
- 'CacheClusterSize' => { 'PrimitiveType' => 'String' },
27
- 'Variables' => { 'PrimitiveType' => 'Json' }
28
- }
29
- },
30
- 'AWS::Serverless::SimpleTable' => {
31
- 'Properties' => {
32
- 'PrimaryKey' => { 'Type' => 'PrimaryKey' },
33
- 'ProvisionedThroughput' => { 'Type' => 'ProvisionedThroughput' }
34
- }
35
- },
36
- 'AWS::SSM::Parameter' => {
37
- 'Properties' => {
38
- 'Name' => { 'PrimitiveType' => 'String' },
39
- 'Description' => { 'PrimitiveType' => 'String' },
40
- 'Type' => { 'PrimitiveType' => 'String' },
41
- 'Value' => { 'PrimitiveType' => 'String' }
42
- }
43
- },
44
- 'AWS::EC2::VPNGatewayConnection' => {
45
- 'Properties' => {
46
- 'Type' => { 'PrimitiveType' => 'String' },
47
- 'Tags' => { 'Type' => 'List', 'ItemType' => 'Tag' }
48
- }
49
- },
50
- 'AWS::EC2::EIPAssociation' => {
51
- 'Properties' => {
52
- 'AllocationId' => { 'PrimitiveType' => 'String' },
53
- 'EIP' => { 'PrimitiveType' => 'String' },
54
- 'InstanceId' => { 'PrimitiveType' => 'String' },
55
- 'NetworkInterfaceId' => { 'PrimitiveType' => 'String' },
56
- 'PrivateIpAddress' => { 'PrimitiveType' => 'String' }
57
- }
58
- },
59
- 'AWS::Config::ConfigurationRecorder' => {
60
- 'Properties' => {
61
- 'Name' => { 'PrimitiveType' => 'String' },
62
- 'RecordingGroup' => { 'Type' => 'RecordingGroup' },
63
- 'RoleARN' => { 'PrimitiveType' => 'String' }
64
- }
65
- }
66
- }
67
- end
68
-
69
- # Missing/malformed types from the resource specification
70
- def self.types
71
- {
72
- 'AWS::Serverless::SimpleTable.PrimaryKey' => {
73
- 'Properties' => {
74
- 'Name' => { 'PrimitiveType' => 'String' },
75
- 'Type' => { 'PrimitiveType' => 'String' }
76
- }
77
- },
78
- 'AWS::Serverless::SimpleTable.ProvisionedThroughput' => {
79
- 'Properties' => {
80
- 'ReadCapacityUnits' => { 'PrimitiveType' => 'Integer' },
81
- 'WriteCapacityUnits' => { 'PrimitiveType' => 'Integer' }
82
- }
83
- },
84
- 'AWS::Serverless::Function.Policy' => {
85
- 'Properties' => {
86
- 'PolicyDocument' => { 'PrimitiveType' => 'Json' },
87
- 'PolicyName' => { 'PrimitiveType' => 'String' }
88
- }
89
- },
90
- 'AWS::Cognito::IdentityPoolRoleAttachment.RulesConfigurationType' => {
91
- 'Properties' => {
92
- 'Rules' => { 'Type' => 'List', 'ItemType' => 'MappingRule' }
93
- }
94
- }
95
- }
96
- end
97
- end
98
- end
data/lib/cfnlego.rb DELETED
@@ -1,42 +0,0 @@
1
- require 'yaml'
2
- require 'erb'
3
- require 'cfnlego/cloudformation'
4
- require 'cfnlego/resource'
5
- require 'net/http'
6
- require 'uri'
7
-
8
- # Cfnlego
9
- module Cfnlego
10
- def self.Resources
11
- content = fetch_resource_content
12
- supported_resources = JSON.parse(content)
13
- resources = []
14
- supported_resources['ResourceTypes'].each do |resource, _value|
15
- resources << resource
16
- end
17
- resources
18
- end
19
-
20
- def self.fetch_resource_content
21
- File.read(CfnDsl.specification_file)
22
- end
23
-
24
- def self.run(options)
25
- # Constructure Resources
26
- resources = []
27
- options[:resources].each do |r|
28
- /(.*),(.*)/.match(r) do |m|
29
- type = m[1]
30
- name = m[2]
31
- resources << Cfnlego::Resource.new(type, name)
32
- end
33
- end
34
-
35
- begin
36
- return Cfnlego::CloudFormation.new(resources).render
37
- rescue RuntimeError => e
38
- $stderr.puts "Error: #{e.message}"
39
- end
40
- nil
41
- end
42
- end
@@ -1,22 +0,0 @@
1
- Heat do
2
- Description 'Test'
3
-
4
- Parameter('One') do
5
- String
6
- Default 'Test'
7
- MaxLength 15
8
- end
9
-
10
- Parameter('Two') do
11
- String
12
- Default 'Test'
13
- MaxLength 15
14
- end
15
-
16
- Output(:One, FnBase64(Ref('One')))
17
-
18
- Server('MyInstance') do
19
- flavor 'asdfa'
20
- image 'asdad'
21
- end
22
- end
@@ -1,5 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe CfnDsl::HeatTemplate do
4
- it_behaves_like 'an orchestration template'
5
- end