Files
agent-claw/cdk/node_modules/aws-cdk-lib/aws-kinesisfirehose/lib/s3-bucket.js
2026-05-06 18:55:16 -05:00

2 lines
6.7 KiB
JavaScript

"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},literal_string_1=()=>{var tmp=require("../../core/lib/private/literal-string");return literal_string_1=()=>tmp,tmp};class S3Bucket{bucket;props;static[JSII_RTTI_SYMBOL_1]={fqn:"aws-cdk-lib.aws_kinesisfirehose.S3Bucket",version:"2.252.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((0,literal_string_1().lit)`S3BackupModeFailedNotSupported`,"S3 destinations do not support BackupMode.FAILED");if(this.props.dataFormatConversion&&this.props.compression)throw new(cdk()).UnscopedValidationError((0,literal_string_1().lit)`DataFormatConversionCompressionConflict`,"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");if(validateOutputPrefix(this.props.dataOutputPrefix,this.props.errorOutputPrefix),!this.props.dynamicPartitioning?.enabled&&(this.props.dataOutputPrefix?.includes(`!{${helpers_1().PARTITION_KEY_LAMBDA}:`)||this.props.dataOutputPrefix?.includes(`!{${helpers_1().PARTITION_KEY_QUERY}:`)))throw new(cdk()).UnscopedValidationError((0,literal_string_1().lit)`DynamicPartitioningNamespaceWithoutEnabled`,`When dynamic partitioning is not enabled, the dataOutputPrefix cannot contain neither ${helpers_1().PARTITION_KEY_LAMBDA} nor ${helpers_1().PARTITION_KEY_QUERY}.`)}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"})??{},{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((0,literal_string_1().lit)`FileExtensionMustStartWithPeriod`,"fileExtension must start with '.'",scope);if(/[^0-9a-z!\-_.*'()]/.test(fileExtension))throw new(cdk()).ValidationError((0,literal_string_1().lit)`FileExtensionInvalidCharacters`,"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,this.props,{role,dynamicPartitioningEnabled:this.props.dynamicPartitioning?.enabled,prefix:this.props.dataOutputPrefix}),roleArn:role.roleArn,s3BackupConfiguration:backupConfig,s3BackupMode:this.getS3BackupMode(),bufferingHints:(0,helpers_1().createBufferingHints)(scope,this.props.bufferingInterval,this.props.bufferingSize,dataFormatConversionConfiguration?.enabled,this.props.dynamicPartitioning?.enabled),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,dynamicPartitioningConfiguration:(0,helpers_1().createDynamicPartitioningConfiguration)(scope,this.props.dynamicPartitioning)},dependables:[bucketGrant,...loggingDependables??[],...backupDependables??[]]}}getS3BackupMode(){return this.props.s3Backup?.bucket||this.props.s3Backup?.mode===common_1().BackupMode.ALL?"Enabled":void 0}}exports.S3Bucket=S3Bucket;function validateOutputPrefix(prefix,errorOutputPrefix){if(prefix&&validateOutputPrefixExpression(prefix,"dataOutputPrefix"),errorOutputPrefix&&validateOutputPrefixExpression(errorOutputPrefix,"errorOutputPrefix"),prefix?.includes("!{")&&!errorOutputPrefix)throw new(cdk()).UnscopedValidationError((0,literal_string_1().lit)`ErrorOutputPrefixRequiredWithExpressions`,"Specify the errorOutputPrefix in order to use expressions in the dataOutputPrefix.");if(errorOutputPrefix?.includes("!{")&&!errorOutputPrefix.includes(helpers_1().ERROR_OUTPUT_TYPE))throw new(cdk()).UnscopedValidationError((0,literal_string_1().lit)`ErrorOutputPrefixMustIncludeErrorOutputType`,`The errorOutputPrefix expression must include at least one instance of ${helpers_1().ERROR_OUTPUT_TYPE}.`);if(prefix?.includes(helpers_1().ERROR_OUTPUT_TYPE))throw new(cdk()).UnscopedValidationError((0,literal_string_1().lit)`DataOutputPrefixCannotContainErrorOutputType`,`The dataOutputPrefix cannot contain ${helpers_1().ERROR_OUTPUT_TYPE}.`);if(errorOutputPrefix?.includes(`!{${helpers_1().PARTITION_KEY_LAMBDA}:`)||errorOutputPrefix?.includes(`!{${helpers_1().PARTITION_KEY_QUERY}:`))throw new(cdk()).UnscopedValidationError((0,literal_string_1().lit)`ErrorOutputPrefixCannotUsePartitionKeyNamespaces`,`You cannot use ${helpers_1().PARTITION_KEY_LAMBDA} and ${helpers_1().PARTITION_KEY_QUERY} namespaces in errorOutputPreix.`)}function validateOutputPrefixExpression(prefix,prop){if(/!\{(?!(?:firehose|timestamp|partitionKeyFrom(?:Lambda|Query)):[^{}]+\})/.test(prefix))throw new(cdk()).UnscopedValidationError((0,literal_string_1().lit)`InvalidExpressionFormat`,`The expression must be of the form !{namespace:value} and include a valid namespace at ${prop}.`)}