@intentius/chant-lexicon-aws 0.0.14 → 0.0.15
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.
- package/dist/integrity.json +6 -5
- package/dist/manifest.json +1 -1
- package/dist/meta.json +744 -16
- package/dist/rules/waw030.ts +55 -0
- package/dist/rules/waw031.ts +66 -0
- package/dist/types/index.d.ts +773 -34
- package/package.json +29 -26
- package/src/codegen/docs.ts +11 -1
- package/src/generated/index.d.ts +773 -34
- package/src/generated/index.ts +62 -3
- package/src/generated/lexicon-aws.json +744 -16
- package/src/lint/post-synth/waw030.test.ts +209 -1
- package/src/lint/post-synth/waw030.ts +55 -0
- package/src/lint/post-synth/waw031.test.ts +273 -0
- package/src/lint/post-synth/waw031.ts +66 -0
- package/src/plugin.ts +2 -1
- package/src/serializer.test.ts +40 -0
- package/src/serializer.ts +6 -1
package/src/serializer.test.ts
CHANGED
|
@@ -326,6 +326,46 @@ describe("LexiconOutput serialization", () => {
|
|
|
326
326
|
});
|
|
327
327
|
});
|
|
328
328
|
|
|
329
|
+
// ── StackOutput Serialization ──────────────────────────
|
|
330
|
+
|
|
331
|
+
describe("stackOutput serialization", () => {
|
|
332
|
+
test("Id attribute uses Ref (not Fn::GetAtt)", () => {
|
|
333
|
+
const bucket = new MockBucket({ BucketName: "my-bucket" });
|
|
334
|
+
const idRef = new AttrRef(bucket, "Id");
|
|
335
|
+
idRef._setLogicalName("MyBucket");
|
|
336
|
+
|
|
337
|
+
const output = stackOutput(idRef);
|
|
338
|
+
|
|
339
|
+
const entities = new Map<string, Declarable>();
|
|
340
|
+
entities.set("MyBucket", bucket);
|
|
341
|
+
entities.set("MyBucketId", output as unknown as Declarable);
|
|
342
|
+
|
|
343
|
+
const result = awsSerializer.serialize(entities);
|
|
344
|
+
const template = JSON.parse(result as string);
|
|
345
|
+
|
|
346
|
+
expect(template.Outputs.MyBucketId.Value).toEqual({ Ref: "MyBucket" });
|
|
347
|
+
});
|
|
348
|
+
|
|
349
|
+
test("non-Id attribute uses Fn::GetAtt", () => {
|
|
350
|
+
const bucket = new MockBucket({ BucketName: "my-bucket" });
|
|
351
|
+
const arnRef = new AttrRef(bucket, "Arn");
|
|
352
|
+
arnRef._setLogicalName("MyBucket");
|
|
353
|
+
|
|
354
|
+
const output = stackOutput(arnRef);
|
|
355
|
+
|
|
356
|
+
const entities = new Map<string, Declarable>();
|
|
357
|
+
entities.set("MyBucket", bucket);
|
|
358
|
+
entities.set("MyBucketArn", output as unknown as Declarable);
|
|
359
|
+
|
|
360
|
+
const result = awsSerializer.serialize(entities);
|
|
361
|
+
const template = JSON.parse(result as string);
|
|
362
|
+
|
|
363
|
+
expect(template.Outputs.MyBucketArn.Value).toEqual({
|
|
364
|
+
"Fn::GetAtt": ["MyBucket", "Arn"],
|
|
365
|
+
});
|
|
366
|
+
});
|
|
367
|
+
});
|
|
368
|
+
|
|
329
369
|
// ── Nested Stack Serialization ──────────────────────────
|
|
330
370
|
|
|
331
371
|
function mockChildBuildResult(childTemplate: object): BuildResult {
|
package/src/serializer.ts
CHANGED
|
@@ -282,8 +282,13 @@ function serializeToTemplate(
|
|
|
282
282
|
const ref = stackOutput.sourceRef;
|
|
283
283
|
const logicalName = ref.getLogicalName();
|
|
284
284
|
if (logicalName) {
|
|
285
|
+
// Use Ref for primary identifier ("Id") since not all resources
|
|
286
|
+
// support Fn::GetAtt for their primary identifier (e.g. ACM Certificate).
|
|
287
|
+
// Ref always returns the primary identifier for any CF resource.
|
|
285
288
|
const output: CFOutput = {
|
|
286
|
-
Value:
|
|
289
|
+
Value: ref.attribute === "Id"
|
|
290
|
+
? { Ref: logicalName }
|
|
291
|
+
: { "Fn::GetAtt": [logicalName, ref.attribute] },
|
|
287
292
|
};
|
|
288
293
|
if (stackOutput.description) {
|
|
289
294
|
output.Description = stackOutput.description;
|