ruby-cdk 0.1.0 → 0.2.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 +136 -1
- data/README.md +39 -20
- data/THIRD_PARTY_NOTICES.md +56 -2
- data/data/spec/META.json +10 -10
- data/data/spec/model.json.gz +0 -0
- data/lib/ruby_cdk/cli/diff.rb +88 -7
- data/lib/ruby_cdk/cli/new.rb +13 -16
- data/lib/ruby_cdk/cli/operation.rb +28 -4
- data/lib/ruby_cdk/cli/session.rb +20 -3
- data/lib/ruby_cdk/cli.rb +14 -1
- data/lib/ruby_cdk/constructs/bucket.rb +84 -16
- data/lib/ruby_cdk/constructs/events_rule.rb +245 -0
- data/lib/ruby_cdk/constructs/function.rb +65 -6
- data/lib/ruby_cdk/constructs/kms_alias.rb +90 -0
- data/lib/ruby_cdk/constructs/kms_key.rb +436 -0
- data/lib/ruby_cdk/constructs/queue.rb +94 -15
- data/lib/ruby_cdk/constructs/restapi.rb +234 -0
- data/lib/ruby_cdk/constructs/schedule.rb +92 -0
- data/lib/ruby_cdk/constructs/secret.rb +104 -0
- data/lib/ruby_cdk/constructs/ssm_parameter.rb +238 -0
- data/lib/ruby_cdk/constructs/table.rb +87 -10
- data/lib/ruby_cdk/constructs/topic.rb +25 -14
- data/lib/ruby_cdk/constructs.rb +16 -4
- data/lib/ruby_cdk/deploy/deployer.rb +232 -16
- data/lib/ruby_cdk/deploy/fakes.rb +31 -3
- data/lib/ruby_cdk/deploy/hotswap.rb +175 -0
- data/lib/ruby_cdk/deploy/parameters.rb +16 -8
- data/lib/ruby_cdk/deploy/ports.rb +18 -0
- data/lib/ruby_cdk/deploy/sdk_adapters.rb +23 -0
- data/lib/ruby_cdk/deploy.rb +1 -0
- data/lib/ruby_cdk/diff/destructive.rb +68 -0
- data/lib/ruby_cdk/diff/template.rb +13 -2
- data/lib/ruby_cdk/diff.rb +1 -0
- data/lib/ruby_cdk/errors.rb +13 -0
- data/lib/ruby_cdk/version.rb +1 -1
- metadata +10 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 7d26933a27bf404e149152155ddb8744aa5dd055b94c06929da5d00ccc5b1b2c
|
|
4
|
+
data.tar.gz: 50afe89a297afef34c024cdf99ad86da6837c5042d1ecb9e96639a513993915e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 020c8868d980608e6eb6e0cfad8cd8235990a1d7800b372128b1762551d22d1986be3bc6f87f3a4fbf56de5493a73ea47877586cffc8ed3136aa381047e4c033
|
|
7
|
+
data.tar.gz: 8ba70f3cc099063866ce21faffb0eedae4ec2ed1fa7a030db945d54d154f8c0ca864a6fc3471b8c6ed53aa5fc05c3474c9cc10850176f1a89eb0108d944172be
|
data/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,141 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [0.2.0] - 2026-11-30
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
- **The `api` example.** The Wave 8 constructs in one stack, in the shape
|
|
15
|
+
of the sandbox app that deployed and answered 200 on 2026-11-27: a
|
|
16
|
+
function behind an `ApiGateway::RestApi` proxy and an `Events::Rule`
|
|
17
|
+
schedule, with an `SQS::Queue`, an `SNS::Topic` and an `SSM::Parameter`
|
|
18
|
+
granted to its role and a `SecretsManager::Secret` reference in its
|
|
19
|
+
environment. The REST API's methods are authorized with IAM
|
|
20
|
+
(`authorization: :aws_iam`, the CDK's `defaultMethodOptions` at the
|
|
21
|
+
pinned commit), so the example passes `RC-APIGW-001` with no
|
|
22
|
+
suppression. It is the fourth example under the cross-seed determinism
|
|
23
|
+
gate and the nag rules: its template is committed under
|
|
24
|
+
`test/fixtures/templates/api/`, the first fixture to carry the two
|
|
25
|
+
`AWS::Lambda::Permission` resources a service principal needs, for
|
|
26
|
+
`apigateway.amazonaws.com` and `events.amazonaws.com`.
|
|
27
|
+
- **`diff --fail-on`.** The CDK's table of what a diff fails on, read at
|
|
28
|
+
f7c9dca95f440a076c2abd61b66b984624b8548e: `--fail-on=any-change` exits 1
|
|
29
|
+
when a stack differs, `broadening` when a stack's changes broaden
|
|
30
|
+
permissions, `destructive` when a change replaces, destroys or orphans a
|
|
31
|
+
resource, and `never` never does; without the option the command exits 0
|
|
32
|
+
either way, as before. `--fail` is the CDK's alias for `any-change` and
|
|
33
|
+
`--no-fail` for `never`, and neither goes with `--fail-on`: a usage error in
|
|
34
|
+
the CDK's words. Under `--fail-on=destructive` the CDK's list follows the
|
|
35
|
+
closing line, one line per change (`Stack: Type LogicalId will be
|
|
36
|
+
replaced`, `will be destroyed` or `will be orphaned`), and `--json` gains
|
|
37
|
+
`destructive_changes` per stack. The CDK's own cases are ported: the two
|
|
38
|
+
`--fail-on` describes of its diff command tests
|
|
39
|
+
(`test/cdk/diff/commands_diff_test.rb`, whose count now includes its two
|
|
40
|
+
test.each tables: 61 cases, 25 ported) and its `diff --fail-on` option tests
|
|
41
|
+
(`test/cdk/cli/diff_options_test.rb`: 19 cases, 9 ported). Parity now
|
|
42
|
+
1,850 cases, 543 ported.
|
|
43
|
+
- **`deploy --previous-parameters` / `--no-previous-parameters`.** The CDK's
|
|
44
|
+
flag of that name (`usePreviousParameters` is what it hands to its
|
|
45
|
+
toolkit), on by default: a parameter that is not named again keeps the
|
|
46
|
+
value the stack was last deployed with, sent as `UsePreviousValue`. With
|
|
47
|
+
`--no-previous-parameters` every parameter is resolved from `--parameters`
|
|
48
|
+
and the template's default alone, and one with neither must be named on
|
|
49
|
+
every deploy. The change-set path and the hotswap fast path send the same
|
|
50
|
+
list. The CDK's five parameter cases of deploy-stack.test.ts are ported as
|
|
51
|
+
the origin has them (`test/cdk/cli/deploy_stack_test.rb`: 120 cases at
|
|
52
|
+
f7c9dca, 42 ported).
|
|
53
|
+
- **`KMS::Key`, and customer-managed encryption on the stateful constructs.**
|
|
54
|
+
`RubyCdk::KMS::Key` is the CDK's Key (aws-kms/lib/key.ts, read at the
|
|
55
|
+
pinned commit): an `AWS::KMS::Key` with the CDK's default key policy — one
|
|
56
|
+
statement delegating the account's IAM through `kms:*` — replaced by
|
|
57
|
+
`policy:` when statements are given and extended by
|
|
58
|
+
`add_to_resource_policy`; `description`, `enabled`, `enable_key_rotation`,
|
|
59
|
+
`rotation_period`, `pending_window`, `key_spec`, `key_usage`,
|
|
60
|
+
`multi_region`, `admins:` and an `alias_name:` (an `AWS::KMS::Alias`, more
|
|
61
|
+
through `add_alias`); and the CDK's grants — `grant_encrypt_decrypt`,
|
|
62
|
+
`grant_decrypt`, `grant_encrypt`, the sign, verify and MAC ones,
|
|
63
|
+
`grant_admin` and `grant` — each a statement on the key's ARN in the
|
|
64
|
+
principal's own policy. Every construct that takes a key takes a
|
|
65
|
+
`KMS::Key`, the ARN of a key that exists, or an intrinsic. `S3::Bucket`
|
|
66
|
+
gains `encryption: :kms` with `encryption_key:` (a key is created under the
|
|
67
|
+
bucket when none is given, and a key with no `encryption:` implies KMS),
|
|
68
|
+
and `grant_read` / `grant_read_write` add the key's actions. `SQS::Queue`
|
|
69
|
+
gains `encryption:` (`:unencrypted`, `:kms_managed`, `:kms`,
|
|
70
|
+
`:sqs_managed`), `encryption_master_key:` and `data_key_reuse:`, and its
|
|
71
|
+
consume and send grants add the key's actions; a key given over another
|
|
72
|
+
mode is refused, naming `encryption: :kms`, where the CDK switches the mode
|
|
73
|
+
and annotates a warning. `SNS::Topic` gains `master_key:`, and publish adds
|
|
74
|
+
the key's actions. `DynamoDB::Table` gains `encryption:` (`:default`,
|
|
75
|
+
`:aws_managed`, `:customer_managed`) and `encryption_key:`, and its read,
|
|
76
|
+
read-write and full-access grants add the key's actions. No default
|
|
77
|
+
changed. The CDK's own cases are ported: `key.test.ts` (80 of 112) in
|
|
78
|
+
`test/cdk/constructs/kms_key_test.rb`, and the encryption and key-grant
|
|
79
|
+
cases of the other four in their files, whose headers now count the
|
|
80
|
+
deprecated, skipped and tabulated cases of their origins (bucket 243, not
|
|
81
|
+
200; queue 65, not 59; topic 60, not 54; table 187, not 166). Parity now
|
|
82
|
+
2,007 cases, 627 ported.
|
|
83
|
+
- **`deploy --hotswap` and `--hotswap-fallback`.** The CDK's
|
|
84
|
+
development-loop fast path: the deploy is diffed against the deployed
|
|
85
|
+
template, and when every change is a Lambda function's code (an asset's S3
|
|
86
|
+
location, `S3ObjectVersion`, or inline `ZipFile`) or in-place configuration
|
|
87
|
+
(`Handler`, `Runtime`, `MemorySize`, `Timeout`, `Environment`,
|
|
88
|
+
`Description`), one direct `UpdateStack` applies it — no change set — with
|
|
89
|
+
the CDK's own reporting lines and the same approval question a change-set
|
|
90
|
+
deploy asks. Anything else is refused by the fast path: `--hotswap-fallback`
|
|
91
|
+
hands the whole deploy to the change set (the CDK's `FALL_BACK` mode);
|
|
92
|
+
`--hotswap` reports what it refused and applies nothing (`HOTSWAP_ONLY`);
|
|
93
|
+
both flags together are refused. `--json` gains a `hotswap` object per
|
|
94
|
+
stack: the mode, whether the change set took over, the swapped functions,
|
|
95
|
+
and the refused changes with their reasons. Change sets remain the default;
|
|
96
|
+
the two flags print the CDK's drift warning. The CDK's lambda hotswap
|
|
97
|
+
scenarios are ported (`test/cdk/cli/hotswap_test.rb`; parity now 1,819
|
|
98
|
+
cases, 518 ported), with the apply-path differences recorded where this
|
|
99
|
+
tool goes through CloudFormation instead of the Lambda API.
|
|
100
|
+
- **Four more curated constructs.** `SSM::Parameter` (String and StringList,
|
|
101
|
+
the CDK's grants, SecureString refused with the KMS reason), a
|
|
102
|
+
`SecretsManager::Secret` reference by name (partial ARN as one `Fn::Sub`,
|
|
103
|
+
the `{{resolve:secretsmanager:...}}` value), `Events::Rule` with
|
|
104
|
+
`Schedule` and pattern merging, and `ApiGateway::RestApi` with a Lambda
|
|
105
|
+
proxy (`{proxy+}`, ANY, a prod stage, the CDK's method-set hash on the
|
|
106
|
+
Deployment). Parity now 1,755 cases, 485 ported.
|
|
107
|
+
- **The resource policies a service principal needs.**
|
|
108
|
+
`Function#add_permission` writes the `AWS::Lambda::Permission` of the CDK
|
|
109
|
+
on a function's resource policy. `ApiGateway::RestApi` writes it for
|
|
110
|
+
`apigateway.amazonaws.com` and `Events::Rule#add_target` for
|
|
111
|
+
`events.amazonaws.com`, each scoped by its source ARN, so an endpoint and
|
|
112
|
+
a scheduled rule reach a function with no permission added by hand.
|
|
113
|
+
|
|
114
|
+
### Fixed
|
|
115
|
+
|
|
116
|
+
- **Every update of an existing stack through a change set failed against
|
|
117
|
+
AWS**, with `ChangeSetNotFound`. Before creating its change set the engine
|
|
118
|
+
deletes an earlier one of the same name and waits for it to be gone, and it
|
|
119
|
+
took as gone only an error whose message said "not found". AWS answers
|
|
120
|
+
`ChangeSetNotFound` — "ChangeSet [name] does not exist" — for a change set
|
|
121
|
+
that was never created, which is every ordinary update. The scripted fake
|
|
122
|
+
had answered a status, so every test was green. The port now raises the
|
|
123
|
+
typed `RubyCdk::ChangeSetNotFound` for AWS's answer and the engine takes
|
|
124
|
+
the class. Found on 2026-11-29, on the first update ever run against a
|
|
125
|
+
real stack; 0.1.0 carries the defect.
|
|
126
|
+
|
|
127
|
+
### Changed
|
|
128
|
+
|
|
129
|
+
- **A parameter's deployed value comes before its template's default.** With
|
|
130
|
+
`--previous-parameters` (the default) the engine follows the CDK's
|
|
131
|
+
ParameterValues (cfn-api.ts:613-641 at the commit above): a value that is
|
|
132
|
+
given, then the one the stack has, sent as `UsePreviousValue`, then the
|
|
133
|
+
template's default, which is not sent. It read the default first, so a
|
|
134
|
+
stack deployed with another value than a parameter's default was never
|
|
135
|
+
recognised as unchanged, and each of its redeploys asked CloudFormation for
|
|
136
|
+
a change set that had nothing in it.
|
|
137
|
+
|
|
138
|
+
### Fixed
|
|
139
|
+
|
|
140
|
+
- `diff --security-only` counted a stack for the closing line and for `--fail`
|
|
141
|
+
whenever it had a security change. The CDK counts it only when the changes
|
|
142
|
+
broaden permissions (cdk-toolkit.ts:331-336 and 401-406), and so does the
|
|
143
|
+
command now.
|
|
144
|
+
|
|
10
145
|
## [0.1.0] - 2026-11-27
|
|
11
146
|
|
|
12
147
|
### Added
|
|
@@ -37,7 +172,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
37
172
|
`ruby-cdk-assets-<account>-<region>` with the bucket's expected owner
|
|
38
173
|
named on every call. The bootstrap stack with its pre-flight, and
|
|
39
174
|
`ruby-cdk bootstrap`.
|
|
40
|
-
- **Security rules.** `rake nag`:
|
|
175
|
+
- **Security rules.** `rake nag`: seventeen rules over a template as a plain
|
|
41
176
|
Hash (open security groups, wildcard principals, secrets in the
|
|
42
177
|
environment, unencrypted storage, retired runtimes), suppressions from
|
|
43
178
|
resource metadata or `.ruby-cdk/nag.yml`, measured against cfn-nag's own
|
data/README.md
CHANGED
|
@@ -2,17 +2,21 @@
|
|
|
2
2
|
|
|
3
3
|
Infrastructure as code in **pure Ruby**, in the style of the AWS CDK: define stacks as Ruby objects, synthesize deterministic CloudFormation templates validated against the schemas AWS publishes, and deploy them through change sets with the AWS SDK for Ruby. No Node.js, no jsii, no npm anywhere in the toolchain.
|
|
4
4
|
|
|
5
|
-
> **Status: 0.0
|
|
5
|
+
> **Status: 0.1.0, pre-release.** The gem is on [rubygems.org](https://rubygems.org/gems/ruby-cdk) and attached to each [release](https://github.com/a-safe-digital/ruby-cdk/releases). The API is still settling; see [Status](#status).
|
|
6
6
|
|
|
7
7
|
## What it is
|
|
8
8
|
|
|
9
9
|
The AWS CDK's programming model, reimplemented in Ruby. Your app file creates one `RubyCdk::App`; stacks are classes with a `build` method that declares resources, parameters and outputs; synthesis turns the object tree into CloudFormation templates whose every byte is specified, and the `ruby-cdk` CLI deploys them through change sets. Properties are written with CloudFormation's names, or in `snake_case` — the keys are normalized against AWS's own resource schemas before anything is written.
|
|
10
10
|
|
|
11
|
-
"Measured against the CDK" is a number, not a claim. The CDK's own test suites are ported and run in the default gate (`rake parity`):
|
|
11
|
+
"Measured against the CDK" is a number, not a claim. The CDK's own test suites are ported and run in the default gate (`rake parity`): 2,084 cases, 666 of them ported, every ported case passing, and each of the others listed in a ported file's header with the reason it is not ported — every header's origin count held to the counted fact in `test/cdk/origins.json`, so the numbers are recountable, not remembered. The whole suite — 2,228 runs, 25,320 assertions — passes with no AWS credential reachable; the same gate keeps line coverage above 98% over a floor of 85%, and proves that every example synthesizes byte-identical output across two runs with different Ruby hash seeds.
|
|
12
12
|
|
|
13
13
|
## Install
|
|
14
14
|
|
|
15
|
-
From
|
|
15
|
+
From rubygems.org, or from source:
|
|
16
|
+
|
|
17
|
+
```sh
|
|
18
|
+
gem install ruby-cdk
|
|
19
|
+
```
|
|
16
20
|
|
|
17
21
|
```sh
|
|
18
22
|
git clone https://github.com/a-safe-digital/ruby-cdk.git
|
|
@@ -22,7 +26,7 @@ bundle exec rake install:local # builds the gem and installs it into your gems
|
|
|
22
26
|
```
|
|
23
27
|
|
|
24
28
|
$ ruby-cdk version
|
|
25
|
-
0.0
|
|
29
|
+
0.1.0
|
|
26
30
|
|
|
27
31
|
The gem ships no native code, so no compiler is needed.
|
|
28
32
|
|
|
@@ -33,8 +37,7 @@ With the gem installed (above), `ruby-cdk new` scaffolds the smallest useful app
|
|
|
33
37
|
```sh
|
|
34
38
|
ruby-cdk new my-app
|
|
35
39
|
cd my-app
|
|
36
|
-
bundle install
|
|
37
|
-
# Gemfile from the gem installed on this machine, nothing more
|
|
40
|
+
bundle install # ruby-cdk is on rubygems.org; this resolves the Gemfile
|
|
38
41
|
```
|
|
39
42
|
|
|
40
43
|
The directory holds the app file, `cdk.rb` — one `RubyCdk::App`, one stack:
|
|
@@ -145,12 +148,27 @@ The command prints the target — account, region, profile — before the first
|
|
|
145
148
|
Yes executes the change set and follows the operation, printing each event as it arrives and the outputs at the end. Anything else stops: the change set is deleted, and a not-yet-created stack is deleted with it, so a refused deploy leaves nothing behind. A stack without an `env` deploys wherever your credentials point, after the command prints the target. Useful options:
|
|
146
149
|
|
|
147
150
|
- `--yes` — deploy without asking. Without a terminal the command stops at the question anyway (exit 4, nothing deployed), so unattended runs must say `--yes`.
|
|
148
|
-
- `--parameters K=V,K=V` and `--tags K=V,K=V` — template parameters and stack tags.
|
|
151
|
+
- `--parameters K=V,K=V` and `--tags K=V,K=V` — template parameters and stack tags. A parameter you don't name again keeps the value the stack was last deployed with (the CDK's `--previous-parameters`, on by default); with `--no-previous-parameters` every parameter without a template default must be named on every deploy.
|
|
149
152
|
- `--outputs-file PATH` — the outputs of each stack as JSON.
|
|
150
153
|
- `--no-execute` — create the change set and leave it for the console.
|
|
151
154
|
- `--on-failure DELETE|ROLLBACK|DO_NOTHING` — what CloudFormation does when a first deploy fails (default `DELETE`, so a failed creation cleans up after itself).
|
|
152
155
|
- `--force` — deploy even when the deployed template, parameters and tags are unchanged (unchanged means the deploy is skipped).
|
|
153
156
|
- `--all`, `-e/--exclusively` — every stack of the app in dependency order, or only the ones named.
|
|
157
|
+
- `--hotswap` / `--hotswap-fallback` — the development-loop fast path; see below.
|
|
158
|
+
|
|
159
|
+
**The hotswap fast path.** Change sets are the default, and the CDK's `--hotswap` flags are the deliberate way around them for the inner development loop. With `--hotswap` or `--hotswap-fallback`, the deploy diffs the synthesized template against the deployed one and, when every change is a Lambda function's code (an asset's S3 location, `S3ObjectVersion`, or inline `ZipFile`) or in-place configuration (`Handler`, `Runtime`, `MemorySize`, `Timeout`, `Environment`, `Description`), applies them with one direct `UpdateStack` — no change set, no waiting for one — reporting each function it swapped and asking the same approval question a change-set deploy asks. Anything else (a new or removed resource, a replacement, any other type or section) is refused by the fast path: `--hotswap-fallback` hands the whole deploy to the normal change set, the CDK's `FALL_BACK` mode, while `--hotswap` reports what it refused and applies nothing, the CDK's `HOTSWAP_ONLY` mode — giving both is an error. With `--json`, the per-stack record gains a `hotswap` object: the mode, whether the change set took over, the swapped functions, and the refused changes with their reasons. The command prints the CDK's own warning above every hotswap deploy:
|
|
160
|
+
|
|
161
|
+
⚠️ The --hotswap and --hotswap-fallback flags deliberately introduce CloudFormation drift to speed up deployments
|
|
162
|
+
⚠️ They should only be used for development - never use them for your production Stacks!
|
|
163
|
+
|
|
164
|
+
A hotswap puts the stack outside what CloudFormation last deployed (drift); the next ordinary deploy brings it back in line. Do not use either flag on a production stack.
|
|
165
|
+
|
|
166
|
+
**Preview a deploy.** `bundle exec ruby-cdk diff` compares each stack's synthesized template with the one CloudFormation holds: per resource and per changed property path, the properties whose change replaces the resource marked as such, and the security view — the IAM statements a deployment adds or takes away. It reads the deployed template and writes nothing. The command exits 0 whether or not there are differences; these options decide otherwise, as the CDK's do:
|
|
167
|
+
|
|
168
|
+
- `--fail` — exit 1 when a stack differs.
|
|
169
|
+
- `--fail-on=any-change` | `broadening` | `destructive` | `never` — exit 1 when the diff holds that kind of change: any difference; a change that broadens permissions; a resource that would be replaced, destroyed or orphaned, listed after the closing line; or never. Not together with `--fail`.
|
|
170
|
+
- `--security-only` — the security view alone.
|
|
171
|
+
- `--json` — one object per stack on standard output: the changes with their replacement facts, the security view, and the destructive changes.
|
|
154
172
|
|
|
155
173
|
`bundle exec ruby-cdk destroy` prints what the stack retains, then asks you to type the stack's name — a yes/no is not enough for an irreversible act — and deletes it. `--yes` skips the question; a termination-protected stack is refused.
|
|
156
174
|
|
|
@@ -179,7 +197,7 @@ A key that matches nothing is an error with the closest names as suggestions —
|
|
|
179
197
|
|
|
180
198
|
Exit 0 when every selected stack is clean of errors, 2 otherwise; warnings are reported but not fatal. An unknown resource type (V1) is a warning that leaves the resource's keys as written, so `Custom::*` and registry types work.
|
|
181
199
|
|
|
182
|
-
`--strict-types` re-registers the rules so that V1 reports an error instead of a warning.
|
|
200
|
+
`--strict-types` re-registers the rules so that V1 reports an error instead of a warning. The run keeps `validate`'s contract: exit 0 when nothing is found, exit 2 with the first error printed.
|
|
183
201
|
|
|
184
202
|
## Assets
|
|
185
203
|
|
|
@@ -210,16 +228,16 @@ The bucket comes from `ruby-cdk bootstrap`, which deploys a stack named `ruby-cd
|
|
|
210
228
|
`RubyCdk::Test` is the CDK's assertions module, ported: the same method names, snake_cased. A stack's template in a plain Minitest:
|
|
211
229
|
|
|
212
230
|
```ruby
|
|
213
|
-
# test/
|
|
231
|
+
# test/my_app_stack_test.rb — beside the scaffold's files
|
|
214
232
|
require "minitest/autorun"
|
|
215
233
|
require "ruby-cdk"
|
|
216
234
|
require "ruby_cdk/test"
|
|
217
235
|
|
|
218
|
-
require_relative "
|
|
236
|
+
require_relative "my_app/my_app_stack"
|
|
219
237
|
|
|
220
|
-
class
|
|
238
|
+
class MyAppStackTest < Minitest::Test
|
|
221
239
|
def test_the_bucket_stays_private_and_is_encrypted
|
|
222
|
-
stack =
|
|
240
|
+
stack = MyApp::Stack.new(RubyCdk::App.new, "my-app")
|
|
223
241
|
template = RubyCdk::Test.template(stack)
|
|
224
242
|
|
|
225
243
|
template.resource_count_is("AWS::S3::Bucket", 1)
|
|
@@ -240,7 +258,6 @@ class HelloStackTest < Minitest::Test
|
|
|
240
258
|
"DeletionPolicy" => "RetainExceptOnCreate",
|
|
241
259
|
"UpdateReplacePolicy" => "Retain")
|
|
242
260
|
template.has_parameter("Versioning", "Type" => "String", "Default" => "Suspended")
|
|
243
|
-
template.has_output("BucketName", "Value" => RubyCdk::Test.any_value)
|
|
244
261
|
template.template_matches("Parameters" => RubyCdk::Test.any_value)
|
|
245
262
|
assert_equal "RetainExceptOnCreate",
|
|
246
263
|
template.get("Resources.Bucket.DeletionPolicy").as_string
|
|
@@ -256,7 +273,7 @@ That test runs:
|
|
|
256
273
|
|
|
257
274
|
## Security defaults
|
|
258
275
|
|
|
259
|
-
- **Change sets
|
|
276
|
+
- **Change sets by default.** A deploy is a change set you are shown before it executes (`lib/ruby_cdk/deploy/deployer.rb`). The one way around it is the explicit `--hotswap` pair ("The hotswap fast path" above), which applies a Lambda function's code and in-place configuration with one direct `UpdateStack` after the same approval question, under the CDK's drift warning. A failed first deploy passes `OnStackFailure: DELETE`, and a refused creation deletes the stack it created, so nothing half-made is left behind.
|
|
260
277
|
- **Stateful types are retained, not deleted.** The types the CDK retains — S3 buckets, DynamoDB tables, log groups, KMS keys, and the rest of its list — get `DeletionPolicy: RetainExceptOnCreate` and `UpdateReplacePolicy: Retain` from the first synth; RDS instances and clusters get `Snapshot`. `RetainExceptOnCreate` rather than `Retain`, so a creation that rolls back leaves no orphan behind; every change set also executes with `RetainExceptOnCreate: true`, which protects plain-`Retain` templates too (`lib/ruby_cdk/core/stateful.rb`).
|
|
261
278
|
- **The account rule.** A stack with an `env` deploys and is destroyed only into that account — the command resolves who it is with STS and refuses on a mismatch. A stack without one goes wherever the credentials point, with the target printed first; an unattended deploy (`--yes`) of such a stack refuses without `--account ID` naming it (`lib/ruby_cdk/deploy/deployer.rb`).
|
|
262
279
|
- **The asset bucket's owner is checked on every call.** `HeadBucket`, `HeadObject` and `PutObject` all carry `expected_bucket_owner`; a bucket that exists and is not yours stops the deploy before anything is uploaded (`lib/ruby_cdk/assets/uploader.rb`).
|
|
@@ -272,16 +289,18 @@ That test runs:
|
|
|
272
289
|
|
|
273
290
|
Works today:
|
|
274
291
|
|
|
275
|
-
- `ruby-cdk synth`, `validate`, `ls`, `deploy`, `destroy`, `new`, `bootstrap` (`ruby-cdk help COMMAND` for each). `new PROJECT` scaffolds an app: `cdk.rb`, one stack with one private bucket, a Gemfile, `.gitattributes` and `.gitignore`.
|
|
292
|
+
- `ruby-cdk synth`, `validate`, `ls`, `diff`, `deploy`, `destroy`, `new`, `bootstrap` (`ruby-cdk help COMMAND` for each). `new PROJECT` scaffolds an app: `cdk.rb`, one stack with one private bucket, a Gemfile, `.gitattributes` and `.gitignore`.
|
|
276
293
|
- Schema-backed synthesis with the normalizer and rules V1–V23.
|
|
277
294
|
- File assets with content hashing, zipping at deploy, and the bootstrap bucket; templates above 51,200 bytes deploy by URL.
|
|
278
|
-
- The nag rule pack — seventeen security rules over every
|
|
295
|
+
- The nag rule pack — seventeen security rules over every example's synthesized template, run with `rake nag`, suppressed per resource or in `.ruby-cdk/nag.yml`.
|
|
279
296
|
- The test kit, `RubyCdk::Test`, with the CDK's assertions ported.
|
|
280
|
-
-
|
|
297
|
+
- Two scenarios run end to end in CI against the AWS Emulator, which answers as CloudFormation does (`rake integration`), and the same two against the real sandbox before a release: a stack created, updated through a change set, deployed again with nothing changed and destroyed; and a Lambda function whose code is a zipped asset, bootstrapped, created, updated through `--hotswap`, left untouched by `--hotswap` when a change is refused, updated through `--hotswap-fallback`, and destroyed.
|
|
298
|
+
- Curated constructs — `S3::Bucket`, `IAM::Role`, `Lambda::Function`, `DynamoDB::Table`, `SQS::Queue`, `SNS::Topic`, `Logs::LogGroup`, `SSM::Parameter`, a `SecretsManager::Secret` reference, `Events::Rule`, `ApiGateway::RestApi`, `KMS::Key` — with explicit grants, and `ruby-cdk diff` against the deployed template. `KMS::Key` brings customer-managed encryption to the bucket (`encryption: :kms`, `encryption_key:`), the queue (`encryption:`, `encryption_master_key:`), the topic (`master_key:`) and the table (`encryption:`, `encryption_key:`), with the grants on the key the CDK's own grants add.
|
|
299
|
+
- Two examples that put the constructs in one stack: `examples/app` — a function, a table, a bucket and one least-privilege role for them all — and `examples/api` — a function behind a REST API and a scheduled rule, with the queue, topic and parameter grants and the two Lambda permissions a service principal needs to call a function itself. Both are under the determinism and nag gates.
|
|
281
300
|
|
|
282
|
-
Next:
|
|
301
|
+
Next: context providers (lookups of existing resources). `deploy --hotswap` is there (see "The hotswap fast path" above).
|
|
283
302
|
|
|
284
|
-
And the honest part: this is 0.0.
|
|
303
|
+
And the honest part: this is 0.1.0. The APIs — `Stack`, `App`, `Test`, the constructs, the CLI options — may still change between versions. Pin the version you build against.
|
|
285
304
|
|
|
286
305
|
## Development
|
|
287
306
|
|
|
@@ -292,7 +311,7 @@ bundle install
|
|
|
292
311
|
bundle exec rake # everything that must pass before a commit
|
|
293
312
|
```
|
|
294
313
|
|
|
295
|
-
The default gate is an explicit list: `test`, `rubocop`, `typecheck` (Sorbet), `coverage:check` (floor 85%), `determinism`, `
|
|
314
|
+
The default gate is an explicit list: `test`, `rubocop`, `typecheck` (Sorbet), `coverage:check` (floor 85%), `determinism`, `parity`, `nag`, `purity`. It never touches the network and never calls AWS. `rake -T` lists the rest — `rake mutation`, and the network tasks `spec:update` and `corpus:update`, which CI runs weekly and everyone else runs by hand, on purpose.
|
|
296
315
|
|
|
297
316
|
The tests: `test/unit/` for each component alone, `test/cdk/` for the CDK's suites ported (every file's header names the origin path, commit and licence), `test/architecture/` for the component map — the set of components and their dependencies, enforced by a test so no shortcut crosses a boundary — and `test/integration/`, of which only the in-process part runs in the gate. The design documents under `docs/` are not part of a fresh clone: the owner keeps them local (decision D-025), so the code comments and this README are the public record.
|
|
298
317
|
|
data/THIRD_PARTY_NOTICES.md
CHANGED
|
@@ -18,7 +18,7 @@ Copyright 2018-2026 Amazon.com, Inc. or its affiliates. All Rights Reserved.
|
|
|
18
18
|
|
|
19
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
20
|
|
|
21
|
-
The files of the test kit were read at commit `025a6f67fec3d37a6ffdc6168f8a751a04918f66` (the head of `main` on 2026-11-23);
|
|
21
|
+
The files of the test kit were read at commit `025a6f67fec3d37a6ffdc6168f8a751a04918f66` (the head of `main` on 2026-11-23); the commit each other table was read at stands in the line above it, and a table whose rows read at different commits carries a `Read at` column. 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
22
|
|
|
23
23
|
#### Code: `RubyCdk::Test`, the equivalent of `aws-cdk-lib/assertions`
|
|
24
24
|
|
|
@@ -44,6 +44,25 @@ The files of the test kit were read at commit `025a6f67fec3d37a6ffdc6168f8a751a0
|
|
|
44
44
|
|
|
45
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
46
|
|
|
47
|
+
#### Code: the curated constructs (Waves 7 and 8)
|
|
48
|
+
|
|
49
|
+
All read at commit `c070afb54b9e4dbddd52a85a21077fe970354985` (aws/aws-cdk, `main`, read 2026-11-25 and 2026-11-27); Apache-2.0.
|
|
50
|
+
|
|
51
|
+
| File in this repository | Ported from | Licence | What it is |
|
|
52
|
+
|---|---|---|---|
|
|
53
|
+
| `lib/ruby_cdk/constructs/bucket.rb` | `packages/aws-cdk-lib/aws-s3/lib/bucket.ts` | Apache-2.0 | The L2 bucket: encryption and the public access block written out, grants |
|
|
54
|
+
| `lib/ruby_cdk/constructs/function.rb` | `packages/aws-cdk-lib/aws-lambda/lib/function.ts` | Apache-2.0 | The L2 function: code, handler, runtime, environment, grants |
|
|
55
|
+
| `lib/ruby_cdk/constructs/log_group.rb` | `packages/aws-cdk-lib/aws-logs/lib/log-group.ts` | Apache-2.0 | The L2 log group: retention, the `/aws/lambda/<name>` shape |
|
|
56
|
+
| `lib/ruby_cdk/constructs/queue.rb` | `packages/aws-cdk-lib/aws-sqs/lib/queue.ts` | Apache-2.0 | The L2 queue and its grants |
|
|
57
|
+
| `lib/ruby_cdk/constructs/topic.rb` | `packages/aws-cdk-lib/aws-sns/lib/topic.ts` | Apache-2.0 | The L2 topic and its grants |
|
|
58
|
+
| `lib/ruby_cdk/constructs/table.rb` | `packages/aws-cdk-lib/aws-dynamodb/lib/table.ts` | Apache-2.0 | The L2 table: billing, point-in-time recovery, grants |
|
|
59
|
+
| `lib/ruby_cdk/constructs/role.rb` | `packages/aws-cdk-lib/aws-iam/lib/role.ts` | Apache-2.0 | The L2 role: trust policy, managed policies, grants |
|
|
60
|
+
| `lib/ruby_cdk/constructs/ssm_parameter.rb` | `packages/aws-cdk-lib/aws-ssm/lib/parameter.ts` | Apache-2.0 | `StringParameter` and `StringListParameter` as one class: name checks, tiers, allowed pattern, read/write grants |
|
|
61
|
+
| `lib/ruby_cdk/constructs/secret.rb` | `packages/aws-cdk-lib/aws-secretsmanager/lib/secret.ts`, `packages/aws-cdk-lib/core/lib/secret-value.ts` | Apache-2.0 | `fromSecretNameV2` and `SecretValue.secretsManager` as reference-only helpers: no tree node, no lookup, no grants |
|
|
62
|
+
| `lib/ruby_cdk/constructs/schedule.rb` | `packages/aws-cdk-lib/aws-events/lib/schedule.ts` | Apache-2.0 | The `Schedule` factories: `rate`, `cron`, `expression` |
|
|
63
|
+
| `lib/ruby_cdk/constructs/events_rule.rb` | `packages/aws-cdk-lib/aws-events/lib/rule.ts` | Apache-2.0 | The `Rule`: schedule and event pattern, pattern merging, targets |
|
|
64
|
+
| `lib/ruby_cdk/constructs/restapi.rb` | `packages/aws-cdk-lib/aws-apigateway/lib/lambda-api.ts`, `integrations/lambda.ts`, `restapi.ts` | Apache-2.0 | `LambdaRestApi` over `RestApi`: the proxy resource, the ANY methods, the deployment and stage, the endpoint output |
|
|
65
|
+
|
|
47
66
|
#### Tests: the CDK's own tests of that package, ported
|
|
48
67
|
|
|
49
68
|
| File in this repository | Ported from | Licence | Cases |
|
|
@@ -62,6 +81,28 @@ Two files of the package are not ported, because they test what this tool does n
|
|
|
62
81
|
|---|---|---|---|
|
|
63
82
|
| `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
83
|
| `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 |
|
|
84
|
+
| `test/unit/assets/record_test.rb` | `packages/aws-cdk-lib/aws-s3-assets/test/asset.test.ts` | `78649cb7cf7399204ed63f629964779eeaa8b37a` | 1 ported; the rest of asset.test.ts not ported (listed in the header) |
|
|
85
|
+
| `test/cdk/core/stack_test.rb` | `packages/aws-cdk-lib/core/test/stack.test.ts` | `622f51fa4999d5557c1d1da292c04cc186ac6818` | 36 ported, 132 not ported (listed in the header) |
|
|
86
|
+
| `test/cdk/core/resource_test.rb` | `packages/aws-cdk-lib/core/test/resource.test.ts` | `622f51fa4999d5557c1d1da292c04cc186ac6818` | 13 ported, 25 not ported (listed in the header) |
|
|
87
|
+
| `test/cdk/validation/valid_test.rb` | `packages/aws-cdk-lib/cloudformation-include/test/valid-templates.test.ts` | `68b2516c09791d78b199f30e455e4670dc9cde6d` | 56 ported, 26 not ported (listed in the header) |
|
|
88
|
+
| `test/cdk/validation/invalid_test.rb` | `packages/aws-cdk-lib/cloudformation-include/test/invalid-templates.test.ts` | `68b2516c09791d78b199f30e455e4670dc9cde6d` | 30 ported, 12 not ported (listed in the header) |
|
|
89
|
+
|
|
90
|
+
#### Tests: the constructs' own suites, ported
|
|
91
|
+
|
|
92
|
+
All read at commit `c070afb54b9e4dbddd52a85a21077fe970354985` (aws/aws-cdk, `main`, read 2026-11-25 and 2026-11-27); Apache-2.0.
|
|
93
|
+
|
|
94
|
+
| File in this repository | Ported from | Licence | Cases |
|
|
95
|
+
|---|---|---|---|
|
|
96
|
+
| `test/cdk/constructs/bucket_test.rb` | `packages/aws-cdk-lib/aws-s3/test/bucket.test.ts` | Apache-2.0 | 11 ported, 189 not ported (listed in the header) |
|
|
97
|
+
| `test/cdk/constructs/events_rule_test.rb` | `packages/aws-cdk-lib/aws-events/test/rule.test.ts` | Apache-2.0 | 15 ported, 28 not ported (listed in the header) |
|
|
98
|
+
| `test/cdk/constructs/function_test.rb` | `packages/aws-cdk-lib/aws-lambda/test/function.test.ts` | Apache-2.0 | 5 ported, 199 not ported (listed in the header) |
|
|
99
|
+
| `test/cdk/constructs/log_group_test.rb` | `packages/aws-cdk-lib/aws-logs/test/loggroup.test.ts` | Apache-2.0 | 5 ported, 48 not ported (listed in the header) |
|
|
100
|
+
| `test/cdk/constructs/queue_test.rb` | `packages/aws-cdk-lib/aws-sqs/test/sqs.test.ts` | Apache-2.0 | 6 ported, 53 not ported (listed in the header) |
|
|
101
|
+
| `test/cdk/constructs/restapi_test.rb` | `packages/aws-cdk-lib/aws-apigateway/test/restapi.test.ts`, `packages/aws-cdk-lib/aws-apigateway/test/lambda-api.test.ts` | Apache-2.0 | 3 ported, 95 not ported (listed in the header) |
|
|
102
|
+
| `test/cdk/constructs/role_test.rb` | `packages/aws-cdk-lib/aws-iam/test/role.test.ts` | Apache-2.0 | 16 ported, 41 not ported (listed in the header) |
|
|
103
|
+
| `test/cdk/constructs/ssm_parameter_test.rb` | `packages/aws-cdk-lib/aws-ssm/test/parameter.test.ts` | Apache-2.0 | 22 ported, 41 not ported (listed in the header) |
|
|
104
|
+
| `test/cdk/constructs/table_test.rb` | `packages/aws-cdk-lib/aws-dynamodb/test/dynamodb.test.ts` | Apache-2.0 | 12 ported, 154 not ported (listed in the header) |
|
|
105
|
+
| `test/cdk/constructs/topic_test.rb` | `packages/aws-cdk-lib/aws-sns/test/sns.test.ts` | Apache-2.0 | 10 ported, 44 not ported (listed in the header) |
|
|
65
106
|
|
|
66
107
|
#### Fixtures: the corpus sample
|
|
67
108
|
|
|
@@ -84,6 +125,18 @@ Repository: <https://github.com/aws/aws-cdk-cli>. Licence: Apache-2.0, the full
|
|
|
84
125
|
| `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
126
|
| `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
127
|
|
|
128
|
+
#### Tests: the deploy, destroy and diff commands, ported
|
|
129
|
+
|
|
130
|
+
All read at commit `eca1b73d682d7763955bec30ab5dd52bbc4327b6` (`main`, read 2026-11-24 and 2026-11-25); Apache-2.0.
|
|
131
|
+
|
|
132
|
+
| File in this repository | Ported from | Read at | Cases |
|
|
133
|
+
|---|---|---|---|
|
|
134
|
+
| `test/cdk/cli/deploy_stack_test.rb` | `packages/@aws-cdk/toolkit-lib/test/api/deployments/deploy-stack.test.ts` | `eca1b73d682d7763955bec30ab5dd52bbc4327b6` | 40 ported, 77 not ported (listed in the header) |
|
|
135
|
+
| `test/cdk/cli/cloudformation_deployments_test.rb` | `packages/@aws-cdk/toolkit-lib/test/api/deployments/cloudformation-deployments.test.ts` | `eca1b73d682d7763955bec30ab5dd52bbc4327b6` | 0 ported, 35 not ported (listed in the header) |
|
|
136
|
+
| `test/cdk/cli/destroy_test.rb` | `packages/@aws-cdk/toolkit-lib/test/actions/destroy.test.ts` | `eca1b73d682d7763955bec30ab5dd52bbc4327b6` | 4 ported, 21 not ported (listed in the header) |
|
|
137
|
+
| `test/cdk/diff/commands_diff_test.rb` | `packages/aws-cdk/test/commands/diff.test.ts` | `eca1b73d682d7763955bec30ab5dd52bbc4327b6` | 11 ported, 41 not ported (listed in the header) |
|
|
138
|
+
| `test/cdk/diff/diff_template_test.rb` | `packages/@aws-cdk/cloudformation-diff/test/diff-template.test.ts` | `eca1b73d682d7763955bec30ab5dd52bbc4327b6` | 26 ported, 5 not ported (listed in the header) |
|
|
139
|
+
|
|
87
140
|
### stelligent/cfn_nag
|
|
88
141
|
|
|
89
142
|
Copyright (c) 2016-2021 Stelligent Systems LLC. Licence: MIT, the full text of which is at `test/fixtures/nag/LICENSE.cfn_nag`.
|
|
@@ -105,10 +158,11 @@ Repository: <https://github.com/cdklabs/cdk-nag>. Read at commit `da5bed77c1b08e
|
|
|
105
158
|
| File in this repository | Ported from | Licence | What it is |
|
|
106
159
|
|---|---|---|---|
|
|
107
160
|
| `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 |
|
|
161
|
+
| `lib/ruby_cdk/nag/engine.rb` | `src/nag-pack.ts` | Apache-2.0 | The engine: every rule over every resource, suppressions and acknowledgements |
|
|
108
162
|
|
|
109
163
|
### stelligent/cfn-model
|
|
110
164
|
|
|
111
|
-
Copyright (c) 2016-2020 Stelligent Systems LLC. Licence: MIT,
|
|
165
|
+
Copyright (c) 2016-2020 Stelligent Systems LLC. Licence: MIT, as published in that repository's `LICENSE` file. No cfn-model fixture is shipped here; the MIT text at `test/fixtures/nag/LICENSE.cfn_nag` is cfn_nag's, not this project's.
|
|
112
166
|
|
|
113
167
|
Repository: <https://github.com/stelligent/cfn-model>. Read at commit `3ca846093639c1bfdf2069d33c8050ad66122e6b` (v0.6.6, the version cfn-nag pins).
|
|
114
168
|
|
data/data/spec/META.json
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
{
|
|
2
2
|
"counts": {
|
|
3
|
-
"only_provider_schemas":
|
|
3
|
+
"only_provider_schemas": 32,
|
|
4
4
|
"only_resource_specification": 231,
|
|
5
|
-
"provider_schemas":
|
|
5
|
+
"provider_schemas": 1930,
|
|
6
6
|
"resource_specification": 2129,
|
|
7
|
-
"types":
|
|
7
|
+
"types": 2161
|
|
8
8
|
},
|
|
9
9
|
"meta_format": 2,
|
|
10
10
|
"model_format": 1,
|
|
11
|
-
"model_sha256": "
|
|
11
|
+
"model_sha256": "2e26ca273097180f07a9d9a73a8873055c9ea0926edb8f001d270fcbaa9dafd8",
|
|
12
12
|
"region": "us-east-1",
|
|
13
|
-
"schema_version": "resource specification 273.0.0, model sha256:
|
|
13
|
+
"schema_version": "resource specification 273.0.0, model sha256:2e26ca273097180f07a9d9a73a8873055c9ea0926edb8f001d270fcbaa9dafd8, model format 1",
|
|
14
14
|
"sources": {
|
|
15
15
|
"provider_schemas": {
|
|
16
|
-
"bytes":
|
|
17
|
-
"etag": "\"
|
|
18
|
-
"last_modified": "2026-11-
|
|
19
|
-
"sha256": "
|
|
20
|
-
"types":
|
|
16
|
+
"bytes": 3440832,
|
|
17
|
+
"etag": "\"cc9255aab77bcb2172e0f0a7b122c4ea\"",
|
|
18
|
+
"last_modified": "2026-11-30T02:29:14Z",
|
|
19
|
+
"sha256": "c715c07836ece9337135cb32b7928d9f8963c4821f055b62ae3b2dfe44da96b9",
|
|
20
|
+
"types": 1930,
|
|
21
21
|
"url": "https://schema.cloudformation.us-east-1.amazonaws.com/CloudformationSchema.zip"
|
|
22
22
|
},
|
|
23
23
|
"resource_specification": {
|
data/data/spec/model.json.gz
CHANGED
|
Binary file
|
data/lib/ruby_cdk/cli/diff.rb
CHANGED
|
@@ -26,13 +26,25 @@ module RubyCdk
|
|
|
26
26
|
# Output is text for a person on standard error -- where the CDK prints
|
|
27
27
|
# it too (its io host routes everything but result and error to standard
|
|
28
28
|
# error) -- and, with --json, one machine object per stack on standard
|
|
29
|
-
# output and nothing else there.
|
|
30
|
-
#
|
|
31
|
-
# the CDK's
|
|
32
|
-
#
|
|
33
|
-
# the
|
|
29
|
+
# output and nothing else there.
|
|
30
|
+
#
|
|
31
|
+
# The exit code is the CDK's (cdk-toolkit.ts, `diff` and diffFails, and
|
|
32
|
+
# cli.ts, both at f7c9dca95f440a076c2abd61b66b984624b8548e, in
|
|
33
|
+
# aws/aws-cdk-cli): 0 whatever the diff holds, until --fail-on names a
|
|
34
|
+
# kind of change it contains. any-change fails when a stack differs,
|
|
35
|
+
# broadening when a stack's changes broaden permissions, destructive when
|
|
36
|
+
# a change replaces, destroys or orphans a resource, never fails. --fail
|
|
37
|
+
# is the CDK's alias for any-change and --no-fail for never, and neither
|
|
38
|
+
# goes with --fail-on. Under --security-only the CDK counts a stack, for
|
|
39
|
+
# the closing line and for any-change, only when its changes broaden
|
|
40
|
+
# permissions, and so does this command.
|
|
34
41
|
module Diff
|
|
42
|
+
# The kinds of change --fail-on names: the CDK's choices for the option
|
|
43
|
+
# (parse-command-line-arguments.ts:987-993 at the commit above).
|
|
44
|
+
FAIL_ON = %w[never any-change broadening destructive].freeze
|
|
45
|
+
|
|
35
46
|
def self.run(session, names)
|
|
47
|
+
fail_on = fail_on_category(session)
|
|
36
48
|
manifest = session.manifest
|
|
37
49
|
session.say_synthesis_time
|
|
38
50
|
selected = Selection.choose(session.stacks, names:, all: session.options.all, command: "diff")
|
|
@@ -54,9 +66,55 @@ module RubyCdk
|
|
|
54
66
|
session.io.say(text.chomp) unless text.empty?
|
|
55
67
|
end
|
|
56
68
|
session.io.say(summary(counted(diffs, security_only)))
|
|
69
|
+
destructive(session, diffs, fail_on)
|
|
70
|
+
end
|
|
71
|
+
|
|
72
|
+
fails?(fail_on, diffs, security_only) ? 1 : Cli::SUCCESS
|
|
73
|
+
end
|
|
74
|
+
|
|
75
|
+
# What --fail, --no-fail and --fail-on asked for, as one of FAIL_ON. The
|
|
76
|
+
# CDK's reading of the three (cli.ts:363-395 at the commit above):
|
|
77
|
+
#
|
|
78
|
+
# - --fail is --fail-on=any-change, and --no-fail is --fail-on=never;
|
|
79
|
+
# - neither of the two goes with --fail-on: a usage error, in the CDK's
|
|
80
|
+
# words;
|
|
81
|
+
# - with none of them the answer is never. The CDK decides that one on
|
|
82
|
+
# its aws-cdk:enableDiffNoFail context flag, which is on when nothing
|
|
83
|
+
# configures it (aws-cdk-lib, cx-api/lib/features.ts:196-213 at
|
|
84
|
+
# 2.260.0, the release the CLI's yarn.lock pins); this tool has no
|
|
85
|
+
# context, so the answer is the same.
|
|
86
|
+
#
|
|
87
|
+
# Read before the app is loaded: the CDK's parser refuses the option
|
|
88
|
+
# before anything runs.
|
|
89
|
+
def self.fail_on_category(session)
|
|
90
|
+
fail = session.options.fail
|
|
91
|
+
given = session.options.fail_on
|
|
92
|
+
if !fail.nil? && !given.nil?
|
|
93
|
+
raise Usage.new(
|
|
94
|
+
fail ? "--fail cannot be used with --fail-on, use --fail-on=any-change instead of --fail" :
|
|
95
|
+
"--no-fail cannot be used with --fail-on, use --fail-on=never instead of --no-fail",
|
|
96
|
+
next_step: "Run `ruby-cdk #{session.command}` again with --fail-on alone, or with --fail or --no-fail alone."
|
|
97
|
+
)
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
unless given.nil? || FAIL_ON.include?(given)
|
|
101
|
+
raise Usage.new("--fail-on must be one of #{FAIL_ON.join(", ")}, not #{given.inspect}",
|
|
102
|
+
next_step: "Run `ruby-cdk #{session.command}` again with --fail-on naming one of the four.")
|
|
57
103
|
end
|
|
104
|
+
return given if given
|
|
58
105
|
|
|
59
|
-
|
|
106
|
+
fail ? "any-change" : "never"
|
|
107
|
+
end
|
|
108
|
+
|
|
109
|
+
# The CDK's diffFails (cdk-toolkit.ts:2745-2756): whether the diffs of
|
|
110
|
+
# these stacks hold the kind of change named.
|
|
111
|
+
def self.fails?(fail_on, diffs, security_only)
|
|
112
|
+
case fail_on
|
|
113
|
+
when "any-change" then counted(diffs, security_only).positive?
|
|
114
|
+
when "broadening" then diffs.any? { |diff| diff.security.broadening? }
|
|
115
|
+
when "destructive" then diffs.any? { |diff| diff.destructive_changes.any? }
|
|
116
|
+
else false
|
|
117
|
+
end
|
|
60
118
|
end
|
|
61
119
|
|
|
62
120
|
# The CDK's closing line (cdk-toolkit.ts, `Number of stacks with
|
|
@@ -65,6 +123,24 @@ module RubyCdk
|
|
|
65
123
|
"✨ Number of stacks with differences: #{count}"
|
|
66
124
|
end
|
|
67
125
|
|
|
126
|
+
# What --fail-on=destructive prints after the closing line
|
|
127
|
+
# (cdk-toolkit.ts:429-434): how many changes replace, destroy or orphan
|
|
128
|
+
# a resource, then one line for each, `Stack: Type LogicalId` and the
|
|
129
|
+
# impact in a few words. Only that option looks for them. Nothing under
|
|
130
|
+
# --json: the stack's object carries them as destructive_changes.
|
|
131
|
+
def self.destructive(session, diffs, fail_on)
|
|
132
|
+
return unless fail_on == "destructive"
|
|
133
|
+
|
|
134
|
+
lines = diffs.flat_map do |diff|
|
|
135
|
+
diff.destructive_changes.map { |change| " #{diff.stack_name}: #{change.line}" }
|
|
136
|
+
end
|
|
137
|
+
return if lines.empty?
|
|
138
|
+
|
|
139
|
+
session.io.say("❌ Found #{lines.length} destructive change(s) (--fail-on=destructive):")
|
|
140
|
+
session.io.say(lines.join("\n"))
|
|
141
|
+
session.io.say
|
|
142
|
+
end
|
|
143
|
+
|
|
68
144
|
# One stack, from synthesis's output to its diff.
|
|
69
145
|
def self.one(session, entry)
|
|
70
146
|
stack = session.stack(entry.name)
|
|
@@ -85,9 +161,14 @@ module RubyCdk
|
|
|
85
161
|
session.io.say("Including dependency stacks: #{extra.join(", ")}")
|
|
86
162
|
end
|
|
87
163
|
|
|
164
|
+
# How many stacks count for the closing line and for any-change: the
|
|
165
|
+
# CDK's numStacksWithChanges. Without --security-only a stack counts when
|
|
166
|
+
# its diff is not empty; with it, when its changes broaden permissions
|
|
167
|
+
# (cdk-toolkit.ts:331-336 and 401-406, where a broadening stack is the
|
|
168
|
+
# only one counted).
|
|
88
169
|
def self.counted(diffs, security_only)
|
|
89
170
|
if security_only
|
|
90
|
-
diffs.count { |diff| diff.security.
|
|
171
|
+
diffs.count { |diff| diff.security.broadening? }
|
|
91
172
|
else
|
|
92
173
|
diffs.count { |diff| !diff.empty? }
|
|
93
174
|
end
|