Repository: cdklabs/cdk-monitoring-constructs (language: python)

Issue:
Dynamic Dashboard Default Range Incorrect
### Version

5.0.0

### Steps and/or minimal code example to reproduce

Create any MonitoringFacade with dashboardConfigs and DynamicSegments:


```
new MonitoringFacade(this, `MonitoringFacade`, {
            dashboardNamePrefix: dashboardName,
            dashboardConfigs: [
                { name: DashboardTypes.Type1, range: Duration.days(7). },
            ],
            ...
```


### Expected behavior

Duration should be converted into a properly formatted string, and the default range of the dashboard should be set correctly according to CloudWatch api spec in the CloudFormation template:

```
start

    The start of the time range to use for each widget on the dashboard.

    You can specify start without specifying end to specify a relative time range that ends with the current time. In this case, the value of start must begin with -PT if you specify a time range in minutes or hours, and must begin with -P if you specify a time range in days, weeks, or months. You can then use M, H, D, W and M as abbreviations for minutes, hours, days, weeks and months. For example, -PT5M shows the last 5 minutes, -PT8H shows the last 8 hours, and -P3M shows the last three months.

    You can also use start along with an end field, to specify an absolute time range. When specifying an absolute time range, use the ISO 8601 format. For example, 2018-12-17T06:00:00.000Z.

    If you omit start, the dashboard shows the default time range when it loads.

    Type: String

    Required: No

```


Example: 
```
   "Type": "AWS::CloudWatch::Dashboard",
   "Properties": {
    "DashboardBody": {
     "Fn::Join": [
      "",
      [
       "{\"start\":\"-P7D\",\"widgets\":[{\"type\":\"text\",\"width\":......, 
       {
        "Ref": "AWS::Region"
       },

```

### Actual behavior


In the [constructor of DynamicDashboardFactory](https://github.com/cdklabs/cdk-monitoring-constructs/blob/21cf2cc92cc10e1d2a9af330b6659776f17954b7/lib/dashboard/DynamicDashboardFactory.ts#L90C1-L91C74), this is used in the following way:

```
      const start: string =
        "-" + (dashboardConfig.range ?? Duration.hours(8).toIsoString());

      const dashboard = this.createDashboard(
        renderingPreference,
        dashboardConfig.name,
        {
          dashboardName: `${props.dashboardNamePrefix}-${dashboardConfig.name}`,
          start,
          periodOverride:
            dashboardConfig.periodOverride ?? PeriodOverride.INHERIT,
        }
      );
```

dashboardConfig.range is restricted to type `Duration`, and this translates into the cloudformation template, resulting in no default start and the behavior is that it shows 3 hours.

Example: 
```
{
   "Type": "AWS::CloudWatch::Dashboard",
   "Properties": {
    "DashboardBody": {
     "Fn::Join": [
      "",
      [
       "{\"start\":\"-Duration.days(7)\",\"periodOverride\":\"inherit\",\"widgets\"......,
       {
        "Ref": "AWS::Region"
       },
```

### Other details

Maybe let the interface DynamicDashboardConfiguration range property be able to be string?
Or fix from

```
      const start: string =
        "-" + (dashboardConfig.range ?? Duration.hours(8).toIsoString());
```

to 

```
      const start: string =
        "-" + (dashboardConfig.range.toIsoString() ?? Duration.hours(8).toIsoString());
```


Discussion / hints:

Fix patch:
diff --git a/lib/dashboard/DynamicDashboardFactory.ts b/lib/dashboard/DynamicDashboardFactory.ts
index 003c6852..0008fdb0 100644
--- a/lib/dashboard/DynamicDashboardFactory.ts
+++ b/lib/dashboard/DynamicDashboardFactory.ts
@@ -88,7 +88,9 @@ export class DynamicDashboardFactory
         dashboardConfig.renderingPreference ??
         DashboardRenderingPreference.INTERACTIVE_ONLY;
       const start: string =
-        "-" + (dashboardConfig.range ?? Duration.hours(8).toIsoString());
+        "-" +
+        (dashboardConfig.range?.toIsoString() ??
+          Duration.hours(8).toIsoString());
 
       const dashboard = this.createDashboard(
         renderingPreference,


Test patch:
diff --git a/test/dashboard/DynamicDashboardFactory.test.ts b/test/dashboard/DynamicDashboardFactory.test.ts
index 24d0a9e9..cde84e8c 100644
--- a/test/dashboard/DynamicDashboardFactory.test.ts
+++ b/test/dashboard/DynamicDashboardFactory.test.ts
@@ -1,4 +1,4 @@
-import { Stack } from "aws-cdk-lib";
+import { Duration, Stack } from "aws-cdk-lib";
 import { Template } from "aws-cdk-lib/assertions";
 import { IWidget, TextWidget } from "aws-cdk-lib/aws-cloudwatch";
 import { DynamicDashboardFactory, IDynamicDashboardSegment } from "../../lib";
@@ -28,7 +28,7 @@ test("dynamic dashboards created", () => {
     dashboardNamePrefix: "testPrefix",
     dashboardConfigs: [
       { name: TestDashboards.Dynamic1 },
-      { name: TestDashboards.Dynamic2 },
+      { name: TestDashboards.Dynamic2, range: Duration.days(7) },
     ],
   });
 
@@ -45,7 +45,7 @@ test("dynamic dashboards created", () => {
     DashboardName: "testPrefix-Dynamic1",
   });
   result.hasResourceProperties("AWS::CloudWatch::Dashboard", {
-    DashboardBody: `{"start":"-PT8H","periodOverride":"inherit","widgets":[{"type":"text","width":6,"height":2,"x":0,"y":0,"properties":{"markdown":"Dynamic2"}}]}`,
+    DashboardBody: `{"start":"-P7D","periodOverride":"inherit","widgets":[{"type":"text","width":6,"height":2,"x":0,"y":0,"properties":{"markdown":"Dynamic2"}}]}`,
     DashboardName: "testPrefix-Dynamic2",
   });
 });