Skip to content

Commit

Permalink
fix: 'Need to perform AWS calls for account' when doing cross-account…
Browse files Browse the repository at this point in the history
… 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*
  • Loading branch information
rix0rrr authored Oct 22, 2024
1 parent f1e2f3b commit 595a422
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions packages/aws-cdk/lib/api/deployments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -812,7 +812,7 @@ export class Deployments {
const { manifest, stackEnv } = await this.prepareAndValidateAssets(asset, options);
await publishAssets(manifest, this.sdkProvider, stackEnv, {
...options.publishOptions,
allowCrossAccount: await this.allowCrossAccountAssetPublishingForEnv(stackEnv),
allowCrossAccount: await this.allowCrossAccountAssetPublishingForEnv(options.stack),
});
}

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

private async allowCrossAccountAssetPublishingForEnv(env: cxapi.Environment): Promise<boolean> {
private async allowCrossAccountAssetPublishingForEnv(stack: cxapi.CloudFormationStackArtifact): Promise<boolean> {
if (this._allowCrossAccountAssetPublishing === undefined) {
const sdk = (await this.cachedSdkForEnvironment(env, Mode.ForReading)).sdk;
const { stackSdk: sdk } = await this.prepareSdkFor(stack, undefined, Mode.ForReading);
this._allowCrossAccountAssetPublishing = await determineAllowCrossAccountAssetPublishing(sdk, this.props.toolkitStackName);
}
return this._allowCrossAccountAssetPublishing;
Expand Down

0 comments on commit 595a422

Please sign in to comment.