Skip to content

Commit 8e115db

Browse files
feat(cloudfront): retrieve default distribution metrics (#28894)
This PR implements functions to retrieve [default distribution metrics](https://docs.aws.amazon.com/AmazonCloudFront/latest/DeveloperGuide/viewing-cloudfront-metrics.html). ```ts declare const dist: cloudfront.Distribution const metric = dist.metricRequests() ``` Closes #28893 ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent 5a68f59 commit 8e115db

File tree

12 files changed

+941
-7
lines changed

12 files changed

+941
-7
lines changed

packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-default-metrics.js.snapshot/MyTestDefaultTestDeployAssertB8AA280E.assets.json

+19
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-default-metrics.js.snapshot/MyTestDefaultTestDeployAssertB8AA280E.template.json

+36
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-default-metrics.js.snapshot/MyTestStack.assets.json

+19
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,183 @@
1+
{
2+
"Resources": {
3+
"DistB3B78991": {
4+
"Type": "AWS::CloudFront::Distribution",
5+
"Properties": {
6+
"DistributionConfig": {
7+
"DefaultCacheBehavior": {
8+
"CachePolicyId": "658327ea-f89d-4fab-a63d-7e88639e58f6",
9+
"Compress": true,
10+
"TargetOriginId": "MyTestStackDistOrigin1CBA48A7B",
11+
"ViewerProtocolPolicy": "allow-all"
12+
},
13+
"Enabled": true,
14+
"HttpVersion": "http2",
15+
"IPV6Enabled": true,
16+
"Origins": [
17+
{
18+
"CustomOriginConfig": {
19+
"OriginProtocolPolicy": "https-only"
20+
},
21+
"DomainName": "www.example.com",
22+
"Id": "MyTestStackDistOrigin1CBA48A7B"
23+
}
24+
]
25+
}
26+
}
27+
},
28+
"Alarm1F9009D71": {
29+
"Type": "AWS::CloudWatch::Alarm",
30+
"Properties": {
31+
"ComparisonOperator": "GreaterThanThreshold",
32+
"Dimensions": [
33+
{
34+
"Name": "DistributionId",
35+
"Value": {
36+
"Ref": "DistB3B78991"
37+
}
38+
}
39+
],
40+
"EvaluationPeriods": 1,
41+
"MetricName": "Requests",
42+
"Namespace": "AWS/CloudFront",
43+
"Period": 300,
44+
"Statistic": "Sum",
45+
"Threshold": 1
46+
}
47+
},
48+
"Alarm2A7122E13": {
49+
"Type": "AWS::CloudWatch::Alarm",
50+
"Properties": {
51+
"ComparisonOperator": "GreaterThanThreshold",
52+
"Dimensions": [
53+
{
54+
"Name": "DistributionId",
55+
"Value": {
56+
"Ref": "DistB3B78991"
57+
}
58+
}
59+
],
60+
"EvaluationPeriods": 1,
61+
"MetricName": "BytesUploaded",
62+
"Namespace": "AWS/CloudFront",
63+
"Period": 300,
64+
"Statistic": "Sum",
65+
"Threshold": 1
66+
}
67+
},
68+
"Alarm32341D8D9": {
69+
"Type": "AWS::CloudWatch::Alarm",
70+
"Properties": {
71+
"ComparisonOperator": "GreaterThanThreshold",
72+
"Dimensions": [
73+
{
74+
"Name": "DistributionId",
75+
"Value": {
76+
"Ref": "DistB3B78991"
77+
}
78+
}
79+
],
80+
"EvaluationPeriods": 1,
81+
"MetricName": "BytesDownloaded",
82+
"Namespace": "AWS/CloudFront",
83+
"Period": 300,
84+
"Statistic": "Sum",
85+
"Threshold": 1
86+
}
87+
},
88+
"Alarm4671832C8": {
89+
"Type": "AWS::CloudWatch::Alarm",
90+
"Properties": {
91+
"ComparisonOperator": "GreaterThanThreshold",
92+
"Dimensions": [
93+
{
94+
"Name": "DistributionId",
95+
"Value": {
96+
"Ref": "DistB3B78991"
97+
}
98+
}
99+
],
100+
"EvaluationPeriods": 1,
101+
"MetricName": "4xxErrorRate",
102+
"Namespace": "AWS/CloudFront",
103+
"Period": 300,
104+
"Statistic": "Average",
105+
"Threshold": 1
106+
}
107+
},
108+
"Alarm548383B2F": {
109+
"Type": "AWS::CloudWatch::Alarm",
110+
"Properties": {
111+
"ComparisonOperator": "GreaterThanThreshold",
112+
"Dimensions": [
113+
{
114+
"Name": "DistributionId",
115+
"Value": {
116+
"Ref": "DistB3B78991"
117+
}
118+
}
119+
],
120+
"EvaluationPeriods": 1,
121+
"MetricName": "5xxErrorRate",
122+
"Namespace": "AWS/CloudFront",
123+
"Period": 300,
124+
"Statistic": "Average",
125+
"Threshold": 1
126+
}
127+
},
128+
"Alarm65738D89F": {
129+
"Type": "AWS::CloudWatch::Alarm",
130+
"Properties": {
131+
"ComparisonOperator": "GreaterThanThreshold",
132+
"Dimensions": [
133+
{
134+
"Name": "DistributionId",
135+
"Value": {
136+
"Ref": "DistB3B78991"
137+
}
138+
}
139+
],
140+
"EvaluationPeriods": 1,
141+
"MetricName": "TotalErrorRate",
142+
"Namespace": "AWS/CloudFront",
143+
"Period": 300,
144+
"Statistic": "Average",
145+
"Threshold": 1
146+
}
147+
}
148+
},
149+
"Parameters": {
150+
"BootstrapVersion": {
151+
"Type": "AWS::SSM::Parameter::Value<String>",
152+
"Default": "/cdk-bootstrap/hnb659fds/version",
153+
"Description": "Version of the CDK Bootstrap resources in this environment, automatically retrieved from SSM Parameter Store. [cdk:skip]"
154+
}
155+
},
156+
"Rules": {
157+
"CheckBootstrapVersion": {
158+
"Assertions": [
159+
{
160+
"Assert": {
161+
"Fn::Not": [
162+
{
163+
"Fn::Contains": [
164+
[
165+
"1",
166+
"2",
167+
"3",
168+
"4",
169+
"5"
170+
],
171+
{
172+
"Ref": "BootstrapVersion"
173+
}
174+
]
175+
}
176+
]
177+
},
178+
"AssertDescription": "CDK bootstrap stack version 6 required. Please run 'cdk bootstrap' with a recent version of the CDK CLI."
179+
}
180+
]
181+
}
182+
}
183+
}

packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-default-metrics.js.snapshot/cdk.out

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk-testing/framework-integ/test/aws-cloudfront/test/integ.distribution-default-metrics.js.snapshot/integ.json

+12
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)