Skip to content

Commit d41005e

Browse files
authored
feat(cloudwatch): add verticalAnnotations property to GraphWidget (#26819)
Adds a verticalAnnotation property to GraphWidget, reference: https://docs.aws.amazon.com/AmazonCloudWatch/latest/APIReference/CloudWatch-Dashboard-Body-Structure.html#CloudWatch-Dashboard-Properties-Annotation-Format Shoutout to brendo-m for coming up with the solution Closes #7622. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent c695b60 commit d41005e

12 files changed

+621
-6
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"version": "30.0.0",
3+
"files": {
4+
"fa0b1fe0c3043238b7413b794c626bac246c94f150aa6e3ff441a030d7dce521": {
5+
"source": {
6+
"path": "DashboardWithGraphWidgetWithAnnotationsIntegrationTest.template.json",
7+
"packaging": "file"
8+
},
9+
"destinations": {
10+
"current_account-current_region": {
11+
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}",
12+
"objectKey": "fa0b1fe0c3043238b7413b794c626bac246c94f150aa6e3ff441a030d7dce521.json",
13+
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}"
14+
}
15+
}
16+
}
17+
},
18+
"dockerImages": {}
19+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
{
2+
"Resources": {
3+
"DashCCD7F836": {
4+
"Type": "AWS::CloudWatch::Dashboard",
5+
"Properties": {
6+
"DashboardBody": {
7+
"Fn::Join": [
8+
"",
9+
[
10+
"{\"widgets\":[{\"type\":\"metric\",\"width\":6,\"height\":6,\"x\":0,\"y\":0,\"properties\":{\"view\":\"timeSeries\",\"title\":\"My fancy graph\",\"region\":\"",
11+
{
12+
"Ref": "AWS::Region"
13+
},
14+
"\",\"metrics\":[[\"CDK/Test\",\"Metric\",{\"label\":\"Metric left 1 - p99\",\"stat\":\"p99\"}],[\"CDK/Test\",\"Metric\",{\"label\":\"Metric left 2 - TC_10P_90P\",\"stat\":\"TC(10%:90%)\"}],[\"CDK/Test\",\"Metric\",{\"label\":\"Metric left 3 - TS(5%:95%)\",\"stat\":\"TS(5%:95%)\"}],[\"CDK/Test\",\"Metric\",{\"label\":\"Metric right 1 - p90.1234\",\"stat\":\"p90.1234\",\"yAxis\":\"right\"}]],\"annotations\":{\"horizontal\":[{\"value\":10,\"label\":\"Left annotation\",\"color\":\"#00ff00\",\"fill\":\"above\",\"visible\":true,\"yAxis\":\"left\"},{\"value\":20,\"label\":\"Right annotation\",\"color\":\"#e30d0d\",\"fill\":\"below\",\"visible\":false,\"yAxis\":\"right\"}],\"vertical\":[{\"value\":\"2023-08-20T00:00:00.000Z\",\"label\":\"Vertical annotation\",\"color\":\"#2556f6\",\"fill\":\"after\",\"visible\":true}]},\"yAxis\":{}}}]}"
15+
]
16+
]
17+
}
18+
}
19+
}
20+
},
21+
"Parameters": {
22+
"BootstrapVersion": {
23+
"Type": "AWS::SSM::Parameter::Value<String>",
24+
"Default": "/cdk-bootstrap/hnb659fds/version",
25+
"Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]"
26+
}
27+
},
28+
"Rules": {
29+
"CheckBootstrapVersion": {
30+
"Assertions": [
31+
{
32+
"Assert": {
33+
"Fn::Not": [
34+
{
35+
"Fn::Contains": [
36+
[
37+
"1",
38+
"2",
39+
"3",
40+
"4",
41+
"5"
42+
],
43+
{
44+
"Ref": "BootstrapVersion"
45+
}
46+
]
47+
}
48+
]
49+
},
50+
"AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI."
51+
}
52+
]
53+
}
54+
}
55+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"version":"30.0.0"}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"version": "30.0.0",
3+
"files": {
4+
"21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22": {
5+
"source": {
6+
"path": "cdkintegdashboardwithgraphwidgetwithannotationsDefaultTestDeployAssertD4707D74.template.json",
7+
"packaging": "file"
8+
},
9+
"destinations": {
10+
"current_account-current_region": {
11+
"bucketName": "cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}",
12+
"objectKey": "21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22.json",
13+
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-file-publishing-role-${AWS::AccountId}-${AWS::Region}"
14+
}
15+
}
16+
}
17+
},
18+
"dockerImages": {}
19+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{
2+
"Parameters": {
3+
"BootstrapVersion": {
4+
"Type": "AWS::SSM::Parameter::Value<String>",
5+
"Default": "/cdk-bootstrap/hnb659fds/version",
6+
"Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]"
7+
}
8+
},
9+
"Rules": {
10+
"CheckBootstrapVersion": {
11+
"Assertions": [
12+
{
13+
"Assert": {
14+
"Fn::Not": [
15+
{
16+
"Fn::Contains": [
17+
[
18+
"1",
19+
"2",
20+
"3",
21+
"4",
22+
"5"
23+
],
24+
{
25+
"Ref": "BootstrapVersion"
26+
}
27+
]
28+
}
29+
]
30+
},
31+
"AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI."
32+
}
33+
]
34+
}
35+
}
36+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
{
2+
"version": "30.0.0",
3+
"testCases": {
4+
"cdk-integ-dashboard-with-graph-widget-with-annotations/DefaultTest": {
5+
"stacks": [
6+
"DashboardWithGraphWidgetWithAnnotationsIntegrationTest"
7+
],
8+
"assertionStack": "cdk-integ-dashboard-with-graph-widget-with-annotations/DefaultTest/DeployAssert",
9+
"assertionStackName": "cdkintegdashboardwithgraphwidgetwithannotationsDefaultTestDeployAssertD4707D74"
10+
}
11+
}
12+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
{
2+
"version": "30.0.0",
3+
"artifacts": {
4+
"DashboardWithGraphWidgetWithAnnotationsIntegrationTest.assets": {
5+
"type": "cdk:asset-manifest",
6+
"properties": {
7+
"file": "DashboardWithGraphWidgetWithAnnotationsIntegrationTest.assets.json",
8+
"requiresBootstrapStackVersion": 6,
9+
"bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version"
10+
}
11+
},
12+
"DashboardWithGraphWidgetWithAnnotationsIntegrationTest": {
13+
"type": "aws:cloudformation:stack",
14+
"environment": "aws://unknown-account/unknown-region",
15+
"properties": {
16+
"templateFile": "DashboardWithGraphWidgetWithAnnotationsIntegrationTest.template.json",
17+
"validateOnSynth": false,
18+
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-deploy-role-${AWS::AccountId}-${AWS::Region}",
19+
"cloudFormationExecutionRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-cfn-exec-role-${AWS::AccountId}-${AWS::Region}",
20+
"stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/fa0b1fe0c3043238b7413b794c626bac246c94f150aa6e3ff441a030d7dce521.json",
21+
"requiresBootstrapStackVersion": 6,
22+
"bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version",
23+
"additionalDependencies": [
24+
"DashboardWithGraphWidgetWithAnnotationsIntegrationTest.assets"
25+
],
26+
"lookupRole": {
27+
"arn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-lookup-role-${AWS::AccountId}-${AWS::Region}",
28+
"requiresBootstrapStackVersion": 8,
29+
"bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version"
30+
}
31+
},
32+
"dependencies": [
33+
"DashboardWithGraphWidgetWithAnnotationsIntegrationTest.assets"
34+
],
35+
"metadata": {
36+
"/DashboardWithGraphWidgetWithAnnotationsIntegrationTest/Dash/Resource": [
37+
{
38+
"type": "aws:cdk:logicalId",
39+
"data": "DashCCD7F836"
40+
}
41+
],
42+
"/DashboardWithGraphWidgetWithAnnotationsIntegrationTest/BootstrapVersion": [
43+
{
44+
"type": "aws:cdk:logicalId",
45+
"data": "BootstrapVersion"
46+
}
47+
],
48+
"/DashboardWithGraphWidgetWithAnnotationsIntegrationTest/CheckBootstrapVersion": [
49+
{
50+
"type": "aws:cdk:logicalId",
51+
"data": "CheckBootstrapVersion"
52+
}
53+
]
54+
},
55+
"displayName": "DashboardWithGraphWidgetWithAnnotationsIntegrationTest"
56+
},
57+
"cdkintegdashboardwithgraphwidgetwithannotationsDefaultTestDeployAssertD4707D74.assets": {
58+
"type": "cdk:asset-manifest",
59+
"properties": {
60+
"file": "cdkintegdashboardwithgraphwidgetwithannotationsDefaultTestDeployAssertD4707D74.assets.json",
61+
"requiresBootstrapStackVersion": 6,
62+
"bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version"
63+
}
64+
},
65+
"cdkintegdashboardwithgraphwidgetwithannotationsDefaultTestDeployAssertD4707D74": {
66+
"type": "aws:cloudformation:stack",
67+
"environment": "aws://unknown-account/unknown-region",
68+
"properties": {
69+
"templateFile": "cdkintegdashboardwithgraphwidgetwithannotationsDefaultTestDeployAssertD4707D74.template.json",
70+
"validateOnSynth": false,
71+
"assumeRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-deploy-role-${AWS::AccountId}-${AWS::Region}",
72+
"cloudFormationExecutionRoleArn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-cfn-exec-role-${AWS::AccountId}-${AWS::Region}",
73+
"stackTemplateAssetObjectUrl": "s3://cdk-hnb659fds-assets-${AWS::AccountId}-${AWS::Region}/21fbb51d7b23f6a6c262b46a9caee79d744a3ac019fd45422d988b96d44b2a22.json",
74+
"requiresBootstrapStackVersion": 6,
75+
"bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version",
76+
"additionalDependencies": [
77+
"cdkintegdashboardwithgraphwidgetwithannotationsDefaultTestDeployAssertD4707D74.assets"
78+
],
79+
"lookupRole": {
80+
"arn": "arn:${AWS::Partition}:iam::${AWS::AccountId}:role/cdk-hnb659fds-lookup-role-${AWS::AccountId}-${AWS::Region}",
81+
"requiresBootstrapStackVersion": 8,
82+
"bootstrapStackVersionSsmParameter": "/cdk-bootstrap/hnb659fds/version"
83+
}
84+
},
85+
"dependencies": [
86+
"cdkintegdashboardwithgraphwidgetwithannotationsDefaultTestDeployAssertD4707D74.assets"
87+
],
88+
"metadata": {
89+
"/cdk-integ-dashboard-with-graph-widget-with-annotations/DefaultTest/DeployAssert/BootstrapVersion": [
90+
{
91+
"type": "aws:cdk:logicalId",
92+
"data": "BootstrapVersion"
93+
}
94+
],
95+
"/cdk-integ-dashboard-with-graph-widget-with-annotations/DefaultTest/DeployAssert/CheckBootstrapVersion": [
96+
{
97+
"type": "aws:cdk:logicalId",
98+
"data": "CheckBootstrapVersion"
99+
}
100+
]
101+
},
102+
"displayName": "cdk-integ-dashboard-with-graph-widget-with-annotations/DefaultTest/DeployAssert"
103+
},
104+
"Tree": {
105+
"type": "cdk:tree",
106+
"properties": {
107+
"file": "tree.json"
108+
}
109+
}
110+
}
111+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
{
2+
"version": "tree-0.1",
3+
"tree": {
4+
"id": "App",
5+
"path": "",
6+
"children": {
7+
"DashboardWithGraphWidgetWithAnnotationsIntegrationTest": {
8+
"id": "DashboardWithGraphWidgetWithAnnotationsIntegrationTest",
9+
"path": "DashboardWithGraphWidgetWithAnnotationsIntegrationTest",
10+
"children": {
11+
"Dash": {
12+
"id": "Dash",
13+
"path": "DashboardWithGraphWidgetWithAnnotationsIntegrationTest/Dash",
14+
"children": {
15+
"Resource": {
16+
"id": "Resource",
17+
"path": "DashboardWithGraphWidgetWithAnnotationsIntegrationTest/Dash/Resource",
18+
"attributes": {
19+
"aws:cdk:cloudformation:type": "AWS::CloudWatch::Dashboard",
20+
"aws:cdk:cloudformation:props": {
21+
"dashboardBody": {
22+
"Fn::Join": [
23+
"",
24+
[
25+
"{\"widgets\":[{\"type\":\"metric\",\"width\":6,\"height\":6,\"x\":0,\"y\":0,\"properties\":{\"view\":\"timeSeries\",\"title\":\"My fancy graph\",\"region\":\"",
26+
{
27+
"Ref": "AWS::Region"
28+
},
29+
"\",\"metrics\":[[\"CDK/Test\",\"Metric\",{\"label\":\"Metric left 1 - p99\",\"stat\":\"p99\"}],[\"CDK/Test\",\"Metric\",{\"label\":\"Metric left 2 - TC_10P_90P\",\"stat\":\"TC(10%:90%)\"}],[\"CDK/Test\",\"Metric\",{\"label\":\"Metric left 3 - TS(5%:95%)\",\"stat\":\"TS(5%:95%)\"}],[\"CDK/Test\",\"Metric\",{\"label\":\"Metric right 1 - p90.1234\",\"stat\":\"p90.1234\",\"yAxis\":\"right\"}]],\"annotations\":{\"horizontal\":[{\"value\":10,\"label\":\"Left annotation\",\"color\":\"#00ff00\",\"fill\":\"above\",\"visible\":true,\"yAxis\":\"left\"},{\"value\":20,\"label\":\"Right annotation\",\"color\":\"#e30d0d\",\"fill\":\"below\",\"visible\":false,\"yAxis\":\"right\"}],\"vertical\":[{\"value\":\"2023-08-20T00:00:00.000Z\",\"label\":\"Vertical annotation\",\"color\":\"#2556f6\",\"fill\":\"after\",\"visible\":true}]},\"yAxis\":{}}}]}"
30+
]
31+
]
32+
}
33+
}
34+
},
35+
"constructInfo": {
36+
"fqn": "@aws-cdk/aws-cloudwatch.CfnDashboard",
37+
"version": "0.0.0"
38+
}
39+
}
40+
},
41+
"constructInfo": {
42+
"fqn": "@aws-cdk/aws-cloudwatch.Dashboard",
43+
"version": "0.0.0"
44+
}
45+
},
46+
"BootstrapVersion": {
47+
"id": "BootstrapVersion",
48+
"path": "DashboardWithGraphWidgetWithAnnotationsIntegrationTest/BootstrapVersion",
49+
"constructInfo": {
50+
"fqn": "@aws-cdk/core.CfnParameter",
51+
"version": "0.0.0"
52+
}
53+
},
54+
"CheckBootstrapVersion": {
55+
"id": "CheckBootstrapVersion",
56+
"path": "DashboardWithGraphWidgetWithAnnotationsIntegrationTest/CheckBootstrapVersion",
57+
"constructInfo": {
58+
"fqn": "@aws-cdk/core.CfnRule",
59+
"version": "0.0.0"
60+
}
61+
}
62+
},
63+
"constructInfo": {
64+
"fqn": "@aws-cdk/core.Stack",
65+
"version": "0.0.0"
66+
}
67+
},
68+
"cdk-integ-dashboard-with-graph-widget-with-annotations": {
69+
"id": "cdk-integ-dashboard-with-graph-widget-with-annotations",
70+
"path": "cdk-integ-dashboard-with-graph-widget-with-annotations",
71+
"children": {
72+
"DefaultTest": {
73+
"id": "DefaultTest",
74+
"path": "cdk-integ-dashboard-with-graph-widget-with-annotations/DefaultTest",
75+
"children": {
76+
"Default": {
77+
"id": "Default",
78+
"path": "cdk-integ-dashboard-with-graph-widget-with-annotations/DefaultTest/Default",
79+
"constructInfo": {
80+
"fqn": "constructs.Construct",
81+
"version": "10.1.252"
82+
}
83+
},
84+
"DeployAssert": {
85+
"id": "DeployAssert",
86+
"path": "cdk-integ-dashboard-with-graph-widget-with-annotations/DefaultTest/DeployAssert",
87+
"children": {
88+
"BootstrapVersion": {
89+
"id": "BootstrapVersion",
90+
"path": "cdk-integ-dashboard-with-graph-widget-with-annotations/DefaultTest/DeployAssert/BootstrapVersion",
91+
"constructInfo": {
92+
"fqn": "@aws-cdk/core.CfnParameter",
93+
"version": "0.0.0"
94+
}
95+
},
96+
"CheckBootstrapVersion": {
97+
"id": "CheckBootstrapVersion",
98+
"path": "cdk-integ-dashboard-with-graph-widget-with-annotations/DefaultTest/DeployAssert/CheckBootstrapVersion",
99+
"constructInfo": {
100+
"fqn": "@aws-cdk/core.CfnRule",
101+
"version": "0.0.0"
102+
}
103+
}
104+
},
105+
"constructInfo": {
106+
"fqn": "@aws-cdk/core.Stack",
107+
"version": "0.0.0"
108+
}
109+
}
110+
},
111+
"constructInfo": {
112+
"fqn": "@aws-cdk/integ-tests.IntegTestCase",
113+
"version": "0.0.0"
114+
}
115+
}
116+
},
117+
"constructInfo": {
118+
"fqn": "@aws-cdk/integ-tests.IntegTest",
119+
"version": "0.0.0"
120+
}
121+
},
122+
"Tree": {
123+
"id": "Tree",
124+
"path": "Tree",
125+
"constructInfo": {
126+
"fqn": "constructs.Construct",
127+
"version": "10.1.252"
128+
}
129+
}
130+
},
131+
"constructInfo": {
132+
"fqn": "@aws-cdk/core.App",
133+
"version": "0.0.0"
134+
}
135+
}
136+
}

0 commit comments

Comments
 (0)