# CapacityProviderFunctionOptions

Options for creating a function associated with a capacity provider.

- Source: [`aws-lambda/lib/capacity-provider.ts`](https://github.com/aws/aws-cdk/blob/v2.275.0/packages/aws-cdk-lib/aws-lambda/lib/capacity-provider.ts#L338)
- Type last changed: v2.231.0 · 1 Dec 2025

## Example

```ts
declare const capacityProvider: lambda.CapacityProvider;

const fn = new lambda.Function(this, 'MyFunction', {
  // Runtime must be equal to or newer than NODEJS_LATEST
  runtime: lambda.Runtime.NODEJS_LATEST,
  handler: 'index.handler',
  code: lambda.Code.fromAsset(path.join(__dirname, 'lambda-handler')),
});

// Associate the function with the capacity provider
capacityProvider.addFunction(fn, {
  perExecutionEnvironmentMaxConcurrency: 10,
  executionEnvironmentMemoryGiBPerVCpu: 4,
});
```

## Properties

- `executionEnvironmentMemoryGiBPerVCpu`: number = 2.0 — Specifies the execution environment memory per VCPU, in GiB.

- `latestPublishedScalingConfig`: [LatestPublishedScalingConfig](/cdk/api/v2/docs/aws-cdk-lib.aws_lambda.LatestPublishedScalingConfig.html) — The scaling options that are applied to the $LATEST.PUBLISHED version.

  **Default:** No scaling limitations are applied to the $LATEST.PUBLISHED version.

- `perExecutionEnvironmentMaxConcurrency`: number — Specifies the maximum number of concurrent invokes a single execution environment can handle.

  **Default:** Maximum is set to 10

- `publishToLatestPublished`: boolean = True — A boolean determining whether or not to automatically publish to the $LATEST.PUBLISHED version.
