diff --git a/packages/aws-cdk/lib/api/evaluate-cloudformation-template.ts b/packages/aws-cdk/lib/api/evaluate-cloudformation-template.ts index b3595a9fcbe56..67517804fa627 100644 --- a/packages/aws-cdk/lib/api/evaluate-cloudformation-template.ts +++ b/packages/aws-cdk/lib/api/evaluate-cloudformation-template.ts @@ -103,7 +103,6 @@ export interface EvaluateCloudFormationTemplateProps { readonly urlSuffix: (region: string) => string; readonly sdk: ISDK; readonly nestedStackNames?: { [nestedStackLogicalId: string]: NestedStackNames }; - readonly lookupExport: LookupExport; } export class EvaluateCloudFormationTemplate { @@ -123,7 +122,6 @@ export class EvaluateCloudFormationTemplate { constructor(props: EvaluateCloudFormationTemplateProps) { this.stackName = props.stackName; - this.lookupExport = props.lookupExport; this.template = props.template; this.context = { 'AWS::AccountId': props.account, @@ -144,6 +142,9 @@ export class EvaluateCloudFormationTemplate { // We need them to figure out the physical name of a resource in case it wasn't specified by the user. // We fetch it lazily, to save a service call, in case all hotswapped resources have their physical names set. this.stackResources = new LazyListStackResources(this.sdk, this.stackName); + + // CloudFormation Exports lookup to be able to resolve Fn::ImportValue intrinsics in template + this.lookupExport = new LazyLookupExport(this.sdk); } // clones current EvaluateCloudFormationTemplate object, but updates the stack name @@ -163,7 +164,6 @@ export class EvaluateCloudFormationTemplate { urlSuffix: this.urlSuffix, sdk: this.sdk, nestedStackNames: this.nestedStackNames, - lookupExport: this.lookupExport, }); } diff --git a/packages/aws-cdk/lib/api/hotswap-deployments.ts b/packages/aws-cdk/lib/api/hotswap-deployments.ts index 8dc177aabdc88..eb1641a5b2dce 100644 --- a/packages/aws-cdk/lib/api/hotswap-deployments.ts +++ b/packages/aws-cdk/lib/api/hotswap-deployments.ts @@ -59,8 +59,6 @@ export async function tryHotswapDeployment( const currentTemplate = await loadCurrentTemplateWithNestedStacks(stackArtifact, sdk); - // CloudFormation Exports lookup to be able to resolve Fn::ImportValue intrinsics in template - const lookupExport = new LazyLookupExport(sdk); const evaluateCfnTemplate = new EvaluateCloudFormationTemplate({ stackName: stackArtifact.stackName, template: stackArtifact.template, @@ -71,7 +69,6 @@ export async function tryHotswapDeployment( urlSuffix: (region) => sdk.getEndpointSuffix(region), sdk, nestedStackNames: currentTemplate.nestedStackNames, - lookupExport, }); const stackChanges = cfn_diff.diffTemplate(currentTemplate.deployedTemplate, stackArtifact.template); diff --git a/packages/aws-cdk/lib/api/logs/find-cloudwatch-logs.ts b/packages/aws-cdk/lib/api/logs/find-cloudwatch-logs.ts index 911cbc4cd543b..bcee908dcc746 100644 --- a/packages/aws-cdk/lib/api/logs/find-cloudwatch-logs.ts +++ b/packages/aws-cdk/lib/api/logs/find-cloudwatch-logs.ts @@ -2,7 +2,7 @@ import * as cxapi from '@aws-cdk/cx-api'; import { CloudFormation } from 'aws-sdk'; import { Mode, SdkProvider, ISDK } from '../aws-auth'; import { Deployments } from '../deployments'; -import { EvaluateCloudFormationTemplate, LazyListStackResources, LazyLookupExport } from '../evaluate-cloudformation-template'; +import { EvaluateCloudFormationTemplate, LazyListStackResources } from '../evaluate-cloudformation-template'; // resource types that have associated CloudWatch Log Groups that should _not_ be monitored const IGNORE_LOGS_RESOURCE_TYPES = ['AWS::EC2::FlowLog', 'AWS::CloudTrail::Trail', 'AWS::CodeBuild::Project']; @@ -55,7 +55,6 @@ export async function findCloudWatchLogGroups( } const listStackResources = new LazyListStackResources(sdk, stackArtifact.stackName); - const lookupExport = new LazyLookupExport(sdk); const evaluateCfnTemplate = new EvaluateCloudFormationTemplate({ stackName: stackArtifact.stackName, template: stackArtifact.template, @@ -65,7 +64,6 @@ export async function findCloudWatchLogGroups( partition: (await sdk.currentAccount()).partition, urlSuffix: (region) => sdk.getEndpointSuffix(region), sdk, - lookupExport, }); const stackResources = await listStackResources.listStackResources(); diff --git a/packages/aws-cdk/test/api/evaluate-cloudformation-template.test.ts b/packages/aws-cdk/test/api/evaluate-cloudformation-template.test.ts index 599d28859a6ce..4a571838820a2 100644 --- a/packages/aws-cdk/test/api/evaluate-cloudformation-template.test.ts +++ b/packages/aws-cdk/test/api/evaluate-cloudformation-template.test.ts @@ -1,8 +1,6 @@ import { CfnEvaluationException, EvaluateCloudFormationTemplate, - LazyListStackResources, - LazyLookupExport, Template, } from '../../lib/api/evaluate-cloudformation-template'; import { MockSdk } from '../util/mock-sdk'; @@ -22,8 +20,8 @@ const createEvaluateCloudFormationTemplate = (template: Template) => new Evaluat region: 'ap-south-east-2', partition: 'aws', urlSuffix: (region) => sdk.getEndpointSuffix(region), - listStackResources: new LazyListStackResources(sdk, 'test-stack'), - lookupExport: new LazyLookupExport(sdk), + sdk, + stackName: 'test-stack', }); describe('evaluateCfnExpression', () => {