# FunctionRuntime

The function's runtime environment version.

Obtainable from: FunctionRuntime.JS_1_0, FunctionRuntime.JS_2_0, FunctionRuntime.custom

- Source: [`aws-cloudfront/lib/function.ts`](https://github.com/aws/aws-cdk/blob/v2.277.0/packages/aws-cdk-lib/aws-cloudfront/lib/function.ts#L291)
- Type last changed: v2.118.0 · 3 Jan 2024

## Example

TypeScript:

```ts
const store = new cloudfront.KeyValueStore(this, 'KeyValueStore');
new cloudfront.Function(this, 'Function', {
  code: cloudfront.FunctionCode.fromInline('function handler(event) { return event.request }'),
  // Note that JS_2_0 must be used for Key Value Store support
  runtime: cloudfront.FunctionRuntime.JS_2_0,
  keyValueStore: store,
});
```

Python:

```python
store = cloudfront.KeyValueStore(self, "KeyValueStore")
cloudfront.Function(self, "Function",
    code=cloudfront.FunctionCode.from_inline("function handler(event) { return event.request }"),
    # Note that JS_2_0 must be used for Key Value Store support
    runtime=cloudfront.FunctionRuntime.JS_2_0,
    key_value_store=store
)
```

Java:

```java
KeyValueStore store = new KeyValueStore(this, "KeyValueStore");
Function.Builder.create(this, "Function")
        .code(FunctionCode.fromInline("function handler(event) { return event.request }"))
        // Note that JS_2_0 must be used for Key Value Store support
        .runtime(FunctionRuntime.JS_2_0)
        .keyValueStore(store)
        .build();
```

C# / .NET:

```csharp
// Install: dotnet add package Amazon.CDK.Lib
var store = new KeyValueStore(this, "KeyValueStore");
new Function(this, "Function", new FunctionProps {
    Code = FunctionCode.FromInline("function handler(event) { return event.request }"),
    // Note that JS_2_0 must be used for Key Value Store support
    Runtime = FunctionRuntime.JS_2_0,
    KeyValueStore = store
});
```

Golang:

```go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
store := cloudfront.NewKeyValueStore(this, jsii.String("KeyValueStore"))
cloudfront.NewFunction(this, jsii.String("Function"), &FunctionProps{
	Code: cloudfront.FunctionCode_FromInline(jsii.String("function handler(event) { return event.request }")),
	// Note that JS_2_0 must be used for Key Value Store support
	Runtime: cloudfront.FunctionRuntime_JS_2_0(),
	KeyValueStore: store,
})
```

## Properties

- `JS_1_0`: [FunctionRuntime](/cdk/api/v2/docs/aws-cdk-lib.aws_cloudfront.FunctionRuntime.html) (static) — cloudfront-js-1.0.

- `JS_2_0`: [FunctionRuntime](/cdk/api/v2/docs/aws-cdk-lib.aws_cloudfront.FunctionRuntime.html) (static) — cloudfront-js-2.0.

- `value`: string

## Methods

- `custom(runtimeString: string): FunctionRuntime // chainable` (static) — A custom runtime string.

  Gives full control over the runtime string fragment.
