Skip to content

Commit 5aa63d1

Browse files
rix0rrrmrgrain
authored andcommitted
fix: 'Need to perform AWS calls for account' when doing cross-account deployments (#31846)
Fixes #31845 Manually verified that cross-account access is possible again. Will follow up with a PR for more tests. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent ad5325a commit 5aa63d1

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

packages/aws-cdk/lib/api/deployments.ts

+4-4
Original file line numberDiff line numberDiff line change
@@ -812,7 +812,7 @@ export class Deployments {
812812
const { manifest, stackEnv } = await this.prepareAndValidateAssets(asset, options);
813813
await publishAssets(manifest, this.sdkProvider, stackEnv, {
814814
...options.publishOptions,
815-
allowCrossAccount: await this.allowCrossAccountAssetPublishingForEnv(stackEnv),
815+
allowCrossAccount: await this.allowCrossAccountAssetPublishingForEnv(options.stack),
816816
});
817817
}
818818

@@ -852,15 +852,15 @@ export class Deployments {
852852
// No need to validate anymore, we already did that during build
853853
const publisher = this.cachedPublisher(assetManifest, stackEnv, options.stackName);
854854
// eslint-disable-next-line no-console
855-
await publisher.publishEntry(asset, { allowCrossAccount: await this.allowCrossAccountAssetPublishingForEnv(stackEnv) });
855+
await publisher.publishEntry(asset, { allowCrossAccount: await this.allowCrossAccountAssetPublishingForEnv(options.stack) });
856856
if (publisher.hasFailures) {
857857
throw new Error(`Failed to publish asset ${asset.id}`);
858858
}
859859
}
860860

861-
private async allowCrossAccountAssetPublishingForEnv(env: cxapi.Environment): Promise<boolean> {
861+
private async allowCrossAccountAssetPublishingForEnv(stack: cxapi.CloudFormationStackArtifact): Promise<boolean> {
862862
if (this._allowCrossAccountAssetPublishing === undefined) {
863-
const sdk = (await this.cachedSdkForEnvironment(env, Mode.ForReading)).sdk;
863+
const { stackSdk: sdk } = await this.prepareSdkFor(stack, undefined, Mode.ForReading);
864864
this._allowCrossAccountAssetPublishing = await determineAllowCrossAccountAssetPublishing(sdk, this.props.toolkitStackName);
865865
}
866866
return this._allowCrossAccountAssetPublishing;

0 commit comments

Comments
 (0)