diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-iam/test/integ.condition-with-ref.js.snapshot/asset.1e14e895fcbdf65feb0a29e4aa74c6c92a6fb0e41f228bef7ab23627ed409cde/consts.js b/packages/@aws-cdk-testing/framework-integ/test/aws-iam/test/integ.condition-with-ref.js.snapshot/asset.1e14e895fcbdf65feb0a29e4aa74c6c92a6fb0e41f228bef7ab23627ed409cde/consts.js deleted file mode 100644 index dcca3af1f2fb5..0000000000000 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-iam/test/integ.condition-with-ref.js.snapshot/asset.1e14e895fcbdf65feb0a29e4aa74c6c92a6fb0e41f228bef7ab23627ed409cde/consts.js +++ /dev/null @@ -1,18 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.CfnUtilsResourceType = void 0; -/** - * Supported resource type. - */ -var CfnUtilsResourceType; -(function (CfnUtilsResourceType) { - /** - * CfnJson - */ - CfnUtilsResourceType["CFN_JSON"] = "Custom::AWSCDKCfnJson"; - /** - * CfnJsonStringify - */ - CfnUtilsResourceType["CFN_JSON_STRINGIFY"] = "Custom::AWSCDKCfnJsonStringify"; -})(CfnUtilsResourceType || (exports.CfnUtilsResourceType = CfnUtilsResourceType = {})); -//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY29uc3RzLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiY29uc3RzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiI7OztBQUFBOztHQUVHO0FBQ0gsSUFBWSxvQkFVWDtBQVZELFdBQVksb0JBQW9CO0lBQzlCOztPQUVHO0lBQ0gsMERBQWtDLENBQUE7SUFFbEM7O09BRUc7SUFDSCw2RUFBcUQsQ0FBQTtBQUN2RCxDQUFDLEVBVlcsb0JBQW9CLG9DQUFwQixvQkFBb0IsUUFVL0IiLCJzb3VyY2VzQ29udGVudCI6WyIvKipcbiAqIFN1cHBvcnRlZCByZXNvdXJjZSB0eXBlLlxuICovXG5leHBvcnQgZW51bSBDZm5VdGlsc1Jlc291cmNlVHlwZSB7XG4gIC8qKlxuICAgKiBDZm5Kc29uXG4gICAqL1xuICBDRk5fSlNPTiA9ICdDdXN0b206OkFXU0NES0Nmbkpzb24nLFxuXG4gIC8qKlxuICAgKiBDZm5Kc29uU3RyaW5naWZ5XG4gICAqL1xuICBDRk5fSlNPTl9TVFJJTkdJRlkgPSAnQ3VzdG9tOjpBV1NDREtDZm5Kc29uU3RyaW5naWZ5Jyxcbn1cbiJdfQ== \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-iam/test/integ.condition-with-ref.js.snapshot/asset.1e14e895fcbdf65feb0a29e4aa74c6c92a6fb0e41f228bef7ab23627ed409cde/index.js b/packages/@aws-cdk-testing/framework-integ/test/aws-iam/test/integ.condition-with-ref.js.snapshot/asset.1e14e895fcbdf65feb0a29e4aa74c6c92a6fb0e41f228bef7ab23627ed409cde/index.js deleted file mode 100644 index a24d3cad7679f..0000000000000 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-iam/test/integ.condition-with-ref.js.snapshot/asset.1e14e895fcbdf65feb0a29e4aa74c6c92a6fb0e41f228bef7ab23627ed409cde/index.js +++ /dev/null @@ -1,33 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.handler = void 0; -const consts_1 = require("./consts"); -/** - * Parses the value of "Value" and reflects it back as attribute. - */ -async function handler(event) { - // dispatch based on resource type - if (event.ResourceType === consts_1.CfnUtilsResourceType.CFN_JSON) { - return cfnJsonHandler(event); - } - if (event.ResourceType === consts_1.CfnUtilsResourceType.CFN_JSON_STRINGIFY) { - return cfnJsonStringifyHandler(event); - } - throw new Error(`unexpected resource type "${event.ResourceType}`); -} -exports.handler = handler; -function cfnJsonHandler(event) { - return { - Data: { - Value: JSON.parse(event.ResourceProperties.Value), - }, - }; -} -function cfnJsonStringifyHandler(event) { - return { - Data: { - Value: JSON.stringify(event.Res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vbVJlc291cmNlRXZlbnQpIHtcbiAgcmV0dXJuIHtcbiAgICBEYXRhOiB7XG4gICAgICBWYWx1ZTogSlNPTi5zdHJpbmdpZnkoZXZlbnQuUmVzb3VyY2VQcm9wZXJ0aWVzLlZhbHVlKSxcbiAgICB9LFxuICB9O1xufVxuIl19 \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-iam/test/integ.condition-with-ref.js.snapshot/asset.1e14e895fcbdf65feb0a29e4aa74c6c92a6fb0e41f228bef7ab23627ed409cde/__entrypoint__.js b/packages/@aws-cdk-testing/framework-integ/test/aws-iam/test/integ.condition-with-ref.js.snapshot/asset.f58e5b0009fc349d5e78d41594373bd6723e705a3c961a42adfbefa36cbe1bcf/__entrypoint__.js similarity index 100% rename from packages/@aws-cdk-testing/framework-integ/test/aws-iam/test/integ.condition-with-ref.js.snapshot/asset.1e14e895fcbdf65feb0a29e4aa74c6c92a6fb0e41f228bef7ab23627ed409cde/__entrypoint__.js rename to packages/@aws-cdk-testing/framework-integ/test/aws-iam/test/integ.condition-with-ref.js.snapshot/asset.f58e5b0009fc349d5e78d41594373bd6723e705a3c961a42adfbefa36cbe1bcf/__entrypoint__.js diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-iam/test/integ.condition-with-ref.js.snapshot/asset.f58e5b0009fc349d5e78d41594373bd6723e705a3c961a42adfbefa36cbe1bcf/index.js b/packages/@aws-cdk-testing/framework-integ/test/aws-iam/test/integ.condition-with-ref.js.snapshot/asset.f58e5b0009fc349d5e78d41594373bd6723e705a3c961a42adfbefa36cbe1bcf/index.js new file mode 100644 index 0000000000000..db4f4fc8b037f --- /dev/null +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-iam/test/integ.condition-with-ref.js.snapshot/asset.f58e5b0009fc349d5e78d41594373bd6723e705a3c961a42adfbefa36cbe1bcf/index.js @@ -0,0 +1 @@ +"use strict";var u=Object.defineProperty;var a=Object.getOwnPropertyDescriptor;var c=Object.getOwnPropertyNames;var i=Object.prototype.hasOwnProperty;var C=(e,r)=>{for(var o in r)u(e,o,{get:r[o],enumerable:!0})},S=(e,r,o,t)=>{if(r&&typeof r=="object"||typeof r=="function")for(let n of c(r))!i.call(e,n)&&n!==o&&u(e,n,{get:()=>r[n],enumerable:!(t=a(r,n))||t.enumerable});return e};var f=e=>S(u({},"__esModule",{value:!0}),e);var l={};C(l,{CfnUtilsResourceType:()=>s,handler:()=>m});module.exports=f(l);var s=(o=>(o.CFN_JSON="Custom::AWSCDKCfnJson",o.CFN_JSON_STRINGIFY="Custom::AWSCDKCfnJsonStringify",o))(s||{});async function m(e){if(e.ResourceType==="Custom::AWSCDKCfnJson")return N(e);if(e.ResourceType==="Custom::AWSCDKCfnJsonStringify")return d(e);throw new Error(`unexpected resource type "${e.ResourceType}"`)}function N(e){return{Data:{Value:JSON.parse(e.ResourceProperties.Value)}}}function d(e){return{Data:{Value:JSON.stringify(e.ResourceProperties.Value)}}}0&&(module.exports={CfnUtilsResourceType,handler}); diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-iam/test/integ.condition-with-ref.js.snapshot/cdk.out b/packages/@aws-cdk-testing/framework-integ/test/aws-iam/test/integ.condition-with-ref.js.snapshot/cdk.out index 560dae10d018f..2313ab5436501 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-iam/test/integ.condition-with-ref.js.snapshot/cdk.out +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-iam/test/integ.condition-with-ref.js.snapshot/cdk.out @@ -1 +1 @@ -{"version":"33.0.0"} \ No newline at end of file +{"version":"34.0.0"} \ No newline at end of file diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-iam/test/integ.condition-with-ref.js.snapshot/iamtestconditionwithrefDefaultTestDeployAssert5E44A64B.assets.json b/packages/@aws-cdk-testing/framework-integ/test/aws-iam/test/integ.condition-with-ref.js.snapshot/iamtestconditionwithrefDefaultTestDeployAssert5E44A64B.assets.json index b043af1a3d904..df879045ae8ae 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-iam/test/integ.condition-with-ref.js.snapshot/iamtestconditionwithrefDefaultTestDeployAssert5E44A64B.assets.json +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-iam/test/integ.condition-with-ref.js.snapshot/iamtestconditionwithrefDefaultTestDeployAssert5E44A64B.assets.json @@ -1,5 +1,5 @@ { - "version": "33.0.0", + "version": "34.0.0", "files": { "21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22": { "source": { diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-iam/test/integ.condition-with-ref.js.snapshot/integ.json b/packages/@aws-cdk-testing/framework-integ/test/aws-iam/test/integ.condition-with-ref.js.snapshot/integ.json index 2f04f2aac279c..c4f0c83c94eda 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-iam/test/integ.condition-with-ref.js.snapshot/integ.json +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-iam/test/integ.condition-with-ref.js.snapshot/integ.json @@ -1,5 +1,5 @@ { - "version": "33.0.0", + "version": "34.0.0", "testCases": { "iam-test-condition-with-ref/DefaultTest": { "stacks": [ diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-iam/test/integ.condition-with-ref.js.snapshot/manifest.json b/packages/@aws-cdk-testing/framework-integ/test/aws-iam/test/integ.condition-with-ref.js.snapshot/manifest.json index c11acef43c3fc..2a79eb9216da9 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-iam/test/integ.condition-with-ref.js.snapshot/manifest.json +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-iam/test/integ.condition-with-ref.js.snapshot/manifest.json @@ -1,5 +1,5 @@ { - "version": "33.0.0", + "version": "34.0.0", "artifacts": { "test-condition-with-ref.assets": { "type": "cdk:asset-manifest", @@ -14,10 +14,11 @@ "environment": "aws://unknown-account/unknown-region", "properties": { "templateFile": "test-condition-with-ref.template.json", + "terminationProtection": false, "validateOnSynth": false, "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-deploy-role-${AWS::AccountId}-${AWS::Region}", "cloudFormationExecutionRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-cfn-exec-role-${AWS::AccountId}-${AWS::Region}", - "stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/c78c907e2231879b958741f82c29330bcd35d5778c279f9e497f7e8565e6e2cc.json", + "stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/690358b6134a64472e3e0eeef8f797c1affd14b47dca4cd27d31cf840406fb9f.json", "requiresBootstrapStackVersion": 6, "bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version", "additionalDependencies": [ @@ -91,6 +92,7 @@ "environment": "aws://unknown-account/unknown-region", "properties": { "templateFile": "iamtestconditionwithrefDefaultTestDeployAssert5E44A64B.template.json", + "terminationProtection": false, "validateOnSynth": false, "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-deploy-role-${AWS::AccountId}-${AWS::Region}", "cloudFormationExecutionRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-cfn-exec-role-${AWS::AccountId}-${AWS::Region}", diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-iam/test/integ.condition-with-ref.js.snapshot/test-condition-with-ref.assets.json b/packages/@aws-cdk-testing/framework-integ/test/aws-iam/test/integ.condition-with-ref.js.snapshot/test-condition-with-ref.assets.json index 3f6d7f5a53918..4c1cd2d5f8f55 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-iam/test/integ.condition-with-ref.js.snapshot/test-condition-with-ref.assets.json +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-iam/test/integ.condition-with-ref.js.snapshot/test-condition-with-ref.assets.json @@ -1,20 +1,20 @@ { - "version": "33.0.0", + "version": "34.0.0", "files": { - "1e14e895fcbdf65feb0a29e4aa74c6c92a6fb0e41f228bef7ab23627ed409cde": { + "f58e5b0009fc349d5e78d41594373bd6723e705a3c961a42adfbefa36cbe1bcf": { "source": { - "path": "asset.1e14e895fcbdf65feb0a29e4aa74c6c92a6fb0e41f228bef7ab23627ed409cde", + "path": "asset.f58e5b0009fc349d5e78d41594373bd6723e705a3c961a42adfbefa36cbe1bcf", "packaging": "zip" }, "destinations": { "current_account-current_region": { "bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}", - "objectKey": "1e14e895fcbdf65feb0a29e4aa74c6c92a6fb0e41f228bef7ab23627ed409cde.zip", + "objectKey": "f58e5b0009fc349d5e78d41594373bd6723e705a3c961a42adfbefa36cbe1bcf.zip", "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}" } } }, - "c78c907e2231879b958741f82c29330bcd35d5778c279f9e497f7e8565e6e2cc": { + "690358b6134a64472e3e0eeef8f797c1affd14b47dca4cd27d31cf840406fb9f": { "source": { "path": "test-condition-with-ref.template.json", "packaging": "file" @@ -22,7 +22,7 @@ "destinations": { "current_account-current_region": { "bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}", - "objectKey": "c78c907e2231879b958741f82c29330bcd35d5778c279f9e497f7e8565e6e2cc.json", + "objectKey": "690358b6134a64472e3e0eeef8f797c1affd14b47dca4cd27d31cf840406fb9f.json", "assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}" } } diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-iam/test/integ.condition-with-ref.js.snapshot/test-condition-with-ref.template.json b/packages/@aws-cdk-testing/framework-integ/test/aws-iam/test/integ.condition-with-ref.js.snapshot/test-condition-with-ref.template.json index 9c90ab65c0719..6ba9830d714f3 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-iam/test/integ.condition-with-ref.js.snapshot/test-condition-with-ref.template.json +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-iam/test/integ.condition-with-ref.js.snapshot/test-condition-with-ref.template.json @@ -65,7 +65,7 @@ "S3Bucket": { "Fn::Sub": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}" }, - "S3Key": "3e61d858eaa7724170872a455b8f788d5fcf18adba89aadbe603a52dab59d917.zip" + "S3Key": "f58e5b0009fc349d5e78d41594373bd6723e705a3c961a42adfbefa36cbe1bcf.zip" }, "Timeout": 900, "MemorySize": 128, diff --git a/packages/@aws-cdk-testing/framework-integ/test/aws-iam/test/integ.condition-with-ref.js.snapshot/tree.json b/packages/@aws-cdk-testing/framework-integ/test/aws-iam/test/integ.condition-with-ref.js.snapshot/tree.json index ad8cf02d25aa4..4bde78b3deaf7 100644 --- a/packages/@aws-cdk-testing/framework-integ/test/aws-iam/test/integ.condition-with-ref.js.snapshot/tree.json +++ b/packages/@aws-cdk-testing/framework-integ/test/aws-iam/test/integ.condition-with-ref.js.snapshot/tree.json @@ -179,7 +179,7 @@ "path": "iam-test-condition-with-ref/DefaultTest/Default", "constructInfo": { "fqn": "constructs.Construct", - "version": "10.2.69" + "version": "10.2.70" } }, "DeployAssert": { @@ -225,7 +225,7 @@ "path": "Tree", "constructInfo": { "fqn": "constructs.Construct", - "version": "10.2.69" + "version": "10.2.70" } } }, diff --git a/packages/aws-cdk-lib/core/lib/private/cfn-utils-provider/index.ts b/packages/@aws-cdk/custom-resource-handlers/lib/core/cfn-utils-provider/index.ts similarity index 78% rename from packages/aws-cdk-lib/core/lib/private/cfn-utils-provider/index.ts rename to packages/@aws-cdk/custom-resource-handlers/lib/core/cfn-utils-provider/index.ts index 3cfbd9ba583d3..02f1e66e7dc25 100644 --- a/packages/aws-cdk-lib/core/lib/private/cfn-utils-provider/index.ts +++ b/packages/@aws-cdk/custom-resource-handlers/lib/core/cfn-utils-provider/index.ts @@ -1,4 +1,17 @@ -import { CfnUtilsResourceType } from './consts'; +/** + * Supported resource type. + */ +export enum CfnUtilsResourceType { + /** + * CfnJson + */ + CFN_JSON = 'Custom::AWSCDKCfnJson', + + /** + * CfnJsonStringify + */ + CFN_JSON_STRINGIFY = 'Custom::AWSCDKCfnJsonStringify', +} /** * Parses the value of "Value" and reflects it back as attribute. diff --git a/packages/aws-cdk-lib/core/test/private/cfn-utils-provider-handler.test.ts b/packages/@aws-cdk/custom-resource-handlers/test/core/cfn-utils-provider-handler.test.ts similarity index 79% rename from packages/aws-cdk-lib/core/test/private/cfn-utils-provider-handler.test.ts rename to packages/@aws-cdk/custom-resource-handlers/test/core/cfn-utils-provider-handler.test.ts index 26beaf733001d..47f91d70ea640 100644 --- a/packages/aws-cdk-lib/core/test/private/cfn-utils-provider-handler.test.ts +++ b/packages/@aws-cdk/custom-resource-handlers/test/core/cfn-utils-provider-handler.test.ts @@ -1,5 +1,4 @@ -import { CfnUtilsResourceType } from '../../lib/private/cfn-utils-provider/consts'; -import { handler } from '../../lib/private/cfn-utils-provider/index'; +import { handler, CfnUtilsResourceType } from '../../lib/core/cfn-utils-provider/index'; test('parses value as JSON', async () => { // GIVEN @@ -67,6 +66,17 @@ test('fails if wrong resource type', async () => { await expect(() => invokeHandler(event)).rejects.toThrow(/unexpected resource type "Create"/); }); +test('resource provider simply parses json and reflects back as an attribute', async () => { + const input = { foo: 1234 }; + const response = await handler({ + ResourceType: CfnUtilsResourceType.CFN_JSON, + ResourceProperties: { + Value: JSON.stringify(input), + }, + } as any); + expect(input).toEqual(response.Data.Value); +}); + // helper function to get around TypeScript expecting a complete event object, // even though our tests only need some of the fields async function invokeHandler(event: Partial) { diff --git a/packages/aws-cdk-lib/core/lib/private/cfn-utils-provider.ts b/packages/aws-cdk-lib/core/lib/private/cfn-utils-provider.ts index 50c9f987e332c..16358347185d6 100644 --- a/packages/aws-cdk-lib/core/lib/private/cfn-utils-provider.ts +++ b/packages/aws-cdk-lib/core/lib/private/cfn-utils-provider.ts @@ -1,3 +1,4 @@ +import * as path from 'path'; import { Construct } from 'constructs'; import { CfnUtilsResourceType } from './cfn-utils-provider/consts'; import { CustomResource } from '../custom-resource'; @@ -10,7 +11,7 @@ export class CfnUtilsProvider extends Construct { public static getOrCreate(scope: Construct) { return CustomResourceProvider.getOrCreate(scope, 'AWSCDKCfnUtilsProvider', { runtime: CustomResourceProviderRuntime.NODEJS_18_X, - codeDirectory: `${__dirname}/cfn-utils-provider`, + codeDirectory: path.join(__dirname, '..', '..', '..', 'custom-resource-handlers', 'dist', 'core', 'cfn-utils-provider'), }); } } diff --git a/packages/aws-cdk-lib/core/lib/private/cfn-utils-provider/.is_custom_resource b/packages/aws-cdk-lib/core/lib/private/cfn-utils-provider/.is_custom_resource deleted file mode 100644 index e69de29bb2d1d..0000000000000 diff --git a/packages/aws-cdk-lib/core/lib/private/cfn-utils-provider/consts.ts b/packages/aws-cdk-lib/core/lib/private/cfn-utils-provider/consts.ts index 31417563a1736..a199b62aa3803 100644 --- a/packages/aws-cdk-lib/core/lib/private/cfn-utils-provider/consts.ts +++ b/packages/aws-cdk-lib/core/lib/private/cfn-utils-provider/consts.ts @@ -1,3 +1,4 @@ +// Shared definition with packages/@aws-cdk/custom-resource-handlers/lib/core/cfn-utils-provider/index.ts /** * Supported resource type. */ diff --git a/packages/aws-cdk-lib/core/test/cfn-json.test.ts b/packages/aws-cdk-lib/core/test/cfn-json.test.ts index 0a4a988957300..7885a0fbedc3c 100644 --- a/packages/aws-cdk-lib/core/test/cfn-json.test.ts +++ b/packages/aws-cdk-lib/core/test/cfn-json.test.ts @@ -1,7 +1,5 @@ import { App, CfnResource, Lazy, Stack } from '../lib'; import { CfnJson } from '../lib/cfn-json'; -import { CfnUtilsResourceType } from '../lib/private/cfn-utils-provider/consts'; -import { handler } from '../lib/private/cfn-utils-provider/index'; describe('cfn json', () => { @@ -71,15 +69,4 @@ describe('cfn json', () => { 'Fn::Join': ['', ['"{"ref=', { Ref: 'MyResource' }, '":"this is a I am lazy"}"']], }); }); - - test('resource provider simply parses json and reflects back as an attribute', async () => { - const input = { foo: 1234 }; - const response = await handler({ - ResourceType: CfnUtilsResourceType.CFN_JSON, - ResourceProperties: { - Value: JSON.stringify(input), - }, - } as any); - expect(input).toEqual(response.Data.Value); - }); });