UNPKG

aws-cdk-lib

Version:

Version 2 of the AWS Cloud Development Kit library

3 lines (2 loc) 19.3 kB
"use strict";var __decorate=exports&&exports.__decorate||function(decorators,target,key,desc){var c=arguments.length,r=c<3?target:desc===null?desc=Object.getOwnPropertyDescriptor(target,key):desc,d;if(typeof Reflect=="object"&&typeof Reflect.decorate=="function")r=Reflect.decorate(decorators,target,key,desc);else for(var i=decorators.length-1;i>=0;i--)(d=decorators[i])&&(r=(c<3?d(r):c>3?d(target,key,r):d(target,key))||r);return c>3&&r&&Object.defineProperty(target,key,r),r},_a,_b,_c,_d,_e,_f;Object.defineProperty(exports,"__esModule",{value:!0}),exports.Transformer=exports.DataConverterProcessor=exports.JsonMutatorProcessor=exports.StringMutatorProcessor=exports.VendedLogParser=exports.ParserProcessor=exports.DataConverterType=exports.JsonMutatorType=exports.StringMutatorType=exports.VendedLogType=exports.ParserProcessorType=exports.OCSFVersion=exports.OCSFSourceType=exports.KeyValueDelimiter=exports.KeyValuePairDelimiter=exports.QuoteCharacter=exports.DelimiterCharacter=exports.DateTimeFormat=exports.TypeConverterType=void 0;var jsiiDeprecationWarnings=()=>{var tmp=require("../../.warnings.jsii.js");return jsiiDeprecationWarnings=()=>tmp,tmp};const JSII_RTTI_SYMBOL_1=Symbol.for("jsii.rtti");var _1=()=>{var tmp=require(".");return _1=()=>tmp,tmp},core_1=()=>{var tmp=require("../../core");return core_1=()=>tmp,tmp},metadata_resource_1=()=>{var tmp=require("../../core/lib/metadata-resource");return metadata_resource_1=()=>tmp,tmp},prop_injectable_1=()=>{var tmp=require("../../core/lib/prop-injectable");return prop_injectable_1=()=>tmp,tmp},TypeConverterType;(function(TypeConverterType2){TypeConverterType2.BOOLEAN="boolean",TypeConverterType2.INTEGER="integer",TypeConverterType2.DOUBLE="double",TypeConverterType2.STRING="string"})(TypeConverterType||(exports.TypeConverterType=TypeConverterType={}));var DateTimeFormat;(function(DateTimeFormat2){DateTimeFormat2.ISO_8601="yyyy-MM-dd'T'HH:mm:ss'Z'",DateTimeFormat2.UNIX_TIMESTAMP="epoch",DateTimeFormat2.CUSTOM="custom"})(DateTimeFormat||(exports.DateTimeFormat=DateTimeFormat={}));var DelimiterCharacter;(function(DelimiterCharacter2){DelimiterCharacter2.COMMA=",",DelimiterCharacter2.TAB=" ",DelimiterCharacter2.SPACE=" ",DelimiterCharacter2.SEMICOLON=";",DelimiterCharacter2.PIPE="|"})(DelimiterCharacter||(exports.DelimiterCharacter=DelimiterCharacter={}));var QuoteCharacter;(function(QuoteCharacter2){QuoteCharacter2.DOUBLE_QUOTE='"',QuoteCharacter2.SINGLE_QUOTE="'"})(QuoteCharacter||(exports.QuoteCharacter=QuoteCharacter={}));var KeyValuePairDelimiter;(function(KeyValuePairDelimiter2){KeyValuePairDelimiter2.AMPERSAND="&",KeyValuePairDelimiter2.SEMICOLON=";",KeyValuePairDelimiter2.SPACE=" ",KeyValuePairDelimiter2.NEWLINE=` `})(KeyValuePairDelimiter||(exports.KeyValuePairDelimiter=KeyValuePairDelimiter={}));var KeyValueDelimiter;(function(KeyValueDelimiter2){KeyValueDelimiter2.EQUAL="=",KeyValueDelimiter2.COLON=":"})(KeyValueDelimiter||(exports.KeyValueDelimiter=KeyValueDelimiter={}));var OCSFSourceType;(function(OCSFSourceType2){OCSFSourceType2.CLOUD_TRAIL="CloudTrail",OCSFSourceType2.ROUTE53_RESOLVER="Route53Resolver",OCSFSourceType2.VPC_FLOW="VPCFlow",OCSFSourceType2.EKS_AUDIT="EKSAudit",OCSFSourceType2.AWS_WAF="AWSWAF"})(OCSFSourceType||(exports.OCSFSourceType=OCSFSourceType={}));var OCSFVersion;(function(OCSFVersion2){OCSFVersion2.V1_1="V1.1"})(OCSFVersion||(exports.OCSFVersion=OCSFVersion={}));var ParserProcessorType;(function(ParserProcessorType2){ParserProcessorType2[ParserProcessorType2.JSON=0]="JSON",ParserProcessorType2[ParserProcessorType2.KEY_VALUE=1]="KEY_VALUE",ParserProcessorType2[ParserProcessorType2.CSV=2]="CSV",ParserProcessorType2[ParserProcessorType2.GROK=3]="GROK",ParserProcessorType2[ParserProcessorType2.OCSF=4]="OCSF"})(ParserProcessorType||(exports.ParserProcessorType=ParserProcessorType={}));var VendedLogType;(function(VendedLogType2){VendedLogType2[VendedLogType2.CLOUDFRONT=0]="CLOUDFRONT",VendedLogType2[VendedLogType2.VPC=1]="VPC",VendedLogType2[VendedLogType2.WAF=2]="WAF",VendedLogType2[VendedLogType2.ROUTE53=3]="ROUTE53",VendedLogType2[VendedLogType2.POSTGRES=4]="POSTGRES"})(VendedLogType||(exports.VendedLogType=VendedLogType={}));var StringMutatorType;(function(StringMutatorType2){StringMutatorType2[StringMutatorType2.LOWER_CASE=0]="LOWER_CASE",StringMutatorType2[StringMutatorType2.UPPER_CASE=1]="UPPER_CASE",StringMutatorType2[StringMutatorType2.TRIM=2]="TRIM",StringMutatorType2[StringMutatorType2.SPLIT=3]="SPLIT",StringMutatorType2[StringMutatorType2.SUBSTITUTE=4]="SUBSTITUTE"})(StringMutatorType||(exports.StringMutatorType=StringMutatorType={}));var JsonMutatorType;(function(JsonMutatorType2){JsonMutatorType2[JsonMutatorType2.ADD_KEYS=0]="ADD_KEYS",JsonMutatorType2[JsonMutatorType2.DELETE_KEYS=1]="DELETE_KEYS",JsonMutatorType2[JsonMutatorType2.MOVE_KEYS=2]="MOVE_KEYS",JsonMutatorType2[JsonMutatorType2.RENAME_KEYS=3]="RENAME_KEYS",JsonMutatorType2[JsonMutatorType2.COPY_VALUE=4]="COPY_VALUE",JsonMutatorType2[JsonMutatorType2.LIST_TO_MAP=5]="LIST_TO_MAP"})(JsonMutatorType||(exports.JsonMutatorType=JsonMutatorType={}));var DataConverterType;(function(DataConverterType2){DataConverterType2[DataConverterType2.TYPE_CONVERTER=0]="TYPE_CONVERTER",DataConverterType2[DataConverterType2.DATETIME_CONVERTER=1]="DATETIME_CONVERTER"})(DataConverterType||(exports.DataConverterType=DataConverterType={}));class ParserProcessor{constructor(props){try{jsiiDeprecationWarnings().aws_cdk_lib_aws_logs_ParserProcessorProps(props)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,ParserProcessor),error}switch(this.type=props.type,this.type){case ParserProcessorType.JSON:this.jsonOptions={source:"@message",...props.jsonOptions};break;case ParserProcessorType.KEY_VALUE:this.keyValueOptions={source:"@message",fieldDelimiter:KeyValuePairDelimiter.AMPERSAND,keyValueDelimiter:KeyValueDelimiter.EQUAL,overwriteIfExists:!1,...props.keyValueOptions};break;case ParserProcessorType.CSV:this.csvOptions={source:"@message",quoteCharacter:QuoteCharacter.DOUBLE_QUOTE,delimiter:DelimiterCharacter.COMMA,...props.csvOptions};break;case ParserProcessorType.GROK:if(!props.grokOptions||!props.grokOptions.match)throw new(core_1()).UnscopedValidationError("Match pattern is required for Grok parser");this.grokOptions={source:"@message",...props.grokOptions};break;case ParserProcessorType.OCSF:if(!props.parseToOCSFOptions)throw new(core_1()).UnscopedValidationError("parseToOCSFOptions must be provided for type OCSF");this.parseToOCSFOptions={source:"@message",...props.parseToOCSFOptions};break;default:throw new(core_1()).UnscopedValidationError(`Unsupported parser processor type: ${this.type}`)}}_render(){switch(this.type){case ParserProcessorType.JSON:return{parseJson:this.jsonOptions};case ParserProcessorType.KEY_VALUE:return{parseKeyValue:this.keyValueOptions};case ParserProcessorType.CSV:return{csv:this.csvOptions};case ParserProcessorType.GROK:return{grok:this.grokOptions};case ParserProcessorType.OCSF:return{parseToOcsf:this.parseToOCSFOptions};default:throw new(core_1()).UnscopedValidationError(`Unsupported parser processor type: ${this.type}`)}}}exports.ParserProcessor=ParserProcessor,_a=JSII_RTTI_SYMBOL_1,ParserProcessor[_a]={fqn:"aws-cdk-lib.aws_logs.ParserProcessor",version:"2.211.0"};class VendedLogParser{constructor(props){try{jsiiDeprecationWarnings().aws_cdk_lib_aws_logs_VendedLogParserProps(props)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,VendedLogParser),error}this.logType=props.logType}_render(){switch(this.logType){case VendedLogType.CLOUDFRONT:return{parseCloudfront:{}};case VendedLogType.VPC:return{parseVpc:{}};case VendedLogType.WAF:return{parseWaf:{}};case VendedLogType.ROUTE53:return{parseRoute53:{}};case VendedLogType.POSTGRES:return{parsePostgres:{}};default:throw new(core_1()).UnscopedValidationError(`Unsupported vended log type: ${this.logType}`)}}}exports.VendedLogParser=VendedLogParser,_b=JSII_RTTI_SYMBOL_1,VendedLogParser[_b]={fqn:"aws-cdk-lib.aws_logs.VendedLogParser",version:"2.211.0"};class StringMutatorProcessor{constructor(props){try{jsiiDeprecationWarnings().aws_cdk_lib_aws_logs_StringMutatorProps(props)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,StringMutatorProcessor),error}switch(this.type=props.type,this.type){case StringMutatorType.LOWER_CASE:if(!props.lowerCaseKeys||props.lowerCaseKeys.length===0)throw new(core_1()).UnscopedValidationError("lowerCaseKeys must be provided for LOWER_CASE string mutator");this.lowerCaseKeys=props.lowerCaseKeys;break;case StringMutatorType.UPPER_CASE:if(!props.upperCaseKeys||props.upperCaseKeys.length===0)throw new(core_1()).UnscopedValidationError("upperCaseKeys must be provided for UPPER_CASE string mutator");this.upperCaseKeys=props.upperCaseKeys;break;case StringMutatorType.TRIM:if(!props.trimKeys||props.trimKeys.length===0)throw new(core_1()).UnscopedValidationError("trimKeys must be provided for TRIM string mutator");this.trimKeys=props.trimKeys;break;case StringMutatorType.SPLIT:if(!props.splitOptions||!props.splitOptions.entries||props.splitOptions.entries.length===0)throw new(core_1()).UnscopedValidationError("splitOptions must be provided for SPLIT string mutator");this.splitOptions=props.splitOptions;break;case StringMutatorType.SUBSTITUTE:if(!props.substituteOptions||!props.substituteOptions.entries||props.substituteOptions.entries.length===0)throw new(core_1()).UnscopedValidationError("substituteOptions must be provided for SUBSTITUTE string mutator");this.substituteOptions=props.substituteOptions;break;default:throw new(core_1()).UnscopedValidationError(`Unsupported string mutator type: ${this.type}`)}}_render(){switch(this.type){case StringMutatorType.LOWER_CASE:return{lowerCaseString:{withKeys:this.lowerCaseKeys}};case StringMutatorType.UPPER_CASE:return{upperCaseString:{withKeys:this.upperCaseKeys}};case StringMutatorType.TRIM:return{trimString:{withKeys:this.trimKeys}};case StringMutatorType.SPLIT:return{splitString:this.splitOptions};case StringMutatorType.SUBSTITUTE:return{substituteString:this.substituteOptions};default:throw new(core_1()).UnscopedValidationError(`Unsupported string mutator type: ${this.type}`)}}}exports.StringMutatorProcessor=StringMutatorProcessor,_c=JSII_RTTI_SYMBOL_1,StringMutatorProcessor[_c]={fqn:"aws-cdk-lib.aws_logs.StringMutatorProcessor",version:"2.211.0"};class JsonMutatorProcessor{constructor(props){try{jsiiDeprecationWarnings().aws_cdk_lib_aws_logs_JsonMutatorProps(props)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,JsonMutatorProcessor),error}switch(this.type=props.type,this.type){case JsonMutatorType.ADD_KEYS:if(!props.addKeysOptions||!props.addKeysOptions.entries||props.addKeysOptions.entries.length===0)throw new(core_1()).UnscopedValidationError("addKeysOptions must be provided for ADD_KEYS JSON mutator");this.addKeysOptions={entries:props.addKeysOptions.entries.map(entry=>({overwriteIfExists:!1,...entry}))};break;case JsonMutatorType.DELETE_KEYS:if(!props.deleteKeysOptions||!props.deleteKeysOptions.withKeys||props.deleteKeysOptions.withKeys.length===0)throw new(core_1()).UnscopedValidationError("deleteKeys must be provided for DELETE_KEYS JSON mutator");this.deleteKeysOptions=props.deleteKeysOptions;break;case JsonMutatorType.MOVE_KEYS:if(!props.moveKeysOptions||!props.moveKeysOptions.entries||props.moveKeysOptions.entries.length===0)throw new(core_1()).UnscopedValidationError("moveKeysOptions must be provided for MOVE_KEYS JSON mutator");this.moveKeysOptions={entries:props.moveKeysOptions.entries.map(entry=>({overwriteIfExists:!1,...entry}))};break;case JsonMutatorType.RENAME_KEYS:if(!props.renameKeysOptions||!props.renameKeysOptions.entries||props.renameKeysOptions.entries.length===0)throw new(core_1()).UnscopedValidationError("renameKeysOptions must be provided for RENAME_KEYS JSON mutator");this.renameKeysOptions={entries:props.renameKeysOptions.entries.map(entry=>({overwriteIfExists:!1,...entry}))};break;case JsonMutatorType.COPY_VALUE:if(!props.copyValueOptions||!props.copyValueOptions.entries||props.copyValueOptions.entries.length===0)throw new(core_1()).UnscopedValidationError("copyValueOptions must be provided for COPY_VALUE JSON mutator");this.copyValueOptions={entries:props.copyValueOptions.entries.map(entry=>({overwriteIfExists:!1,...entry}))};break;case JsonMutatorType.LIST_TO_MAP:if(!props.listToMapOptions||!props.listToMapOptions.source||!props.listToMapOptions.key)throw new(core_1()).UnscopedValidationError("listToMapOptions with source and key must be provided for LIST_TO_MAP JSON mutator");if(props.listToMapOptions.flatten&&!props.listToMapOptions.flattenedElement)throw new(core_1()).UnscopedValidationError("listToMapOptions flattenedElement must be provided when flatten is true for LIST_TO_MAP JSON mutator");this.listToMapOptions={flatten:!1,...props.listToMapOptions};break;default:throw new(core_1()).UnscopedValidationError(`Unsupported JSON mutator type: ${this.type}`)}}_render(){switch(this.type){case JsonMutatorType.ADD_KEYS:return{addKeys:this.addKeysOptions};case JsonMutatorType.DELETE_KEYS:return{deleteKeys:this.deleteKeysOptions};case JsonMutatorType.MOVE_KEYS:return{moveKeys:this.moveKeysOptions};case JsonMutatorType.RENAME_KEYS:return{renameKeys:this.renameKeysOptions};case JsonMutatorType.COPY_VALUE:return{copyValue:this.copyValueOptions};case JsonMutatorType.LIST_TO_MAP:return{listToMap:this.listToMapOptions};default:throw new(core_1()).UnscopedValidationError(`Unsupported JSON mutator type: ${this.type}`)}}}exports.JsonMutatorProcessor=JsonMutatorProcessor,_d=JSII_RTTI_SYMBOL_1,JsonMutatorProcessor[_d]={fqn:"aws-cdk-lib.aws_logs.JsonMutatorProcessor",version:"2.211.0"};class DataConverterProcessor{constructor(props){try{jsiiDeprecationWarnings().aws_cdk_lib_aws_logs_DataConverterProps(props)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,DataConverterProcessor),error}switch(this.type=props.type,this.type){case DataConverterType.TYPE_CONVERTER:if(!props.typeConverterOptions||!props.typeConverterOptions.entries||props.typeConverterOptions.entries.length===0)throw new(core_1()).UnscopedValidationError("typeConverterOptions must be provided for TYPE_CONVERTER data converter");this.typeConverterOptions=props.typeConverterOptions;break;case DataConverterType.DATETIME_CONVERTER:if(!props.dateTimeConverterOptions||!props.dateTimeConverterOptions.source||!props.dateTimeConverterOptions.target||!props.dateTimeConverterOptions.matchPatterns)throw new(core_1()).UnscopedValidationError("dateTimeConverterOptions with source, target and matchPatterns must be provided for DATETIME_CONVERTER data converter");this.dateTimeConverterOptions={targetFormat:"yyyy-MM-dd'T'HH:mm:ss.SSS'Z'",sourceTimezone:"UTC",targetTimezone:"UTC",...props.dateTimeConverterOptions};break;default:throw new(core_1()).UnscopedValidationError(`Unsupported data converter type: ${this.type}`)}}_render(){switch(this.type){case DataConverterType.TYPE_CONVERTER:return{typeConverter:this.typeConverterOptions};case DataConverterType.DATETIME_CONVERTER:return{dateTimeConverter:this.dateTimeConverterOptions};default:throw new(core_1()).UnscopedValidationError(`Unsupported data converter type: ${this.type}`)}}}exports.DataConverterProcessor=DataConverterProcessor,_e=JSII_RTTI_SYMBOL_1,DataConverterProcessor[_e]={fqn:"aws-cdk-lib.aws_logs.DataConverterProcessor",version:"2.211.0"};let Transformer=class Transformer2 extends core_1().Resource{constructor(scope,id,props){super(scope,id,{physicalName:props.transformerName});try{jsiiDeprecationWarnings().aws_cdk_lib_aws_logs_TransformerProps(props)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,Transformer2),error}(0,metadata_resource_1().addConstructMetadata)(this,props),this.validateProcessorCount(props.transformerConfig),this.validateParserProcessors(props.transformerConfig),this.validateUniqueProcessorTypes(props.transformerConfig),this.validateLogGroupClass(props.logGroup),new(_1()).CfnTransformer(scope,"ResourceTransformer",{logGroupIdentifier:props.logGroup.logGroupName,transformerConfig:props.transformerConfig.map(processor=>processor._render())})}validateProcessorCount(processors){if(!core_1().Token.isUnresolved(processors)){if(processors.length===0)throw new(core_1()).ValidationError("At least one processor is required in a transformer",this);if(processors.length>20)throw new(core_1()).ValidationError("A transformer cannot have more than 20 processors",this)}}validateParserProcessors(processors){if(core_1().Token.isUnresolved(processors))return;if(!(processors.at(0)instanceof ParserProcessor||processors.at(0)instanceof VendedLogParser))throw new(core_1()).ValidationError("First processor in a transformer must be a parser",this);const parserProcessors=processors.filter(p=>p instanceof ParserProcessor||p instanceof VendedLogParser),vendedProcessors=processors.filter(p=>p instanceof VendedLogParser);if(parserProcessors.length>5)throw new(core_1()).ValidationError("A transformer cannot have more than 5 parser-type processors",this);if(vendedProcessors.length>1)throw new(core_1()).ValidationError("Only one vended log parser is allowed in a transformer",this);if(processors.findIndex(p=>p instanceof VendedLogParser)>0)throw new(core_1()).ValidationError("AWS vended log parser must be the first processor in a transformer",this)}validateUniqueProcessorTypes(processors){if(core_1().Token.isUnresolved(processors))return;if(processors.filter(p=>p instanceof ParserProcessor&&p.type===ParserProcessorType.GROK).length>1)throw new(core_1()).ValidationError("Only one grok processor is allowed in a transformer",this);if(processors.filter(p=>p instanceof JsonMutatorProcessor&&p.type===JsonMutatorType.ADD_KEYS).length>1)throw new(core_1()).ValidationError("Only one addKeys processor is allowed in a transformer",this);if(processors.filter(p=>p instanceof JsonMutatorProcessor&&p.type===JsonMutatorType.COPY_VALUE).length>1)throw new(core_1()).ValidationError("Only one copyValue processor is allowed in a transformer",this);const parseToOcsfProcessors=processors.filter(p=>p instanceof ParserProcessor&&p.type===ParserProcessorType.OCSF);if(parseToOcsfProcessors.length>1)throw new(core_1()).ValidationError("Only one parseToOCSF processor is allowed in a transformer",this);if(parseToOcsfProcessors.length>0&&processors.findIndex(p=>p instanceof ParserProcessor&&p.type===ParserProcessorType.OCSF)!=0)throw new(core_1()).ValidationError("parseToOCSF processor must be the first processor in a transformer",this)}validateLogGroupClass(logGroup){logGroup.node&&logGroup.node.addMetadata("warning","Transformers can only be created for log groups in the Standard log class. Ensure that your log group is using the Standard log class.")}};exports.Transformer=Transformer,_f=JSII_RTTI_SYMBOL_1,Transformer[_f]={fqn:"aws-cdk-lib.aws_logs.Transformer",version:"2.211.0"},Transformer.PROPERTY_INJECTION_ID="aws-cdk-lib.aws-logs.Transformer",exports.Transformer=Transformer=__decorate([prop_injectable_1().propertyInjectable],Transformer);