UNPKG

aws-cdk-lib

Version:

Version 2 of the AWS Cloud Development Kit library

2 lines (1 loc) 5.48 kB
"use strict";var __esDecorate=exports&&exports.__esDecorate||function(ctor,descriptorIn,decorators,contextIn,initializers,extraInitializers){function accept(f){if(f!==void 0&&typeof f!="function")throw new TypeError("Function expected");return f}for(var kind=contextIn.kind,key=kind==="getter"?"get":kind==="setter"?"set":"value",target=!descriptorIn&&ctor?contextIn.static?ctor:ctor.prototype:null,descriptor=descriptorIn||(target?Object.getOwnPropertyDescriptor(target,contextIn.name):{}),_,done=!1,i=decorators.length-1;i>=0;i--){var context={};for(var p in contextIn)context[p]=p==="access"?{}:contextIn[p];for(var p in contextIn.access)context.access[p]=contextIn.access[p];context.addInitializer=function(f){if(done)throw new TypeError("Cannot add initializers after decoration has completed");extraInitializers.push(accept(f||null))};var result=(0,decorators[i])(kind==="accessor"?{get:descriptor.get,set:descriptor.set}:descriptor[key],context);if(kind==="accessor"){if(result===void 0)continue;if(result===null||typeof result!="object")throw new TypeError("Object expected");(_=accept(result.get))&&(descriptor.get=_),(_=accept(result.set))&&(descriptor.set=_),(_=accept(result.init))&&initializers.unshift(_)}else(_=accept(result))&&(kind==="field"?initializers.unshift(_):descriptor[key]=_)}target&&Object.defineProperty(target,contextIn.name,descriptor),done=!0},__runInitializers=exports&&exports.__runInitializers||function(thisArg,initializers,value){for(var useValue=arguments.length>2,i=0;i<initializers.length;i++)value=useValue?initializers[i].call(thisArg,value):initializers[i].call(thisArg);return useValue?value:void 0};Object.defineProperty(exports,"__esModule",{value:!0}),exports.CrossRegionSupportStack=exports.CrossRegionSupportConstruct=void 0;var constructs_1=()=>{var tmp=require("constructs");return constructs_1=()=>tmp,tmp},kms=()=>{var tmp=require("../../../aws-kms");return kms=()=>tmp,tmp},s3=()=>{var tmp=require("../../../aws-s3");return s3=()=>tmp,tmp},cdk=()=>{var tmp=require("../../../core");return cdk=()=>tmp,tmp},unique_resource_name_1=()=>{var tmp=require("../../../core/lib/private/unique-resource-name");return unique_resource_name_1=()=>tmp,tmp},prop_injectable_1=()=>{var tmp=require("../../../core/lib/prop-injectable");return prop_injectable_1=()=>tmp,tmp};const REQUIRED_ALIAS_PREFIX="alias/";let AliasWithShorterGeneratedName=(()=>{let _classDecorators=[prop_injectable_1().propertyInjectable],_classDescriptor,_classExtraInitializers=[],_classThis,_classSuper=kms().Alias;var AliasWithShorterGeneratedName2=class extends _classSuper{static{_classThis=this}static{const _metadata=typeof Symbol=="function"&&Symbol.metadata?Object.create(_classSuper[Symbol.metadata]??null):void 0;__esDecorate(null,_classDescriptor={value:_classThis},_classDecorators,{kind:"class",name:_classThis.name,metadata:_metadata},null,_classExtraInitializers),AliasWithShorterGeneratedName2=_classThis=_classDescriptor.value,_metadata&&Object.defineProperty(_classThis,Symbol.metadata,{enumerable:!0,configurable:!0,writable:!0,value:_metadata})}static PROPERTY_INJECTION_ID="aws-cdk-lib.aws-codepipeline.AliasWithShorterGeneratedName";generatePhysicalName(){let baseName=super.generatePhysicalName();baseName.startsWith(REQUIRED_ALIAS_PREFIX)&&(baseName=baseName.substring(REQUIRED_ALIAS_PREFIX.length));const maxLength=50-REQUIRED_ALIAS_PREFIX.length;return REQUIRED_ALIAS_PREFIX+lastNCharacters(baseName,maxLength)}static{__runInitializers(_classThis,_classExtraInitializers)}};return AliasWithShorterGeneratedName2=_classThis})();function lastNCharacters(str,n){const startIndex=Math.max(str.length-n,0);return str.substring(startIndex)}class CrossRegionSupportConstruct extends constructs_1().Construct{replicationBucket;constructor(scope,id,props={}){super(scope,id);const createKmsKey=props.createKmsKey??!0;let encryptionAlias;if(createKmsKey){const encryptionKey=new(kms()).Key(this,"CrossRegionCodePipelineReplicationBucketEncryptionKey",{removalPolicy:cdk().RemovalPolicy.DESTROY,enableKeyRotation:props.enableKeyRotation});encryptionAlias=new AliasWithShorterGeneratedName(this,"CrossRegionCodePipelineReplicationBucketEncryptionAlias",{targetKey:encryptionKey,aliasName:cdk().PhysicalName.GENERATE_IF_NEEDED,removalPolicy:cdk().RemovalPolicy.DESTROY})}this.replicationBucket=new(s3()).Bucket(this,"CrossRegionCodePipelineReplicationBucket",{bucketName:cdk().PhysicalName.GENERATE_IF_NEEDED,encryption:encryptionAlias?s3().BucketEncryption.KMS:s3().BucketEncryption.KMS_MANAGED,encryptionKey:encryptionAlias,enforceSSL:!0,blockPublicAccess:s3().BlockPublicAccess.BLOCK_ALL})}}exports.CrossRegionSupportConstruct=CrossRegionSupportConstruct;class CrossRegionSupportStack extends cdk().Stack{replicationBucket;constructor(scope,id,props){super(scope,id,{stackName:generateStackName(props),env:{region:props.region,account:props.account},synthesizer:props.synthesizer});const crossRegionSupportConstruct=new CrossRegionSupportConstruct(this,"Default",{createKmsKey:props.createKmsKey,enableKeyRotation:props.enableKeyRotation});this.replicationBucket=crossRegionSupportConstruct.replicationBucket}}exports.CrossRegionSupportStack=CrossRegionSupportStack;function generateStackName(props){return cdk().Token.isUnresolved(props.pipelineStackName)?(0,unique_resource_name_1().makeUniqueResourceName)([`cross-region-support-${props.region}`],{maxLength:128,allowedSpecialCharacters:"-"}):`${props.pipelineStackName}-support-${props.region}`}