"use strict";var _a;Object.defineProperty(exports,"__esModule",{value:!0}),exports.ParamsAndSecretsLayerVersion=exports.ParamsAndSecretsLogLevel=exports.ParamsAndSecretsVersions=void 0;const jsiiDeprecationWarnings=require("../../.warnings.jsii.js"),JSII_RTTI_SYMBOL_1=Symbol.for("jsii.rtti"),core_1=require("../../core"),region_info_1=require("../../region-info");var ParamsAndSecretsVersions;(function(ParamsAndSecretsVersions2){ParamsAndSecretsVersions2.V1_0_103="1.0.103"})(ParamsAndSecretsVersions||(exports.ParamsAndSecretsVersions=ParamsAndSecretsVersions={}));var ParamsAndSecretsLogLevel;(function(ParamsAndSecretsLogLevel2){ParamsAndSecretsLogLevel2.DEBUG="debug",ParamsAndSecretsLogLevel2.INFO="info",ParamsAndSecretsLogLevel2.WARN="warn",ParamsAndSecretsLogLevel2.ERROR="error",ParamsAndSecretsLogLevel2.NONE="none"})(ParamsAndSecretsLogLevel||(exports.ParamsAndSecretsLogLevel=ParamsAndSecretsLogLevel={}));class ParamsAndSecretsLayerVersion{static fromVersionArn(arn,options={}){try{jsiiDeprecationWarnings.aws_cdk_lib_aws_lambda_ParamsAndSecretsOptions(options)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.fromVersionArn),error}return new class extends ParamsAndSecretsLayerVersion{_bind(_scope,_fn){return{arn,environmentVars:this.environmentVariablesFromOptions}}}(options)}static fromVersion(version,options={}){try{jsiiDeprecationWarnings.aws_cdk_lib_aws_lambda_ParamsAndSecretsVersions(version),jsiiDeprecationWarnings.aws_cdk_lib_aws_lambda_ParamsAndSecretsOptions(options)}catch(error){throw process.env.JSII_DEBUG!=="1"&&error.name==="DeprecationError"&&Error.captureStackTrace(error,this.fromVersion),error}return new class extends ParamsAndSecretsLayerVersion{_bind(scope,fn){return{arn:this.getVersionArn(scope,version,fn.architecture.name),environmentVars:this.environmentVariablesFromOptions}}}(options)}constructor(options){this.options=options}get environmentVariablesFromOptions(){if(this.options.cacheSize!==void 0&&(this.options.cacheSize<0||this.options.cacheSize>1e3))throw new Error(`Cache size must be between 0 and 1000 inclusive - provided: ${this.options.cacheSize}`);if(this.options.httpPort!==void 0&&(this.options.httpPort<1||this.options.httpPort>65535))throw new Error(`HTTP port must be between 1 and 65535 inclusive - provided: ${this.options.httpPort}`);if(this.options.maxConnections!==void 0&&this.options.maxConnections<1)throw new Error(`Maximum connections must be at least 1 - provided: ${this.options.maxConnections}`);if(this.options.secretsManagerTtl!==void 0&&this.options.secretsManagerTtl.toSeconds()>300)throw new Error(`Maximum TTL for a cached secret is 300 seconds - provided: ${this.options.secretsManagerTtl.toSeconds()} seconds`);if(this.options.parameterStoreTtl!==void 0&&this.options.parameterStoreTtl.toSeconds()>300)throw new Error(`Maximum TTL for a cached parameter is 300 seconds - provided: ${this.options.parameterStoreTtl.toSeconds()} seconds`);return{PARAMETERS_SECRETS_EXTENSION_CACHE_ENABLED:this.options.cacheEnabled??!0,PARAMETERS_SECRETS_EXTENSION_CACHE_SIZE:this.options.cacheSize??1e3,PARAMETERS_SECRETS_EXTENSION_HTTP_PORT:this.options.httpPort??2773,PARAMETERS_SECRETS_EXTENSION_LOG_LEVEL:this.options.logLevel??ParamsAndSecretsLogLevel.INFO,PARAMETERS_SECRETS_EXTENSION_MAX_CONNECTIONS:this.options.maxConnections??3,SECRETS_MANAGER_TIMEOUT_MILLIS:this.options.secretsManagerTimeout?.toMilliseconds()??0,SECRETS_MANAGER_TTL:this.options.secretsManagerTtl?.toSeconds()??300,SSM_PARAMETER_STORE_TIMEOUT_MILLIS:this.options.parameterStoreTimeout?.toMilliseconds()??0,SSM_PARAMETER_STORE_TTL:this.options.parameterStoreTtl?.toSeconds()??300}}getVersionArn(scope,version,architecture){const stack=core_1.Stack.of(scope),region=stack.region;if(region!==void 0&&!core_1.Token.isUnresolved(region)){const layerArn=region_info_1.RegionInfo.get(region).paramsAndSecretsLambdaLayerArn(version,architecture);if(layerArn===void 0)throw new Error(`Parameters and Secrets Extension is not supported in region ${region} for ${architecture} architecture`);return layerArn}return stack.regionalFact(region_info_1.FactName.paramsAndSecretsLambdaLayer(version,architecture))}}exports.ParamsAndSecretsLayerVersion=ParamsAndSecretsLayerVersion,_a=JSII_RTTI_SYMBOL_1,ParamsAndSecretsLayerVersion[_a]={fqn:"aws-cdk-lib.aws_lambda.ParamsAndSecretsLayerVersion",version:"2.96.1"};
