Skip to content

Commit

Permalink
Fix implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
exoego committed Feb 26, 2024
1 parent e764489 commit f9542bf
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 53 deletions.
96 changes: 45 additions & 51 deletions src/__tests__/__snapshots__/stacks.test.ts.snap
Original file line number Diff line number Diff line change
@@ -1,6 +1,18 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Multiple stacks in a single app dependent stacks 1`] = `
{
"Resources": {
"FooDFE0DD70": {
"DeletionPolicy": "Retain",
"Type": "AWS::S3::Bucket",
"UpdateReplacePolicy": "Retain",
},
},
}
`;

exports[`Multiple stacks in a single app dependent stacks 2`] = `
{
"Resources": {
"BarA6AB415C": {
Expand Down Expand Up @@ -60,7 +72,32 @@ exports[`Multiple stacks in a single app dependent stacks 1`] = `
}
`;

exports[`Multiple stacks in a single app dependent stacks 2`] = `
exports[`Multiple stacks in a single app one stack referencing the other 1`] = `
{
"Outputs": {
"ExportsOutputFnGetAttFooDFE0DD70Arn2A3BEF77": {
"Export": {
"Name": "S3:ExportsOutputFnGetAttFooDFE0DD70Arn2A3BEF77",
},
"Value": {
"Fn::GetAtt": [
"FooDFE0DD70",
"Arn",
],
},
},
},
"Resources": {
"FooDFE0DD70": {
"DeletionPolicy": "Retain",
"Type": "AWS::S3::Bucket",
"UpdateReplacePolicy": "Retain",
},
},
}
`;

exports[`Multiple stacks in a single app one stack referencing the other 2`] = `
{
"Resources": {
"BarA6AB415C": {
Expand All @@ -74,6 +111,13 @@ exports[`Multiple stacks in a single app dependent stacks 2`] = `
},
"S3Key": "7ecc77636deefb31954ea2e6aadf6d2c361a2943535a678d65f46a8de5e1f503.zip",
},
"Environment": {
"Variables": {
"bucket": {
"Fn::ImportValue": "S3:ExportsOutputFnGetAttFooDFE0DD70Arn2A3BEF77",
},
},
},
"Handler": "index.handler",
"Role": {
"Fn::GetAtt": [
Expand Down Expand Up @@ -119,53 +163,3 @@ exports[`Multiple stacks in a single app dependent stacks 2`] = `
},
}
`;

exports[`Multiple stacks in a single app one stack referencing the other 1`] = `
{
"Outputs": {
"ExportsOutputFnGetAttFooDFE0DD70Arn2A3BEF77": {
"Export": {
"Name": "S3:ExportsOutputFnGetAttFooDFE0DD70Arn2A3BEF77",
},
"Value": {
"Fn::GetAtt": [
"FooDFE0DD70",
"Arn",
],
},
},
},
"Resources": {
"FooDFE0DD70": {
"DeletionPolicy": "Retain",
"Type": "AWS::S3::Bucket",
"UpdateReplacePolicy": "Retain",
},
},
}
`;

exports[`Multiple stacks in a single app one stack referencing the other 2`] = `
{
"Outputs": {
"ExportsOutputFnGetAttFooDFE0DD70Arn2A3BEF77": {
"Export": {
"Name": "S3:ExportsOutputFnGetAttFooDFE0DD70Arn2A3BEF77",
},
"Value": {
"Fn::GetAtt": [
"FooDFE0DD70",
"Arn",
],
},
},
},
"Resources": {
"FooDFE0DD70": {
"DeletionPolicy": "Retain",
"Type": "AWS::S3::Bucket",
"UpdateReplacePolicy": "Retain",
},
},
}
`;
24 changes: 22 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { App, Stack, StageSynthesisOptions } from "aws-cdk-lib";
import { Template } from "aws-cdk-lib/assertions";
import { Stack, StageSynthesisOptions } from "aws-cdk-lib";
import { toMatchSnapshot } from "jest-snapshot";
import * as jsYaml from "js-yaml";

Expand All @@ -12,6 +13,21 @@ declare global {
}

type Options = StageSynthesisOptions & {
/**
* @deprecated No effect. Please remove this, there is no alternative.
*/
readonly skipValidation?: boolean;

/**
* @deprecated No effect. Please remove this, there is no alternative.
*/
readonly validateOnSynthesis?: boolean;

/**
* @deprecated No effect. Please remove this, there is no alternative.
*/
readonly force?: boolean;

/**
* Output snapshots in YAML (instead of JSON)
*/
Expand Down Expand Up @@ -110,7 +126,11 @@ const convertStack = (stack: Stack, options: Options = {}) => {
...synthOptions
} = options;

const template = App.of(stack)?.synth(synthOptions).stacks[0].template ?? {};
if (Object.keys(synthOptions).length > 0) {
console.warn("Synth options are no longer supported. Please remove them.");
}

const template = Template.fromStack(stack, {}).toJSON();

if (ignoreBootstrapVersion) {
if (template.Parameters) {
Expand Down

0 comments on commit f9542bf

Please sign in to comment.