UNPKG

aws-cdk-lib

Version:

Version 2 of the AWS Cloud Development Kit library

2 lines (1 loc) 10.8 kB
"use strict";var _a;Object.defineProperty(exports,"__esModule",{value:!0}),exports.DefaultStackSynthesizer=exports.BOOTSTRAP_QUALIFIER_CONTEXT=void 0;var jsiiDeprecationWarnings=()=>{var tmp=require("../../../.warnings.jsii.js");return jsiiDeprecationWarnings=()=>tmp,tmp};const JSII_RTTI_SYMBOL_1=Symbol.for("jsii.rtti");var _shared_1=()=>{var tmp=require("./_shared");return _shared_1=()=>tmp,tmp},asset_manifest_builder_1=()=>{var tmp=require("./asset-manifest-builder");return asset_manifest_builder_1=()=>tmp,tmp},stack_synthesizer_1=()=>{var tmp=require("./stack-synthesizer");return stack_synthesizer_1=()=>tmp,tmp},cxapi=()=>{var tmp=require("../../../cx-api");return cxapi=()=>tmp,tmp},string_specializer_1=()=>{var tmp=require("../helpers-internal/string-specializer");return string_specializer_1=()=>tmp,tmp},token_1=()=>{var tmp=require("../token");return token_1=()=>tmp,tmp};exports.BOOTSTRAP_QUALIFIER_CONTEXT="@aws-cdk/core:bootstrapQualifier";const MIN_BOOTSTRAP_STACK_VERSION=6,MIN_LOOKUP_ROLE_BOOTSTRAP_STACK_VERSION=8,MIN_SESSION_TAGS_BOOTSTRAP_STACK_VERSION=22;class DefaultStackSynthesizer extends stack_synthesizer_1().StackSynthesizer{constructor(props={}){super(),this.props=props,this.assetManifest=new(asset_manifest_builder_1()).AssetManifestBuilder;try{jsiiDeprecationWarnings().aws_cdk_lib_DefaultStackSynthesizerProps(props)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,DefaultStackSynthesizer),error}this.useLookupRoleForStackOperations=props.useLookupRoleForStackOperations??!0;for(const key in props)props.hasOwnProperty(key)&&validateNoToken(key);function validateNoToken(key){const prop=props[key];if(typeof prop=="string"&&token_1().Token.isUnresolved(prop))throw new Error(`DefaultStackSynthesizer property '${key}' cannot contain tokens; only the following placeholder strings are allowed: `+["${Qualifier}",cxapi().EnvironmentPlaceholders.CURRENT_REGION,cxapi().EnvironmentPlaceholders.CURRENT_ACCOUNT,cxapi().EnvironmentPlaceholders.CURRENT_PARTITION].join(", "))}}reusableBind(stack){try{jsiiDeprecationWarnings().aws_cdk_lib_Stack(stack)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.reusableBind),error}const copy=Object.create(this);return copy.bind(stack),copy}get bootstrapQualifier(){return this.qualifier}get lookupRole(){return this.lookupRoleArn}bind(stack){try{jsiiDeprecationWarnings().aws_cdk_lib_Stack(stack)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.bind),error}super.bind(stack);const qualifier=this.props.qualifier??stack.node.tryGetContext(exports.BOOTSTRAP_QUALIFIER_CONTEXT)??DefaultStackSynthesizer.DEFAULT_QUALIFIER;this.qualifier=qualifier;const spec=new(string_specializer_1()).StringSpecializer(stack,qualifier);this.bucketName=spec.specialize(this.props.fileAssetsBucketName??DefaultStackSynthesizer.DEFAULT_FILE_ASSETS_BUCKET_NAME),this.repositoryName=spec.specialize(this.props.imageAssetsRepositoryName??DefaultStackSynthesizer.DEFAULT_IMAGE_ASSETS_REPOSITORY_NAME),this._deployRoleArn=spec.specialize(this.props.deployRoleArn??DefaultStackSynthesizer.DEFAULT_DEPLOY_ROLE_ARN),this._cloudFormationExecutionRoleArn=spec.specialize(this.props.cloudFormationExecutionRole??DefaultStackSynthesizer.DEFAULT_CLOUDFORMATION_ROLE_ARN),this.fileAssetPublishingRoleArn=spec.specialize(this.props.fileAssetPublishingRoleArn??DefaultStackSynthesizer.DEFAULT_FILE_ASSET_PUBLISHING_ROLE_ARN),this.imageAssetPublishingRoleArn=spec.specialize(this.props.imageAssetPublishingRoleArn??DefaultStackSynthesizer.DEFAULT_IMAGE_ASSET_PUBLISHING_ROLE_ARN),this.lookupRoleArn=spec.specialize(this.props.lookupRoleArn??DefaultStackSynthesizer.DEFAULT_LOOKUP_ROLE_ARN),this.bucketPrefix=spec.specialize(this.props.bucketPrefix??DefaultStackSynthesizer.DEFAULT_FILE_ASSET_PREFIX),this.dockerTagPrefix=spec.specialize(this.props.dockerTagPrefix??DefaultStackSynthesizer.DEFAULT_DOCKER_ASSET_PREFIX),this.bootstrapStackVersionSsmParameter=spec.qualifierOnly(this.props.bootstrapStackVersionSsmParameter??DefaultStackSynthesizer.DEFAULT_BOOTSTRAP_STACK_VERSION_SSM_PARAMETER)}addFileAsset(asset){try{jsiiDeprecationWarnings().aws_cdk_lib_FileAssetSource(asset)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.addFileAsset),error}(0,_shared_1().assertBound)(this.bucketName);const location=this.assetManifest.defaultAddFileAsset(this.boundStack,asset,{bucketName:this.bucketName,bucketPrefix:this.bucketPrefix,role:this.fileAssetPublishingRoleArn?{assumeRoleArn:this.fileAssetPublishingRoleArn,assumeRoleExternalId:this.props.fileAssetPublishingExternalId,assumeRoleAdditionalOptions:this.props.fileAssetPublishingRoleAdditionalOptions}:void 0});return this.cloudFormationLocationFromFileAsset(location)}addDockerImageAsset(asset){try{jsiiDeprecationWarnings().aws_cdk_lib_DockerImageAssetSource(asset)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.addDockerImageAsset),error}(0,_shared_1().assertBound)(this.repositoryName);const location=this.assetManifest.defaultAddDockerImageAsset(this.boundStack,asset,{repositoryName:this.repositoryName,dockerTagPrefix:this.dockerTagPrefix,role:this.imageAssetPublishingRoleArn?{assumeRoleArn:this.imageAssetPublishingRoleArn,assumeRoleExternalId:this.props.imageAssetPublishingExternalId,assumeRoleAdditionalOptions:this.props.imageAssetPublishingRoleAdditionalOptions}:void 0});return this.cloudFormationLocationFromDockerImageAsset(location)}synthesizeStackTemplate(stack,session){try{jsiiDeprecationWarnings().aws_cdk_lib_Stack(stack),jsiiDeprecationWarnings().aws_cdk_lib_ISynthesisSession(session)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.synthesizeStackTemplate),error}stack._synthesizeTemplate(session,this.lookupRoleArn,this.props.lookupRoleExternalId,this.props.lookupRoleAdditionalOptions)}get stack(){try{jsiiDeprecationWarnings().print("aws-cdk-lib.DefaultStackSynthesizer#stack","Use `boundStack` instead.")}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,jsiiDeprecationWarnings().getPropertyDescriptor(this,"stack").get),error}return this.boundStack}synthesize(session){try{jsiiDeprecationWarnings().aws_cdk_lib_ISynthesisSession(session)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.synthesize),error}(0,_shared_1().assertBound)(this.qualifier),(this.props.generateBootstrapVersionRule??!0)&&this.addBootstrapVersionRule(this._requiredBootstrapVersionForDeployment,this.bootstrapStackVersionSsmParameter);const templateAssetSource=this.synthesizeTemplate(session,this.lookupRoleArn,this.props.lookupRoleExternalId,this.props.lookupRoleAdditionalOptions),templateAsset=this.addFileAsset(templateAssetSource),assetManifestId=this.assetManifest.emitManifest(this.boundStack,session,{requiresBootstrapStackVersion:this._requiredBoostrapVersionForAssets,bootstrapStackVersionSsmParameter:this.bootstrapStackVersionSsmParameter});this.emitArtifact(session,{assumeRoleExternalId:this.props.deployRoleExternalId,assumeRoleArn:this._deployRoleArn,assumeRoleAdditionalOptions:this.props.deployRoleAdditionalOptions,cloudFormationExecutionRoleArn:this._cloudFormationExecutionRoleArn,stackTemplateAssetObjectUrl:templateAsset.s3ObjectUrlWithPlaceholders,requiresBootstrapStackVersion:this._requiredBootstrapVersionForDeployment,bootstrapStackVersionSsmParameter:this.bootstrapStackVersionSsmParameter,additionalDependencies:[assetManifestId],lookupRole:this.useLookupRoleForStackOperations&&this.lookupRoleArn?{arn:this.lookupRoleArn,assumeRoleExternalId:this.props.lookupRoleExternalId,assumeRoleAdditionalOptions:this.props.lookupRoleAdditionalOptions,requiresBootstrapStackVersion:this._requiredBootstrapVersionForLookup,bootstrapStackVersionSsmParameter:this.bootstrapStackVersionSsmParameter}:void 0})}get _requiredBoostrapVersionForAssets(){return this.props.fileAssetPublishingRoleAdditionalOptions?.Tags||this.props.imageAssetPublishingRoleAdditionalOptions?.Tags?MIN_SESSION_TAGS_BOOTSTRAP_STACK_VERSION:MIN_BOOTSTRAP_STACK_VERSION}get _requiredBootstrapVersionForDeployment(){return this.props.deployRoleAdditionalOptions?.Tags?MIN_SESSION_TAGS_BOOTSTRAP_STACK_VERSION:MIN_BOOTSTRAP_STACK_VERSION}get _requiredBootstrapVersionForLookup(){return this.props.lookupRoleAdditionalOptions?.Tags?MIN_SESSION_TAGS_BOOTSTRAP_STACK_VERSION:MIN_LOOKUP_ROLE_BOOTSTRAP_STACK_VERSION}get deployRoleArn(){if(!this._deployRoleArn)throw new Error("deployRoleArn getter can only be called after the synthesizer has been bound to a Stack");return this._deployRoleArn}get cloudFormationExecutionRoleArn(){if(!this._cloudFormationExecutionRoleArn)throw new Error("cloudFormationExecutionRoleArn getter can only be called after the synthesizer has been bound to a Stack");return this._cloudFormationExecutionRoleArn}}exports.DefaultStackSynthesizer=DefaultStackSynthesizer,_a=JSII_RTTI_SYMBOL_1,DefaultStackSynthesizer[_a]={fqn:"aws-cdk-lib.DefaultStackSynthesizer",version:"2.185.0"},DefaultStackSynthesizer.DEFAULT_QUALIFIER="hnb659fds",DefaultStackSynthesizer.DEFAULT_CLOUDFORMATION_ROLE_ARN="arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-${Qualifier}-cfn-exec-role-${AWS::AccountId}-${AWS::Region}",DefaultStackSynthesizer.DEFAULT_DEPLOY_ROLE_ARN="arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-${Qualifier}-deploy-role-${AWS::AccountId}-${AWS::Region}",DefaultStackSynthesizer.DEFAULT_FILE_ASSET_PUBLISHING_ROLE_ARN="arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-${Qualifier}-file-publishing-role-${AWS::AccountId}-${AWS::Region}",DefaultStackSynthesizer.DEFAULT_IMAGE_ASSET_PUBLISHING_ROLE_ARN="arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-${Qualifier}-image-publishing-role-${AWS::AccountId}-${AWS::Region}",DefaultStackSynthesizer.DEFAULT_LOOKUP_ROLE_ARN="arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-${Qualifier}-lookup-role-${AWS::AccountId}-${AWS::Region}",DefaultStackSynthesizer.DEFAULT_IMAGE_ASSETS_REPOSITORY_NAME="cdk-${Qualifier}-container-assets-${AWS::AccountId}-${AWS::Region}",DefaultStackSynthesizer.DEFAULT_FILE_ASSETS_BUCKET_NAME="cdk-${Qualifier}-assets-${AWS::AccountId}-${AWS::Region}",DefaultStackSynthesizer.DEFAULT_FILE_ASSET_KEY_ARN_EXPORT_NAME="CdkBootstrap-${Qualifier}-FileAssetKeyArn",DefaultStackSynthesizer.DEFAULT_FILE_ASSET_PREFIX="",DefaultStackSynthesizer.DEFAULT_DOCKER_ASSET_PREFIX="",DefaultStackSynthesizer.DEFAULT_BOOTSTRAP_STACK_VERSION_SSM_PARAMETER="/cdk-bootstrap/${Qualifier}/version";