# CustomWidgetProps

The properties for a CustomWidget.

Used as props by: [CustomWidget](https://docs.aws.amazon.com/cdk/api/v2/docs/aws-cdk-lib.aws_cloudwatch.CustomWidget.html)

- Source: [`aws-cloudwatch/lib/graph.ts`](https://github.com/aws/aws-cdk/blob/v2.278.0/packages/aws-cdk-lib/aws-cloudwatch/lib/graph.ts#L961)
- Type last changed: v2.23.0 · 4 May 2022

## Example

TypeScript:

```ts
declare const dashboard: cloudwatch.Dashboard;

// Import or create a lambda function
const fn = lambda.Function.fromFunctionArn(
  dashboard,
  'Function',
  'arn:aws:lambda:us-east-1:123456789012:function:MyFn',
);

dashboard.addWidgets(new cloudwatch.CustomWidget({
  functionArn: fn.functionArn,
  title: 'My lambda baked widget',
}));
```

Python:

```python
# dashboard: cloudwatch.Dashboard

# Import or create a lambda function
fn = lambda_.Function.from_function_arn(dashboard, "Function", "arn:aws:lambda:us-east-1:123456789012:function:MyFn")

dashboard.add_widgets(cloudwatch.CustomWidget(
    function_arn=fn.function_arn,
    title="My lambda baked widget"
))
```

Java:

```java
Dashboard dashboard;

// Import or create a lambda function
IFunction fn = Function.fromFunctionArn(dashboard, "Function", "arn:aws:lambda:us-east-1:123456789012:function:MyFn");

dashboard.addWidgets(CustomWidget.Builder.create()
        .functionArn(fn.getFunctionArn())
        .title("My lambda baked widget")
        .build());
```

C# / .NET:

```csharp
// Install: dotnet add package Amazon.CDK.Lib
Dashboard dashboard;

// Import or create a lambda function
var fn = Function.FromFunctionArn(dashboard, "Function", "arn:aws:lambda:us-east-1:123456789012:function:MyFn");

dashboard.AddWidgets(new CustomWidget(new CustomWidgetProps {
    FunctionArn = fn.FunctionArn,
    Title = "My lambda baked widget"
}));
```

Golang:

```go
// Install: go get github.com/aws/aws-cdk-go/awscdk/v2
var dashboard Dashboard

// Import or create a lambda function
fn := lambda.Function_FromFunctionArn(dashboard, jsii.String("Function"), jsii.String("arn:aws:lambda:us-east-1:123456789012:function:MyFn"))

dashboard.AddWidgets(cloudwatch.NewCustomWidget(&CustomWidgetProps{
	FunctionArn: fn.FunctionArn,
	Title: jsii.String("My lambda baked widget"),
}))
```

## Properties

- `functionArn`: string (required) — The Arn of the AWS Lambda function that returns HTML or JSON that will be displayed in the widget.

- `height`: number — Height of the widget.

  **Default:** 6 for Alarm and Graph widgets. 3 for single value widgets where most recent value of a metric is displayed.

- `params`: any — Parameters passed to the lambda function.

  **Default:** no parameters are passed to the lambda function

- `title`: string (required) — The title of the widget.

- `updateOnRefresh`: boolean = true — Update the widget on refresh.

- `updateOnResize`: boolean = true — Update the widget on resize.

- `updateOnTimeRangeChange`: boolean = true — Update the widget on time range change.

- `width`: number = 6 — Width of the widget, in a grid of 24 units wide.
