|
| 1 | +# Custom Resource `Data` GetAtt -> dependent property (failure-seeking) |
| 2 | + |
| 3 | +Surfaces bugs where a Custom Resource's response `Data` — consumed by |
| 4 | +`Fn::GetAtt(CustomResource, '<key>')` (a.k.a. `Data.<key>`) — must flow into |
| 5 | +ANOTHER resource's property. The CR response-`Data` attribute path is fragile |
| 6 | +(issues [#756](https://github.com/go-to-k/cdkd/issues/756) / |
| 7 | +[#804](https://github.com/go-to-k/cdkd/issues/804)) because CR attributes only |
| 8 | +exist AFTER the CR's backing Lambda runs and returns a SUCCESS response. |
| 9 | + |
| 10 | +## What it tests |
| 11 | + |
| 12 | +- An inline Lambda-backed `AWS::CloudFormation::CustomResource` whose handler |
| 13 | + returns `Data: { ComputedValue, Another, NumericValue }` directly in its |
| 14 | + response payload. |
| 15 | +- Three `AWS::SSM::Parameter` dependents whose `Value` is |
| 16 | + `Fn::GetAtt(MyCustomResource, '<key>')` — one per Data key. Multiple keys |
| 17 | + catch a resolver that only wires the first attribute; the stringified-number |
| 18 | + key catches a resolver that mishandles non-text Data. |
| 19 | +- An explicit `addDependency(cr)` on one parameter, so the DAG ordering |
| 20 | + (CR must complete and have its `attributes` populated BEFORE the dependent |
| 21 | + is provisioned) is exercised. |
| 22 | + |
| 23 | +No VPC. No Provider framework (the simple synchronous direct-payload-return |
| 24 | +path — the cheapest way to surface a GetAtt-of-CR-Data resolution bug). |
| 25 | + |
| 26 | +## Architecture |
| 27 | + |
| 28 | +``` |
| 29 | +MyCustomResource (inline Lambda; returns Data: {ComputedValue, Another, NumericValue}) |
| 30 | + | |
| 31 | + +--> SSM Parameter .../computed Value = Fn::GetAtt(CR, 'ComputedValue') |
| 32 | + +--> SSM Parameter .../another Value = Fn::GetAtt(CR, 'Another') |
| 33 | + +--> SSM Parameter .../numeric Value = Fn::GetAtt(CR, 'NumericValue') |
| 34 | +``` |
| 35 | + |
| 36 | +## verify.sh |
| 37 | + |
| 38 | +Deploys, then reads each SSM parameter back from AWS with |
| 39 | +`aws ssm get-parameter` and asserts its `Value` equals the value the CR |
| 40 | +handler returned (`computed-integ` / `another-<region>` / `42`). This proves |
| 41 | +the CR `Data` attribute resolved THROUGH the intrinsic resolver INTO the |
| 42 | +dependent resource's property — a blank / wrong value would otherwise pass |
| 43 | +unnoticed because nothing else reads it. Then destroys and asserts the state |
| 44 | +file, both SSM parameters, and the backing Lambda are gone. |
| 45 | + |
| 46 | +## Deploy / Destroy |
| 47 | + |
| 48 | +```bash |
| 49 | +cdkd deploy CdkdCrGetAttDataExample |
| 50 | +cdkd destroy CdkdCrGetAttDataExample |
| 51 | +``` |
0 commit comments