# ParamsAndSecretsOptions

Parameters and Secrets Extension configuration options.

- Source: [`aws-lambda/lib/params-and-secrets-layers.ts`](https://github.com/aws/aws-cdk/blob/v2.274.0/packages/aws-cdk-lib/aws-lambda/lib/params-and-secrets-layers.ts#L69)
- Type last changed: v2.84.0 · 14 Jun 2023

## Example

```ts
import * as sm from 'aws-cdk-lib/aws-secretsmanager';
import * as ssm from 'aws-cdk-lib/aws-ssm';

const secret = new sm.Secret(this, 'Secret');
const parameter = new ssm.StringParameter(this, 'Parameter', {
  parameterName: 'mySsmParameterName',
  stringValue: 'mySsmParameterValue',
});

const paramsAndSecrets = lambda.ParamsAndSecretsLayerVersion.fromVersion(lambda.ParamsAndSecretsVersions.V1_0_103, {
  cacheSize: 500,
  logLevel: lambda.ParamsAndSecretsLogLevel.DEBUG,
});

const lambdaFunction = new lambda.Function(this, 'MyFunction', {
  runtime: lambda.Runtime.NODEJS_LATEST,
  handler: 'index.handler',
  architecture: lambda.Architecture.ARM_64,
  code: lambda.Code.fromAsset(path.join(__dirname, 'lambda-handler')),
  paramsAndSecrets,
});

secret.grantRead(lambdaFunction);
parameter.grantRead(lambdaFunction);
```

## Properties

- `cacheEnabled`: boolean = true — Whether the Parameters and Secrets Extension will cache parameters and secrets.

- `cacheSize`: number = 1000 — The maximum number of secrets and parameters to cache.

  Must be a value
  from 0 to 1000. A value of 0 means there is no caching.

  Note: This variable is ignored if parameterStoreTtl and secretsManagerTtl
  are 0.

- `httpPort`: number = 2773 — The port for the local HTTP server.

  Valid port numbers are 1 - 65535.

- `logLevel`: [ParamsAndSecretsLogLevel](/cdk/api/v2/docs/aws-cdk-lib.aws_lambda.ParamsAndSecretsLogLevel.html) — The level of logging provided by the Parameters and Secrets Extension.

  **Default:** Logging level will be `info`

  Note: Set to debug to see the cache configuration.

- `maxConnections`: number = 3 — The maximum number of connection for HTTP clients that the Parameters and Secrets Extension uses to make requests to Parameter Store or Secrets Manager.

  There is no maximum limit. Minimum is 1.

  Note: Every running copy of this Lambda function may open the number of
  connections specified by this property. Thus, the total number of connections
  may exceed this number.

- `parameterStoreTimeout`: [Duration](/cdk/api/v2/docs/aws-cdk-lib.Duration.html) = 0 — The timeout for requests to Parameter Store.

  A value of 0 means that there is no
  timeout.

- `parameterStoreTtl`: [Duration](/cdk/api/v2/docs/aws-cdk-lib.Duration.html) — The time-to-live of a parameter in the cache.

  **Default:** 300 seconds

  A value of 0 means there is no caching.
  The maximum time-to-live is 300 seconds.

  Note: This variable is ignored if cacheSize is 0.

- `secretsManagerTimeout`: [Duration](/cdk/api/v2/docs/aws-cdk-lib.Duration.html) = 0 — The timeout for requests to Secrets Manager.

  A value of 0 means that there is
  no timeout.

- `secretsManagerTtl`: [Duration](/cdk/api/v2/docs/aws-cdk-lib.Duration.html) — The time-to-live of a secret in the cache.

  **Default:** 300 seconds

  A value of 0 means there is no caching.
  The maximum time-to-live is 300 seconds.

  Note: This variable is ignored if cacheSize is 0.
