ruby-cdk 0.1.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.
Files changed (155) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG.md +87 -0
  3. data/LICENSE +21 -0
  4. data/README.md +303 -0
  5. data/THIRD_PARTY_NOTICES.md +327 -0
  6. data/data/spec/META.json +33 -0
  7. data/data/spec/model.json.gz +0 -0
  8. data/exe/ruby-cdk +9 -0
  9. data/lib/ruby-cdk.rb +4 -0
  10. data/lib/ruby_cdk/assets/builder.rb +122 -0
  11. data/lib/ruby_cdk/assets/hasher.rb +175 -0
  12. data/lib/ruby_cdk/assets/record.rb +49 -0
  13. data/lib/ruby_cdk/assets/uploader.rb +139 -0
  14. data/lib/ruby_cdk/assets/zipper.rb +108 -0
  15. data/lib/ruby_cdk/assets.rb +116 -0
  16. data/lib/ruby_cdk/bootstrap.rb +289 -0
  17. data/lib/ruby_cdk/cfn/resource.rb +93 -0
  18. data/lib/ruby_cdk/cfn.rb +10 -0
  19. data/lib/ruby_cdk/cli/arguments.rb +41 -0
  20. data/lib/ruby_cdk/cli/aws.rb +35 -0
  21. data/lib/ruby_cdk/cli/bootstrap.rb +63 -0
  22. data/lib/ruby_cdk/cli/diff.rb +98 -0
  23. data/lib/ruby_cdk/cli/failure.rb +80 -0
  24. data/lib/ruby_cdk/cli/io.rb +70 -0
  25. data/lib/ruby_cdk/cli/list.rb +46 -0
  26. data/lib/ruby_cdk/cli/new.rb +313 -0
  27. data/lib/ruby_cdk/cli/operation.rb +124 -0
  28. data/lib/ruby_cdk/cli/pairs.rb +32 -0
  29. data/lib/ruby_cdk/cli/report.rb +118 -0
  30. data/lib/ruby_cdk/cli/selection.rb +134 -0
  31. data/lib/ruby_cdk/cli/session.rb +290 -0
  32. data/lib/ruby_cdk/cli/shell.rb +30 -0
  33. data/lib/ruby_cdk/cli/synth.rb +58 -0
  34. data/lib/ruby_cdk/cli/validate.rb +101 -0
  35. data/lib/ruby_cdk/cli.rb +242 -0
  36. data/lib/ruby_cdk/constructs/bucket.rb +191 -0
  37. data/lib/ruby_cdk/constructs/function.rb +163 -0
  38. data/lib/ruby_cdk/constructs/grant.rb +90 -0
  39. data/lib/ruby_cdk/constructs/log_group.rb +115 -0
  40. data/lib/ruby_cdk/constructs/policy_statement.rb +161 -0
  41. data/lib/ruby_cdk/constructs/queue.rb +118 -0
  42. data/lib/ruby_cdk/constructs/role.rb +282 -0
  43. data/lib/ruby_cdk/constructs/table.rb +160 -0
  44. data/lib/ruby_cdk/constructs/topic.rb +88 -0
  45. data/lib/ruby_cdk/constructs.rb +56 -0
  46. data/lib/ruby_cdk/core/app.rb +146 -0
  47. data/lib/ruby_cdk/core/construct.rb +105 -0
  48. data/lib/ruby_cdk/core/elements.rb +107 -0
  49. data/lib/ruby_cdk/core/ids.rb +117 -0
  50. data/lib/ruby_cdk/core/stack.rb +291 -0
  51. data/lib/ruby_cdk/core/stateful.rb +156 -0
  52. data/lib/ruby_cdk/core.rb +15 -0
  53. data/lib/ruby_cdk/deploy/capabilities.rb +44 -0
  54. data/lib/ruby_cdk/deploy/deployer.rb +805 -0
  55. data/lib/ruby_cdk/deploy/errors.rb +72 -0
  56. data/lib/ruby_cdk/deploy/fakes.rb +546 -0
  57. data/lib/ruby_cdk/deploy/output/base.rb +167 -0
  58. data/lib/ruby_cdk/deploy/output/human.rb +37 -0
  59. data/lib/ruby_cdk/deploy/output/json.rb +80 -0
  60. data/lib/ruby_cdk/deploy/output/quiet.rb +20 -0
  61. data/lib/ruby_cdk/deploy/parameters.rb +86 -0
  62. data/lib/ruby_cdk/deploy/poller.rb +72 -0
  63. data/lib/ruby_cdk/deploy/ports.rb +205 -0
  64. data/lib/ruby_cdk/deploy/sdk_adapters.rb +608 -0
  65. data/lib/ruby_cdk/deploy/states.rb +62 -0
  66. data/lib/ruby_cdk/deploy.rb +25 -0
  67. data/lib/ruby_cdk/diff/compare.rb +141 -0
  68. data/lib/ruby_cdk/diff/normalizer.rb +83 -0
  69. data/lib/ruby_cdk/diff/render.rb +242 -0
  70. data/lib/ruby_cdk/diff/security.rb +322 -0
  71. data/lib/ruby_cdk/diff/statement.rb +256 -0
  72. data/lib/ruby_cdk/diff/template.rb +524 -0
  73. data/lib/ruby_cdk/diff.rb +62 -0
  74. data/lib/ruby_cdk/env.rb +42 -0
  75. data/lib/ruby_cdk/errors.rb +38 -0
  76. data/lib/ruby_cdk/fn.rb +409 -0
  77. data/lib/ruby_cdk/lazy.rb +55 -0
  78. data/lib/ruby_cdk/nag/config.rb +303 -0
  79. data/lib/ruby_cdk/nag/engine.rb +152 -0
  80. data/lib/ruby_cdk/nag/report.rb +86 -0
  81. data/lib/ruby_cdk/nag/rule.rb +171 -0
  82. data/lib/ruby_cdk/nag/rules/api_gateway_authorization.rb +91 -0
  83. data/lib/ruby_cdk/nag/rules/dynamodb_point_in_time_recovery.rb +45 -0
  84. data/lib/ruby_cdk/nag/rules/ebs_volume_encrypted.rb +41 -0
  85. data/lib/ruby_cdk/nag/rules/ec2_ingress_http.rb +48 -0
  86. data/lib/ruby_cdk/nag/rules/ec2_ingress_other_ports.rb +46 -0
  87. data/lib/ruby_cdk/nag/rules/iam_policy_admin_access.rb +60 -0
  88. data/lib/ruby_cdk/nag/rules/iam_policy_full_access.rb +55 -0
  89. data/lib/ruby_cdk/nag/rules/iam_user_credentials.rb +61 -0
  90. data/lib/ruby_cdk/nag/rules/lambda_runtime_supported.rb +88 -0
  91. data/lib/ruby_cdk/nag/rules/lambda_secret_environment.rb +61 -0
  92. data/lib/ruby_cdk/nag/rules/log_group_retention.rb +40 -0
  93. data/lib/ruby_cdk/nag/rules/policy_statements.rb +128 -0
  94. data/lib/ruby_cdk/nag/rules/rds_storage_encrypted.rb +65 -0
  95. data/lib/ruby_cdk/nag/rules/resource_policy_wildcard_principal.rb +58 -0
  96. data/lib/ruby_cdk/nag/rules/s3_public_access_block.rb +56 -0
  97. data/lib/ruby_cdk/nag/rules/security_group_ingress.rb +136 -0
  98. data/lib/ruby_cdk/nag/rules/stateful_deletion_policy.rb +46 -0
  99. data/lib/ruby_cdk/nag/rules.rb +51 -0
  100. data/lib/ruby_cdk/nag/values.rb +305 -0
  101. data/lib/ruby_cdk/nag.rb +60 -0
  102. data/lib/ruby_cdk/schema/normalizer.rb +164 -0
  103. data/lib/ruby_cdk/schema/property_schema.rb +22 -0
  104. data/lib/ruby_cdk/schema/schema.rb +195 -0
  105. data/lib/ruby_cdk/schema/sources/compiler.rb +56 -0
  106. data/lib/ruby_cdk/schema/sources/descriptor.rb +21 -0
  107. data/lib/ruby_cdk/schema/sources/download.rb +86 -0
  108. data/lib/ruby_cdk/schema/sources/provider_schemas.rb +47 -0
  109. data/lib/ruby_cdk/schema/sources/provider_type.rb +630 -0
  110. data/lib/ruby_cdk/schema/sources/regions.rb +86 -0
  111. data/lib/ruby_cdk/schema/sources/resource_specification.rb +94 -0
  112. data/lib/ruby_cdk/schema/sources/specification_type.rb +159 -0
  113. data/lib/ruby_cdk/schema/sources/update.rb +178 -0
  114. data/lib/ruby_cdk/schema/sources.rb +20 -0
  115. data/lib/ruby_cdk/schema/type_schema.rb +109 -0
  116. data/lib/ruby_cdk/schema/validator/corpus_check.rb +81 -0
  117. data/lib/ruby_cdk/schema/validator/policies.rb +48 -0
  118. data/lib/ruby_cdk/schema/validator/refs.rb +489 -0
  119. data/lib/ruby_cdk/schema/validator/report.rb +92 -0
  120. data/lib/ruby_cdk/schema/validator/rule.rb +119 -0
  121. data/lib/ruby_cdk/schema/validator/scans.rb +146 -0
  122. data/lib/ruby_cdk/schema/validator/structure.rb +469 -0
  123. data/lib/ruby_cdk/schema/validator/template.rb +203 -0
  124. data/lib/ruby_cdk/schema/validator/template_rules.rb +70 -0
  125. data/lib/ruby_cdk/schema/validator/walk.rb +122 -0
  126. data/lib/ruby_cdk/schema/validator.rb +159 -0
  127. data/lib/ruby_cdk/schema.rb +19 -0
  128. data/lib/ruby_cdk/synth/manifest.rb +128 -0
  129. data/lib/ruby_cdk/synth/resolver.rb +326 -0
  130. data/lib/ruby_cdk/synth/rules.rb +83 -0
  131. data/lib/ruby_cdk/synth/serializer.rb +120 -0
  132. data/lib/ruby_cdk/synth/writer.rb +31 -0
  133. data/lib/ruby_cdk/synth.rb +255 -0
  134. data/lib/ruby_cdk/test/capture.rb +133 -0
  135. data/lib/ruby_cdk/test/match.rb +426 -0
  136. data/lib/ruby_cdk/test/matcher.rb +290 -0
  137. data/lib/ruby_cdk/test/private/absent.rb +34 -0
  138. data/lib/ruby_cdk/test/private/conditions.rb +39 -0
  139. data/lib/ruby_cdk/test/private/cyclic.rb +160 -0
  140. data/lib/ruby_cdk/test/private/error.rb +48 -0
  141. data/lib/ruby_cdk/test/private/js.rb +326 -0
  142. data/lib/ruby_cdk/test/private/mappings.rb +39 -0
  143. data/lib/ruby_cdk/test/private/outputs.rb +39 -0
  144. data/lib/ruby_cdk/test/private/parameters.rb +39 -0
  145. data/lib/ruby_cdk/test/private/resources.rb +116 -0
  146. data/lib/ruby_cdk/test/private/section.rb +98 -0
  147. data/lib/ruby_cdk/test/private/sorting.rb +40 -0
  148. data/lib/ruby_cdk/test/private/sparse_matrix.rb +35 -0
  149. data/lib/ruby_cdk/test/private/type.rb +23 -0
  150. data/lib/ruby_cdk/test/template.rb +364 -0
  151. data/lib/ruby_cdk/test.rb +116 -0
  152. data/lib/ruby_cdk/values.rb +8 -0
  153. data/lib/ruby_cdk/version.rb +5 -0
  154. data/lib/ruby_cdk.rb +47 -0
  155. metadata +256 -0
@@ -0,0 +1,327 @@
1
+ # Third-party notices
2
+
3
+ This gem contains code and tests ported from the AWS Cloud Development Kit (AWS CDK), and will contain test fixtures taken from other open-source projects as later waves port their suites. Every ported file starts with a header that names its origin path, the commit it was read at, its licence and what was changed. This file lists them all, and carries the licence texts.
4
+
5
+ The gem's own code is under the licence in the `LICENSE` file. A ported file, and the ported parts of a file, remain under the licence of the work they were ported from.
6
+
7
+ ## How to add a suite
8
+
9
+ 1. Give the upstream project its own `###` heading below, with its copyright line and its repository. If the project is already there, add to its table.
10
+ 2. Add one row per ported file: the file in this repository, the path of the file it was ported from, the full commit it was read at, the licence, and whether it is code or tests.
11
+ 3. If the licence is not yet reproduced at the end of this file, add its full text there.
12
+
13
+ ## Ported files
14
+
15
+ ### AWS Cloud Development Kit
16
+
17
+ Copyright 2018-2026 Amazon.com, Inc. or its affiliates. All Rights Reserved.
18
+
19
+ Repository: <https://github.com/aws/aws-cdk>. Licence: Apache-2.0, the full text of which is at the end of this file.
20
+
21
+ The files of the test kit were read at commit `025a6f67fec3d37a6ffdc6168f8a751a04918f66` (the head of `main` on 2026-11-23); every other row names its own commit. The matcher engine of the CDK lives in the internal `matching` package, which the `assertions` package re-exports: the files ported from it say so.
22
+
23
+ #### Code: `RubyCdk::Test`, the equivalent of `aws-cdk-lib/assertions`
24
+
25
+ | File in this repository | Ported from | Licence | What it is |
26
+ |---|---|---|---|
27
+ | `lib/ruby_cdk/test.rb` | `packages/aws-cdk-lib/assertions/lib/index.ts`, `packages/aws-cdk-lib/matching/lib/match.ts` | Apache-2.0 | The public surface of the module and the `Match` factories |
28
+ | `lib/ruby_cdk/test/matcher.rb` | `packages/aws-cdk-lib/matching/lib/matcher.ts` | Apache-2.0 | `Matcher`, `MatchResult` and its rendering |
29
+ | `lib/ruby_cdk/test/match.rb` | `packages/aws-cdk-lib/matching/lib/match.ts` | Apache-2.0 | The ten matchers |
30
+ | `lib/ruby_cdk/test/capture.rb` | `packages/aws-cdk-lib/matching/lib/capture.ts` | Apache-2.0 | `Capture` |
31
+ | `lib/ruby_cdk/test/template.rb` | `packages/aws-cdk-lib/assertions/lib/template.ts` | Apache-2.0 | `Template` |
32
+ | `lib/ruby_cdk/test/private/error.rb` | `packages/aws-cdk-lib/matching/lib/private/error.ts` | Apache-2.0 | `AssertionError` |
33
+ | `lib/ruby_cdk/test/private/type.rb` | `packages/aws-cdk-lib/matching/lib/private/type.ts` | Apache-2.0 | The type of a value, as the messages name it |
34
+ | `lib/ruby_cdk/test/private/sorting.rb` | `packages/aws-cdk-lib/matching/lib/private/sorting.ts` | Apache-2.0 | Sorting by a key |
35
+ | `lib/ruby_cdk/test/private/sparse_matrix.rb` | `packages/aws-cdk-lib/matching/lib/private/sparse-matrix.ts` | Apache-2.0 | What `array_with` remembers of its backtracking |
36
+ | `lib/ruby_cdk/test/private/absent.rb` | `packages/aws-cdk-lib/matching/lib/private/matchers/absent.ts` | Apache-2.0 | The matcher behind `absent` |
37
+ | `lib/ruby_cdk/test/private/section.rb` | `packages/aws-cdk-lib/assertions/lib/private/section.ts` | Apache-2.0 | Matching one section of a template |
38
+ | `lib/ruby_cdk/test/private/resources.rb` | `packages/aws-cdk-lib/assertions/lib/private/resources.ts` | Apache-2.0 | The `Resources` section |
39
+ | `lib/ruby_cdk/test/private/cyclic.rb` | `packages/aws-cdk-lib/assertions/lib/private/cyclic.ts` | Apache-2.0 | The check for dependency cycles |
40
+ | `lib/ruby_cdk/test/private/outputs.rb` | `packages/aws-cdk-lib/assertions/lib/private/outputs.ts` | Apache-2.0 | The `Outputs` section |
41
+ | `lib/ruby_cdk/test/private/parameters.rb` | `packages/aws-cdk-lib/assertions/lib/private/parameters.ts` | Apache-2.0 | The `Parameters` section |
42
+ | `lib/ruby_cdk/test/private/mappings.rb` | `packages/aws-cdk-lib/assertions/lib/private/mappings.ts` | Apache-2.0 | The `Mappings` section |
43
+ | `lib/ruby_cdk/test/private/conditions.rb` | `packages/aws-cdk-lib/assertions/lib/private/conditions.ts` | Apache-2.0 | The `Conditions` section |
44
+
45
+ `lib/ruby_cdk/test/private/js.rb` is not ported from a file: the CDK has none to translate. It reproduces in Ruby the JavaScript the CDK's messages are written in (`typeof`, `String()`, `JSON.stringify`), so that a failure reads the same in both.
46
+
47
+ #### Tests: the CDK's own tests of that package, ported
48
+
49
+ | File in this repository | Ported from | Licence | Cases |
50
+ |---|---|---|---|
51
+ | `test/cdk/assertions/match_test.rb` | `packages/aws-cdk-lib/assertions/test/match.test.ts` | Apache-2.0 | 35 ported, 0 not ported |
52
+ | `test/cdk/assertions/capture_test.rb` | `packages/aws-cdk-lib/assertions/test/capture.test.ts` | Apache-2.0 | 12 ported, 0 not ported |
53
+ | `test/cdk/assertions/render_test.rb` | `packages/aws-cdk-lib/assertions/test/render.test.ts`, `packages/aws-cdk-lib/assertions/test/__snapshots__/render.test.ts.snap` | Apache-2.0 | 11 ported, 0 not ported |
54
+ | `test/cdk/assertions/section_test.rb` | `packages/aws-cdk-lib/assertions/test/private/section.test.ts` | Apache-2.0 | 2 ported, 0 not ported |
55
+ | `test/cdk/assertions/template_test.rb` | `packages/aws-cdk-lib/assertions/test/template.test.ts` | Apache-2.0 | 82 ported, 3 not ported (listed in the header of the file) |
56
+
57
+ Two files of the package are not ported, because they test what this tool does not have: `annotations.test.ts` (23 cases, the CDK's synth-time annotations) and `tags.test.ts` (12 runtime cases, the `Tags` aspect).
58
+
59
+ #### Tests: other suites of the CDK, ported
60
+
61
+ | File in this repository | Ported from | Read at | Cases |
62
+ |---|---|---|---|
63
+ | `test/cdk/core/fn_test.rb` | `packages/aws-cdk-lib/core/test/fn.test.ts` | `78649cb7cf7399204ed63f629964779eeaa8b37a` | 14 of 23 ported; the others listed in the header |
64
+ | `test/unit/assets/hasher_test.rb` | `packages/aws-cdk-lib/core/test/fs/fs-fingerprint.test.ts`, `packages/aws-cdk-lib/aws-s3-assets/test/asset.test.ts`, `packages/aws-cdk-lib/core/test/staging.test.ts` | `78649cb7cf7399204ed63f629964779eeaa8b37a` | 9 ported; the others listed in the header |
65
+
66
+ #### Fixtures: the corpus sample
67
+
68
+ | Directory in this repository | Taken from | Read at | Licence | What it is |
69
+ |---|---|---|---|---|
70
+ | `test/fixtures/corpus/templates/` (400 files, chosen as `META.json` says) | every `*.template.json` of the repository, copied byte for byte | `622f51fa4999d5557c1d1da292c04cc186ac6818` | Apache-2.0 | Templates the CDK synthesized; the validator is measured against them |
71
+
72
+ The sample follows the CDK: the weekly job in `.github/workflows/audit.yml` fetches its templates again and moves the sample, and `META.json` then names the commit.
73
+
74
+ ### AWS Cloud Development Kit CLI
75
+
76
+ Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
77
+
78
+ Repository: <https://github.com/aws/aws-cdk-cli>. Licence: Apache-2.0, the full text of which is at the end of this file.
79
+
80
+ #### Tests: the publisher of assets, ported
81
+
82
+ | File in this repository | Ported from | Read at | Cases |
83
+ |---|---|---|---|
84
+ | `test/unit/assets/zipper_test.rb` | `packages/@aws-cdk/private-tools/test/zip/zip.test.ts`, `packages/@aws-cdk/cdk-assets-lib/test/archive.test.ts` | `eca1b73d682d7763955bec30ab5dd52bbc4327b6` | 7 ported; the others listed in the header |
85
+ | `test/unit/assets/uploader_test.rb` | `packages/@aws-cdk/cdk-assets-lib/test/files.test.ts`, `packages/@aws-cdk/cdk-assets-lib/test/zipping.test.ts` | `eca1b73d682d7763955bec30ab5dd52bbc4327b6` | 6 ported; the others listed in the header |
86
+
87
+ ### stelligent/cfn_nag
88
+
89
+ Copyright (c) 2016-2021 Stelligent Systems LLC. Licence: MIT, the full text of which is at `test/fixtures/nag/LICENSE.cfn_nag`.
90
+
91
+ Repository: <https://github.com/stelligent/cfn_nag>. Read at commit `8b5f03da74202ba323a145e9d037ddce6cab9dec`.
92
+
93
+ | File in this repository | Taken from | Licence | What it is |
94
+ |---|---|---|---|
95
+ | `test/fixtures/nag/cfn_nag/**` (54 templates, verbatim, paths kept) | `spec/test_templates` | MIT | Fixtures: the security rules are measured against the templates cfn-nag ships |
96
+ | `lib/ruby_cdk/nag/rules/policy_statements.rb` | `lib/cfn-nag/base_rules/…` and `cfn-model`'s statement listing | MIT | Rule logic, ported with changes; the file's header names its source |
97
+ | `test/support/nag_template.rb` | `cfn-model`'s YAML short-form handling | MIT | Test support: templates written as cfn-model reads them |
98
+
99
+ ### cdklabs/cdk-nag
100
+
101
+ Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. SPDX-License-Identifier: Apache-2.0, the full text of which is at the end of this file.
102
+
103
+ Repository: <https://github.com/cdklabs/cdk-nag>. Read at commit `da5bed77c1b08e584e3de2d67534c76871af957f`.
104
+
105
+ | File in this repository | Ported from | Licence | What it is |
106
+ |---|---|---|---|
107
+ | `lib/ruby_cdk/nag/rules/**` | the rule packs (` Packs/NagSuppression…`, the pack rules of the same names) | Apache-2.0 | Rule logic, messages and the suppression design, ported with changes; each file's header names its source rule and what changed |
108
+
109
+ ### stelligent/cfn-model
110
+
111
+ Copyright (c) 2016-2020 Stelligent Systems LLC. Licence: MIT, the full text of which is at `test/fixtures/nag/LICENSE.cfn_nag`.
112
+
113
+ Repository: <https://github.com/stelligent/cfn-model>. Read at commit `3ca846093639c1bfdf2069d33c8050ad66122e6b` (v0.6.6, the version cfn-nag pins).
114
+
115
+ | File in this repository | Ported from | Licence | What it is |
116
+ |---|---|---|---|
117
+ | `lib/ruby_cdk/nag/rules/policy_statements.rb` | the resource models' statement listing | MIT | The statement listing and the wildcard-principal test |
118
+
119
+ ## Licence texts
120
+
121
+ ### Apache License, Version 2.0
122
+
123
+ The licence of the AWS CDK, as published in its repository.
124
+
125
+ ```
126
+ Apache License
127
+ Version 2.0, January 2004
128
+ http://www.apache.org/licenses/
129
+
130
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
131
+
132
+ 1. Definitions.
133
+
134
+ "License" shall mean the terms and conditions for use, reproduction,
135
+ and distribution as defined by Sections 1 through 9 of this document.
136
+
137
+ "Licensor" shall mean the copyright owner or entity authorized by
138
+ the copyright owner that is granting the License.
139
+
140
+ "Legal Entity" shall mean the union of the acting entity and all
141
+ other entities that control, are controlled by, or are under common
142
+ control with that entity. For the purposes of this definition,
143
+ "control" means (i) the power, direct or indirect, to cause the
144
+ direction or management of such entity, whether by contract or
145
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
146
+ outstanding shares, or (iii) beneficial ownership of such entity.
147
+
148
+ "You" (or "Your") shall mean an individual or Legal Entity
149
+ exercising permissions granted by this License.
150
+
151
+ "Source" form shall mean the preferred form for making modifications,
152
+ including but not limited to software source code, documentation
153
+ source, and configuration files.
154
+
155
+ "Object" form shall mean any form resulting from mechanical
156
+ transformation or translation of a Source form, including but
157
+ not limited to compiled object code, generated documentation,
158
+ and conversions to other media types.
159
+
160
+ "Work" shall mean the work of authorship, whether in Source or
161
+ Object form, made available under the License, as indicated by a
162
+ copyright notice that is included in or attached to the work
163
+ (an example is provided in the Appendix below).
164
+
165
+ "Derivative Works" shall mean any work, whether in Source or Object
166
+ form, that is based on (or derived from) the Work and for which the
167
+ editorial revisions, annotations, elaborations, or other modifications
168
+ represent, as a whole, an original work of authorship. For the purposes
169
+ of this License, Derivative Works shall not include works that remain
170
+ separable from, or merely link (or bind by name) to the interfaces of,
171
+ the Work and Derivative Works thereof.
172
+
173
+ "Contribution" shall mean any work of authorship, including
174
+ the original version of the Work and any modifications or additions
175
+ to that Work or Derivative Works thereof, that is intentionally
176
+ submitted to Licensor for inclusion in the Work by the copyright owner
177
+ or by an individual or Legal Entity authorized to submit on behalf of
178
+ the copyright owner. For the purposes of this definition, "submitted"
179
+ means any form of electronic, verbal, or written communication sent
180
+ to the Licensor or its representatives, including but not limited to
181
+ communication on electronic mailing lists, source code control systems,
182
+ and issue tracking systems that are managed by, or on behalf of, the
183
+ Licensor for the purpose of discussing and improving the Work, but
184
+ excluding communication that is conspicuously marked or otherwise
185
+ designated in writing by the copyright owner as "Not a Contribution."
186
+
187
+ "Contributor" shall mean Licensor and any individual or Legal Entity
188
+ on behalf of whom a Contribution has been received by Licensor and
189
+ subsequently incorporated within the Work.
190
+
191
+ 2. Grant of Copyright License. Subject to the terms and conditions of
192
+ this License, each Contributor hereby grants to You a perpetual,
193
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
194
+ copyright license to reproduce, prepare Derivative Works of,
195
+ publicly display, publicly perform, sublicense, and distribute the
196
+ Work and such Derivative Works in Source or Object form.
197
+
198
+ 3. Grant of Patent License. Subject to the terms and conditions of
199
+ this License, each Contributor hereby grants to You a perpetual,
200
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
201
+ (except as stated in this section) patent license to make, have made,
202
+ use, offer to sell, sell, import, and otherwise transfer the Work,
203
+ where such license applies only to those patent claims licensable
204
+ by such Contributor that are necessarily infringed by their
205
+ Contribution(s) alone or by combination of their Contribution(s)
206
+ with the Work to which such Contribution(s) was submitted. If You
207
+ institute patent litigation against any entity (including a
208
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
209
+ or a Contribution incorporated within the Work constitutes direct
210
+ or contributory patent infringement, then any patent licenses
211
+ granted to You under this License for that Work shall terminate
212
+ as of the date such litigation is filed.
213
+
214
+ 4. Redistribution. You may reproduce and distribute copies of the
215
+ Work or Derivative Works thereof in any medium, with or without
216
+ modifications, and in Source or Object form, provided that You
217
+ meet the following conditions:
218
+
219
+ (a) You must give any other recipients of the Work or
220
+ Derivative Works a copy of this License; and
221
+
222
+ (b) You must cause any modified files to carry prominent notices
223
+ stating that You changed the files; and
224
+
225
+ (c) You must retain, in the Source form of any Derivative Works
226
+ that You distribute, all copyright, patent, trademark, and
227
+ attribution notices from the Source form of the Work,
228
+ excluding those notices that do not pertain to any part of
229
+ the Derivative Works; and
230
+
231
+ (d) If the Work includes a "NOTICE" text file as part of its
232
+ distribution, then any Derivative Works that You distribute must
233
+ include a readable copy of the attribution notices contained
234
+ within such NOTICE file, excluding those notices that do not
235
+ pertain to any part of the Derivative Works, in at least one
236
+ of the following places: within a NOTICE text file distributed
237
+ as part of the Derivative Works; within the Source form or
238
+ documentation, if provided along with the Derivative Works; or,
239
+ within a display generated by the Derivative Works, if and
240
+ wherever such third-party notices normally appear. The contents
241
+ of the NOTICE file are for informational purposes only and
242
+ do not modify the License. You may add Your own attribution
243
+ notices within Derivative Works that You distribute, alongside
244
+ or as an addendum to the NOTICE text from the Work, provided
245
+ that such additional attribution notices cannot be construed
246
+ as modifying the License.
247
+
248
+ You may add Your own copyright statement to Your modifications and
249
+ may provide additional or different license terms and conditions
250
+ for use, reproduction, or distribution of Your modifications, or
251
+ for any such Derivative Works as a whole, provided Your use,
252
+ reproduction, and distribution of the Work otherwise complies with
253
+ the conditions stated in this License.
254
+
255
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
256
+ any Contribution intentionally submitted for inclusion in the Work
257
+ by You to the Licensor shall be under the terms and conditions of
258
+ this License, without any additional terms or conditions.
259
+ Notwithstanding the above, nothing herein shall supersede or modify
260
+ the terms of any separate license agreement you may have executed
261
+ with Licensor regarding such Contributions.
262
+
263
+ 6. Trademarks. This License does not grant permission to use the trade
264
+ names, trademarks, service marks, or product names of the Licensor,
265
+ except as required for reasonable and customary use in describing the
266
+ origin of the Work and reproducing the content of the NOTICE file.
267
+
268
+ 7. Disclaimer of Warranty. Unless required by applicable law or
269
+ agreed to in writing, Licensor provides the Work (and each
270
+ Contributor provides its Contributions) on an "AS IS" BASIS,
271
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
272
+ implied, including, without limitation, any warranties or conditions
273
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
274
+ PARTICULAR PURPOSE. You are solely responsible for determining the
275
+ appropriateness of using or redistributing the Work and assume any
276
+ risks associated with Your exercise of permissions under this License.
277
+
278
+ 8. Limitation of Liability. In no event and under no legal theory,
279
+ whether in tort (including negligence), contract, or otherwise,
280
+ unless required by applicable law (such as deliberate and grossly
281
+ negligent acts) or agreed to in writing, shall any Contributor be
282
+ liable to You for damages, including any direct, indirect, special,
283
+ incidental, or consequential damages of any character arising as a
284
+ result of this License or out of the use or inability to use the
285
+ Work (including but not limited to damages for loss of goodwill,
286
+ work stoppage, computer failure or malfunction, or any and all
287
+ other commercial damages or losses), even if such Contributor
288
+ has been advised of the possibility of such damages.
289
+
290
+ 9. Accepting Warranty or Additional Liability. While redistributing
291
+ the Work or Derivative Works thereof, You may choose to offer,
292
+ and charge a fee for, acceptance of support, warranty, indemnity,
293
+ or other liability obligations and/or rights consistent with this
294
+ License. However, in accepting such obligations, You may act only
295
+ on Your own behalf and on Your sole responsibility, not on behalf
296
+ of any other Contributor, and only if You agree to indemnify,
297
+ defend, and hold each Contributor harmless for any liability
298
+ incurred by, or claims asserted against, such Contributor by reason
299
+ of your accepting any such warranty or additional liability.
300
+
301
+ END OF TERMS AND CONDITIONS
302
+
303
+ APPENDIX: How to apply the Apache License to your work.
304
+
305
+ To apply the Apache License to your work, attach the following
306
+ boilerplate notice, with the fields enclosed by brackets "[]"
307
+ replaced with your own identifying information. (Don't include
308
+ the brackets!) The text should be enclosed in the appropriate
309
+ comment syntax for the file format. We also recommend that a
310
+ file or class name and description of purpose be included on the
311
+ same "printed page" as the copyright notice for easier
312
+ identification within third-party archives.
313
+
314
+ Copyright 2018-2026 Amazon.com, Inc. or its affiliates. All Rights Reserved.
315
+
316
+ Licensed under the Apache License, Version 2.0 (the "License");
317
+ you may not use this file except in compliance with the License.
318
+ You may obtain a copy of the License at
319
+
320
+ http://www.apache.org/licenses/LICENSE-2.0
321
+
322
+ Unless required by applicable law or agreed to in writing, software
323
+ distributed under the License is distributed on an "AS IS" BASIS,
324
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
325
+ See the License for the specific language governing permissions and
326
+ limitations under the License.
327
+ ```
@@ -0,0 +1,33 @@
1
+ {
2
+ "counts": {
3
+ "only_provider_schemas": 25,
4
+ "only_resource_specification": 231,
5
+ "provider_schemas": 1923,
6
+ "resource_specification": 2129,
7
+ "types": 2154
8
+ },
9
+ "meta_format": 2,
10
+ "model_format": 1,
11
+ "model_sha256": "72a25b4155afd84bfb1f287157d0ca45b2354799a22a2e03e09865975b13cab9",
12
+ "region": "us-east-1",
13
+ "schema_version": "resource specification 273.0.0, model sha256:72a25b4155afd84bfb1f287157d0ca45b2354799a22a2e03e09865975b13cab9, model format 1",
14
+ "sources": {
15
+ "provider_schemas": {
16
+ "bytes": 3423945,
17
+ "etag": "\"72f6b2075c20d73a53a58be2512231b4\"",
18
+ "last_modified": "2026-11-24T05:29:10Z",
19
+ "sha256": "005e18553699e38c549d76407254106e4ba6d4c0c811719195649244fc73cf6e",
20
+ "types": 1923,
21
+ "url": "https://schema.cloudformation.us-east-1.amazonaws.com/CloudformationSchema.zip"
22
+ },
23
+ "resource_specification": {
24
+ "bytes": 1034963,
25
+ "etag": "\"b7c11342bc504480eaed51ca4914278e\"",
26
+ "last_modified": "2026-11-19T20:06:12Z",
27
+ "sha256": "180083997b639db4a453bfa4c24a0cb5aba35f44a46538c28aff8a0f240b56be",
28
+ "types": 2129,
29
+ "url": "https://d1uauaxba7bl26.cloudfront.net/latest/gzip/CloudFormationResourceSpecification.json"
30
+ }
31
+ },
32
+ "specification_version": "273.0.0"
33
+ }
Binary file
data/exe/ruby-cdk ADDED
@@ -0,0 +1,9 @@
1
+ #!/usr/bin/env ruby
2
+ # frozen_string_literal: true
3
+
4
+ require "ruby_cdk/cli"
5
+
6
+ # The edge of the process: the command line answers with an exit code, and this
7
+ # is the only place where it becomes the exit status. It exits on its own when
8
+ # it is interrupted (Ctrl-C), with 130.
9
+ RubyCdk::CLI.main(ARGV)
data/lib/ruby-cdk.rb ADDED
@@ -0,0 +1,4 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Both `require "ruby-cdk"` and `require "ruby_cdk"` work.
4
+ require_relative "ruby_cdk"
@@ -0,0 +1,122 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative "../lazy"
4
+ require_relative "record"
5
+
6
+ module RubyCdk
7
+ module Assets
8
+ # A directory of files as an asset of a stack (architecture §8).
9
+ #
10
+ # Its identity is the manifest hash of its files (Hasher), which is also its
11
+ # object key: the same files give the same asset on every machine, whatever
12
+ # their path, their order or their timestamps. Reached through `stack.asset`.
13
+ #
14
+ # Every accessor answers a Lazy: the files are read when the stack is
15
+ # resolved, not when the asset is declared, so that what is uploaded is what
16
+ # the files are at synthesis.
17
+ class Zip
18
+ attr_reader :stack, :source_path, :exclude
19
+
20
+ def initialize(stack, source_path, exclude: [])
21
+ @stack = stack
22
+ @source_path = source_path
23
+ @exclude = Array(exclude).map(&:dup).freeze
24
+ @record = nil
25
+ end
26
+
27
+ # True once the files were read and hashed.
28
+ def resolved?
29
+ !@record.nil?
30
+ end
31
+
32
+ # The record of the files: read and hashed on first use, then kept.
33
+ # Raises what Record.build raises.
34
+ def record
35
+ @record ||= Record.build(@source_path, exclude: @exclude)
36
+ end
37
+
38
+ # The identity of the asset: its manifest hash.
39
+ #
40
+ # Not named hash: Object#hash must answer an Integer, and an asset whose
41
+ # hash is a String could not be a Hash key or sit in a Set.
42
+ def asset_hash
43
+ Lazy.new { |resolving| ours?(resolving); record.manifest_hash }
44
+ end
45
+
46
+ # "<manifest hash>.zip"
47
+ def key
48
+ Lazy.new { |resolving| ours?(resolving); record.key }
49
+ end
50
+
51
+ # The asset bucket of the stack's environment.
52
+ def bucket
53
+ Lazy.new { |resolving| ours?(resolving); bucket_name }
54
+ end
55
+
56
+ # For a Lambda `code`: {"S3Bucket" => ..., "S3Key" => ...}.
57
+ def s3_location
58
+ Lazy.new { |resolving| ours?(resolving); { "S3Bucket" => bucket_name, "S3Key" => record.key } }
59
+ end
60
+
61
+ private
62
+
63
+ # An asset belongs to the stack that declared it, and its bucket and its
64
+ # key are only published with that stack. Used in another stack's
65
+ # template, it would name an object nothing has uploaded and no manifest
66
+ # entry would list, so it is refused at resolve time. The CDK refuses the
67
+ # same thing when a Code is bound to a second stack ("Asset is already
68
+ # associated with another stack"; aws-lambda/lib/code.ts). Declare the
69
+ # asset again, with the other stack's own `asset.zip`.
70
+ def ours?(resolving)
71
+ return if resolving.nil? || resolving.equal?(@stack)
72
+
73
+ raise UsageError, "The asset at #{File.expand_path(@source_path.to_s)} was declared in stack #{@stack.stack_name}, " \
74
+ "and is being resolved for stack #{resolving.stack_name}. An asset uploads with, and is listed by, the stack " \
75
+ "that declared it. Declare it again in #{resolving.stack_name}: #{resolving.path}.asset.zip(...)"
76
+ end
77
+
78
+ def bucket_name
79
+ Assets.bucket_name(@stack.env.account, @stack.env.region)
80
+ end
81
+ end
82
+
83
+ # Creates the file assets of a stack. Reached through `stack.asset`.
84
+ class Builder
85
+ attr_reader :stack
86
+
87
+ def initialize(stack)
88
+ @stack = stack
89
+ @zips = []
90
+ end
91
+
92
+ # A directory of files as an asset. Nothing is read yet: the directory is
93
+ # walked and hashed when the stack is resolved (architecture §8).
94
+ #
95
+ # path: the directory, relative to the current one, so write it from
96
+ # __dir__ in the app file to be independent of where the command runs.
97
+ # exclude: patterns in addition to Hasher::DEFAULT_EXCLUDES.
98
+ def zip(path, exclude: [])
99
+ unless @stack.env
100
+ raise UsageError, "#{@stack.path}: an asset needs a concrete env, because the name of its bucket is made " \
101
+ "of the account and the region. Give the Stack or its App env: RubyCdk::Env.new(account:, region:)"
102
+ end
103
+
104
+ zip = Zip.new(@stack, path, exclude:)
105
+ @zips << zip
106
+ zip
107
+ end
108
+
109
+ # The manifest hashes of the assets that were resolved, in the order they
110
+ # were declared and without a repeat. Synthesis writes them to the manifest.
111
+ def hashes
112
+ @zips.select(&:resolved?).map { |zip| zip.record.manifest_hash }.uniq
113
+ end
114
+
115
+ # The records of the assets that were resolved, one per distinct key: what
116
+ # the deploy step uploads.
117
+ def records
118
+ @zips.select(&:resolved?).map(&:record).uniq(&:key)
119
+ end
120
+ end
121
+ end
122
+ end