diff --git a/packages/pulumi/package.json b/packages/pulumi/package.json index 49c1450c215..e4d89316f65 100644 --- a/packages/pulumi/package.json +++ b/packages/pulumi/package.json @@ -15,7 +15,8 @@ }, "dependencies": { "@pulumi/pulumi": "^3.34.0", - "find-up": "^5.0.0" + "find-up": "^5.0.0", + "lodash": "^4.17.21" }, "devDependencies": { "@babel/cli": "^7.22.6", diff --git a/packages/pulumi/src/PulumiAppResource.ts b/packages/pulumi/src/PulumiAppResource.ts index 9dea95304d4..fc3d6e7af24 100644 --- a/packages/pulumi/src/PulumiAppResource.ts +++ b/packages/pulumi/src/PulumiAppResource.ts @@ -28,6 +28,8 @@ export interface PulumiAppResourceConfigSetter { export type PulumiAppResourceConfigProxy = { readonly [K in keyof T]-?: PulumiAppResourceConfigSetter; +} & { + clone(): T; }; export interface PulumiAppResource { diff --git a/packages/pulumi/src/createPulumiApp.ts b/packages/pulumi/src/createPulumiApp.ts index c2b1e591795..e5777b0b6f6 100644 --- a/packages/pulumi/src/createPulumiApp.ts +++ b/packages/pulumi/src/createPulumiApp.ts @@ -20,6 +20,7 @@ import { ResourceHandler } from "~/types"; import { PulumiAppRemoteResource } from "~/PulumiAppRemoteResource"; +import cloneDeep from "lodash/cloneDeep"; export function createPulumiApp>( params: CreatePulumiAppParams @@ -219,6 +220,10 @@ export function createPulumiApp>( function createPulumiAppResourceConfigProxy(obj: T) { return new Proxy(obj, { get(target, p: string) { + if (p === "clone") { + return () => cloneDeep(obj); + } + type V = T[keyof T]; const key = p as keyof T; const setter: PulumiAppResourceConfigSetter = ( diff --git a/yarn.lock b/yarn.lock index 3ff04355859..b11b79f071a 100644 --- a/yarn.lock +++ b/yarn.lock @@ -16506,6 +16506,7 @@ __metadata: "@webiny/cli": 0.0.0 "@webiny/project-utils": 0.0.0 find-up: ^5.0.0 + lodash: ^4.17.21 rimraf: ^3.0.2 typescript: 4.7.4 languageName: unknown