UNPKG

aws-cdk-lib

Version:

Version 2 of the AWS Cloud Development Kit library

2 lines (1 loc) 1.99 kB
"use strict";var _a;Object.defineProperty(exports,"__esModule",{value:!0}),exports.ProductStack=void 0;const jsiiDeprecationWarnings=require("../../.warnings.jsii.js"),JSII_RTTI_SYMBOL_1=Symbol.for("jsii.rtti"),crypto=require("crypto"),fs=require("fs"),path=require("path"),cdk=require("../../core"),product_stack_synthesizer_1=require("./private/product-stack-synthesizer");class ProductStack extends cdk.Stack{constructor(scope,id,props={}){super(scope,id,{synthesizer:new product_stack_synthesizer_1.ProductStackSynthesizer(props.assetBucket)});try{jsiiDeprecationWarnings.aws_cdk_lib_aws_servicecatalog_ProductStackProps(props)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,ProductStack),error}this._parentStack=findParentStack(scope),this.templateFile=`${cdk.Names.uniqueId(this)}.product.template.json`,this.assetBucket=props.assetBucket}_setParentProductStackHistory(parentProductStackHistory){return this._parentProductStackHistory=parentProductStackHistory}_getTemplateUrl(){return cdk.Lazy.uncachedString({produce:()=>this._templateUrl})}_getAssetBucket(){return this.assetBucket}_getParentStack(){return this._parentStack}_synthesizeTemplate(session){const cfn=JSON.stringify(this._toCloudFormation(),void 0,2),templateHash=crypto.createHash("sha256").update(cfn).digest("hex");this._templateUrl=this._parentStack.synthesizer.addFileAsset({packaging:cdk.FileAssetPackaging.FILE,sourceHash:templateHash,fileName:this.templateFile}).httpUrl,this._parentProductStackHistory&&this._parentProductStackHistory._writeTemplateToSnapshot(cfn),fs.writeFileSync(path.join(session.assembly.outdir,this.templateFile),cfn)}}exports.ProductStack=ProductStack,_a=JSII_RTTI_SYMBOL_1,ProductStack[_a]={fqn:"aws-cdk-lib.aws_servicecatalog.ProductStack",version:"2.70.0"};function findParentStack(scope){try{return cdk.Stack.of(scope)}catch{throw new Error("Product stacks must be defined within scope of another non-product stack")}}