@@ -12,7 +12,7 @@ import { deployStack, DeployStackResult, destroyStack, DeploymentMethod } from '
12
12
import { EnvironmentResources , EnvironmentResourcesRegistry } from './environment-resources' ;
13
13
import { HotswapMode } from './hotswap/common' ;
14
14
import { loadCurrentTemplateWithNestedStacks , loadCurrentTemplate , RootTemplateWithNestedStacks } from './nested-stack-helpers' ;
15
- import { CloudFormationStack , Template , ResourcesToImport , ResourceIdentifierSummaries , stabilizeStack } from './util/cloudformation' ;
15
+ import { CloudFormationStack , Template , ResourcesToImport , ResourceIdentifierSummaries , stabilizeStack , uploadStackTemplateAssets } from './util/cloudformation' ;
16
16
import { StackActivityMonitor , StackActivityProgress } from './util/cloudformation/stack-activity-monitor' ;
17
17
import { StackEventPoller } from './util/cloudformation/stack-event-poller' ;
18
18
import { RollbackChoice } from './util/cloudformation/stack-status' ;
@@ -292,13 +292,6 @@ interface AssetOptions {
292
292
*/
293
293
readonly stack : cxapi . CloudFormationStackArtifact ;
294
294
295
- /**
296
- * Name of the toolkit stack, if not the default name.
297
- *
298
- * @default 'CDKToolkit'
299
- */
300
- readonly toolkitStackName ?: string ;
301
-
302
295
/**
303
296
* Execution role for the building.
304
297
*
@@ -426,14 +419,29 @@ export class Deployments {
426
419
const { stackSdk, resolvedEnvironment, envResources } = await this . prepareSdkFor ( stackArtifact , undefined , Mode . ForReading ) ;
427
420
const cfn = stackSdk . cloudFormation ( ) ;
428
421
422
+ await uploadStackTemplateAssets ( stackArtifact , this ) ;
423
+
429
424
// Upload the template, if necessary, before passing it to CFN
425
+ const builder = new AssetManifestBuilder ( ) ;
430
426
const cfnParam = await makeBodyParameter (
431
427
stackArtifact ,
432
428
resolvedEnvironment ,
433
- new AssetManifestBuilder ( ) ,
429
+ builder ,
434
430
envResources ,
435
431
stackSdk ) ;
436
432
433
+ // If the `makeBodyParameter` before this added assets, make sure to publish them before
434
+ // calling the API.
435
+ const addedAssets = builder . toManifest ( stackArtifact . assembly . directory ) ;
436
+ for ( const entry of addedAssets . entries ) {
437
+ await this . buildSingleAsset ( 'no-version-validation' , addedAssets , entry , {
438
+ stack : stackArtifact ,
439
+ } ) ;
440
+ await this . publishSingleAsset ( addedAssets , entry , {
441
+ stack : stackArtifact ,
442
+ } ) ;
443
+ }
444
+
437
445
const response = await cfn . getTemplateSummary ( cfnParam ) . promise ( ) ;
438
446
if ( ! response . ResourceIdentifierSummaries ) {
439
447
debug ( 'GetTemplateSummary API call did not return "ResourceIdentifierSummaries"' ) ;
@@ -805,16 +813,22 @@ export class Deployments {
805
813
806
814
/**
807
815
* Build a single asset from an asset manifest
816
+ *
817
+ * If an assert manifest artifact is given, the bootstrap stack version
818
+ * will be validated according to the constraints in that manifest artifact.
819
+ * If that is not necessary, `'no-version-validation'` can be passed.
808
820
*/
809
821
// eslint-disable-next-line max-len
810
- public async buildSingleAsset ( assetArtifact : cxapi . AssetManifestArtifact , assetManifest : AssetManifest , asset : IManifestEntry , options : BuildStackAssetsOptions ) {
822
+ public async buildSingleAsset ( assetArtifact : cxapi . AssetManifestArtifact | 'no-version-validation' , assetManifest : AssetManifest , asset : IManifestEntry , options : BuildStackAssetsOptions ) {
811
823
const { resolvedEnvironment, envResources } = await this . prepareSdkFor ( options . stack , options . roleArn , Mode . ForWriting ) ;
812
824
813
- await this . validateBootstrapStackVersion (
814
- options . stack . stackName ,
815
- assetArtifact . requiresBootstrapStackVersion ,
816
- assetArtifact . bootstrapStackVersionSsmParameter ,
817
- envResources ) ;
825
+ if ( assetArtifact !== 'no-version-validation' ) {
826
+ await this . validateBootstrapStackVersion (
827
+ options . stack . stackName ,
828
+ assetArtifact . requiresBootstrapStackVersion ,
829
+ assetArtifact . bootstrapStackVersionSsmParameter ,
830
+ envResources ) ;
831
+ }
818
832
819
833
const publisher = this . cachedPublisher ( assetManifest , resolvedEnvironment , options . stackName ) ;
820
834
await publisher . buildEntry ( asset ) ;
0 commit comments