UNPKG

aws-cdk-lib

Version:

Version 2 of the AWS Cloud Development Kit library

2 lines (1 loc) 4.17 kB
"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),exports.S3Bucket=void 0;var jsiiDeprecationWarnings=()=>{var tmp=require("../../.warnings.jsii.js");return jsiiDeprecationWarnings=()=>tmp,tmp};const JSII_RTTI_SYMBOL_1=Symbol.for("jsii.rtti");var common_1=()=>{var tmp=require("./common");return common_1=()=>tmp,tmp},iam=()=>{var tmp=require("../../aws-iam");return iam=()=>tmp,tmp},helpers_1=()=>{var tmp=require("./private/helpers");return helpers_1=()=>tmp,tmp},cdk=()=>{var tmp=require("../../core");return cdk=()=>tmp,tmp};class S3Bucket{bucket;props;static[JSII_RTTI_SYMBOL_1]={fqn:"aws-cdk-lib.aws_kinesisfirehose.S3Bucket",version:"2.233.0"};constructor(bucket,props={}){this.bucket=bucket,this.props=props;try{jsiiDeprecationWarnings().aws_cdk_lib_aws_s3_IBucket(bucket),jsiiDeprecationWarnings().aws_cdk_lib_aws_kinesisfirehose_S3BucketProps(props)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,S3Bucket),error}if(this.props.s3Backup?.mode===common_1().BackupMode.FAILED)throw new(cdk()).UnscopedValidationError("S3 destinations do not support BackupMode.FAILED");if(this.props.dataFormatConversion&&this.props.compression)throw new(cdk()).UnscopedValidationError("When data record format conversion is enabled, compression cannot be set on the S3 Destination. Compression may only be set in the OutputFormat. By default, this compression is SNAPPY")}bind(scope,_options){try{jsiiDeprecationWarnings().aws_cdk_lib_aws_kinesisfirehose_DestinationBindOptions(_options)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.bind),error}const role=this.props.role??new(iam()).Role(scope,"S3 Destination Role",{assumedBy:new(iam()).ServicePrincipal("firehose.amazonaws.com")}),bucketGrant=this.bucket.grantReadWrite(role),{loggingOptions,dependables:loggingDependables}=(0,helpers_1().createLoggingOptions)(scope,{loggingConfig:this.props.loggingConfig,role,streamId:"S3Destination"})??{};if(this.props.processor&&this.props.processors)throw new(cdk()).ValidationError("You can specify either 'processors' or 'processor', not both.",scope);const dataProcessors=this.props.processor?[this.props.processor]:this.props.processors,{backupConfig,dependables:backupDependables}=(0,helpers_1().createBackupConfig)(scope,role,this.props.s3Backup)??{},fileExtension=this.props.fileExtension;if(fileExtension&&!cdk().Token.isUnresolved(fileExtension)){if(!fileExtension.startsWith("."))throw new(cdk()).ValidationError("fileExtension must start with '.'",scope);if(/[^0-9a-z!\-_.*'()]/.test(fileExtension))throw new(cdk()).ValidationError("fileExtension can contain allowed characters: 0-9a-z!-_.*'()",scope)}const dataFormatConfig=this.props.dataFormatConversion,dataFormatConversionConfiguration=dataFormatConfig?{enabled:dataFormatConfig.enabled??!0,schemaConfiguration:dataFormatConfig.schemaConfiguration.bind(scope,{role}),inputFormatConfiguration:dataFormatConfig.inputFormat.createInputFormatConfig(),outputFormatConfiguration:dataFormatConfig.outputFormat.createOutputFormatConfig()}:void 0;return{extendedS3DestinationConfiguration:{cloudWatchLoggingOptions:loggingOptions,processingConfiguration:(0,helpers_1().createProcessingConfig)(scope,role,dataProcessors),roleArn:role.roleArn,s3BackupConfiguration:backupConfig,s3BackupMode:this.getS3BackupMode(),bufferingHints:(0,helpers_1().createBufferingHints)(scope,this.props.bufferingInterval,this.props.bufferingSize,dataFormatConversionConfiguration),bucketArn:this.bucket.bucketArn,dataFormatConversionConfiguration,compressionFormat:this.props.compression?.value,encryptionConfiguration:(0,helpers_1().createEncryptionConfig)(role,this.props.encryptionKey),errorOutputPrefix:this.props.errorOutputPrefix,prefix:this.props.dataOutputPrefix,fileExtension:this.props.fileExtension,customTimeZone:this.props.timeZone?.timezoneName},dependables:[bucketGrant,...loggingDependables??[],...backupDependables??[]]}}getS3BackupMode(){return this.props.s3Backup?.bucket||this.props.s3Backup?.mode===common_1().BackupMode.ALL?"Enabled":void 0}}exports.S3Bucket=S3Bucket;