# CustomResourceProviderProps

Initialization properties for `CustomResourceProvider`.

Extends: [CustomResourceProviderOptions](/cdk/api/v2/docs/aws-cdk-lib.CustomResourceProviderOptions.html)
Used as props by: [CustomResourceProvider](/cdk/api/v2/docs/aws-cdk-lib.CustomResourceProvider.html)

- Source: [`core/lib/custom-resource-provider/custom-resource-provider.ts`](https://github.com/aws/aws-cdk/blob/v2.277.0/packages/aws-cdk-lib/core/lib/custom-resource-provider/custom-resource-provider.ts#L11)
- Type last changed: v2.116.0 · 22 Dec 2023

## Example

TypeScript:

```ts
const provider = CustomResourceProvider.getOrCreateProvider(this, 'Custom::MyCustomResourceType', {
  codeDirectory: `${__dirname}/my-handler`,
  runtime: CustomResourceProviderRuntime.NODEJS_22_X,
});
provider.addToRolePolicy({
  Effect: 'Allow',
  Action: 's3:GetObject',
  Resource: '*',
})
```

Python:

```python
provider = CustomResourceProvider.get_or_create_provider(self, "Custom::MyCustomResourceType",
    code_directory=f"{__dirname}/my-handler",
    runtime=CustomResourceProviderRuntime.NODEJS_22_X
)
provider.add_to_role_policy({
    "Effect": "Allow",
    "Action": "s3:GetObject",
    "Resource": "*"
})
```

Java:

```java
CustomResourceProvider provider = CustomResourceProvider.getOrCreateProvider(this, "Custom::MyCustomResourceType", CustomResourceProviderProps.builder()
        .codeDirectory(String.format("%s/my-handler", __dirname))
        .runtime(CustomResourceProviderRuntime.NODEJS_22_X)
        .build());
provider.addToRolePolicy(Map.of(
        "Effect", "Allow",
        "Action", "s3:GetObject",
        "Resource", "*"));
```

C# / .NET:

```csharp
// Install: dotnet add package Amazon.CDK.Lib
var provider = CustomResourceProvider.GetOrCreateProvider(this, "Custom::MyCustomResourceType", new CustomResourceProviderProps {
    CodeDirectory = $"{__dirname}/my-handler",
    Runtime = CustomResourceProviderRuntime.NODEJS_22_X
});
provider.AddToRolePolicy(new Dictionary<string, string> {
    { "Effect", "Allow" },
    { "Action", "s3:GetObject" },
    { "Resource", "*" }
});
```

Golang:

```go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
provider := awscdk.CustomResourceProvider_GetOrCreateProvider(this, jsii.String("Custom::MyCustomResourceType"), &CustomResourceProviderProps{
	CodeDirectory: fmt.Sprintf("%v/my-handler", __dirname),
	Runtime: awscdk.CustomResourceProviderRuntime_NODEJS_22_X,
})
provider.AddToRolePolicy(map[string]*string{
	"Effect": jsii.String("Allow"),
	"Action": jsii.String("s3:GetObject"),
	"Resource": jsii.String("*"),
})
```

## Properties

- `codeDirectory`: string (required) — A local file system directory with the provider's code.

  The code will be
  bundled into a zip asset and wired to the provider's AWS Lambda function.

- `description`: string — A description of the function.

  **Default:** No description.

- `environment`: { [key: string]: string } — Key-value pairs that are passed to Lambda as Environment.

  **Default:** No environment variables.

- `memorySize`: [Size](/cdk/api/v2/docs/aws-cdk-lib.Size.html) = Size.mebibytes(128) — The amount of memory that your function has access to.

  Increasing the
  function's memory also increases its CPU allocation.

- `policyStatements`: any[] — A set of IAM policy statements to include in the inline policy of the provider's lambda function.

  **Default:** no additional inline policy

  **Please note**: these are direct IAM JSON policy blobs, *not* `iam.PolicyStatement`
  objects like you will see in the rest of the CDK.

  ```ts
  const provider = CustomResourceProvider.getOrCreateProvider(this, 'Custom::MyCustomResourceType', {
    codeDirectory: `${__dirname}/my-handler`,
    runtime: CustomResourceProviderRuntime.NODEJS_18_X,
    policyStatements: [
      {
        Effect: 'Allow',
        Action: 's3:PutObject*',
        Resource: '*',
      }
    ],
  });
  ```

- `runtime`: [CustomResourceProviderRuntime](/cdk/api/v2/docs/aws-cdk-lib.CustomResourceProviderRuntime.html) (required) — The AWS Lambda runtime and version to use for the provider.

- `timeout`: [Duration](/cdk/api/v2/docs/aws-cdk-lib.Duration.html) = Duration.minutes(15) — AWS Lambda timeout for the provider.

- `useCfnResponseWrapper`: boolean — Whether or not the cloudformation response wrapper (`nodejs-entrypoint.ts`) is used. If set to `true`, `nodejs-entrypoint.js` is bundled in the same asset as the custom resource and set as the entrypoint. If set to `false`, the custom resource provided is the entrypoint.

  **Default:** `true` if `inlineCode: false` and `false` otherwise.
