CustomWidget

class aws_cdk.aws_cloudwatch.CustomWidget(*, function_arn, title, height=None, params=None, update_on_refresh=None, update_on_resize=None, update_on_time_range_change=None, width=None)

Bases: ConcreteWidget

A CustomWidget shows the result of a AWS lambda function.

ExampleMetadata:

infused

Example:

# 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"
))
Parameters:
  • function_arn (str) – The Arn of the AWS Lambda function that returns HTML or JSON that will be displayed in the widget.

  • title (str) – The title of the widget.

  • height (Union[int, float, None]) – 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 (Optional[Any]) – Parameters passed to the lambda function. Default: - no parameters are passed to the lambda function

  • update_on_refresh (Optional[bool]) – Update the widget on refresh. Default: true

  • update_on_resize (Optional[bool]) – Update the widget on resize. Default: true

  • update_on_time_range_change (Optional[bool]) – Update the widget on time range change. Default: true

  • width (Union[int, float, None]) – Width of the widget, in a grid of 24 units wide. Default: 6

Methods

position(x, y)

Place the widget at a given position.

Parameters:
  • x (Union[int, float]) –

  • y (Union[int, float]) –

Return type:

None

to_json()

Return the widget JSON for use in the dashboard.

Return type:

List[Any]

Attributes

height

The amount of vertical grid units the widget will take up.

warnings

Any warnings that are produced as a result of putting together this widget.

warnings_v2

Any warnings that are produced as a result of putting together this widget.

width

The amount of horizontal grid units the widget will take up.