-
Notifications
You must be signed in to change notification settings - Fork 4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(acm): DaysToExpiry metric (#15424)
Adds a convenient method to obtain the `DaysToExpiry` metric for an AWS Certificates Manager Certificate, without having to craft it yourself. ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
- Loading branch information
1 parent
e61a5b8
commit ff044ed
Showing
7 changed files
with
95 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
32 changes: 32 additions & 0 deletions
32
packages/@aws-cdk/aws-certificatemanager/lib/certificate-base.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import * as cloudwatch from '@aws-cdk/aws-cloudwatch'; | ||
import { Statistic } from '@aws-cdk/aws-cloudwatch'; | ||
import { Duration, Resource } from '@aws-cdk/core'; | ||
import { ICertificate } from './certificate'; | ||
|
||
/** | ||
* Shared implementation details of ICertificate implementations. | ||
* | ||
* @internal | ||
*/ | ||
export abstract class CertificateBase extends Resource implements ICertificate { | ||
public abstract readonly certificateArn: string; | ||
|
||
/** | ||
* If the certificate is provisionned in a different region than the | ||
* containing stack, this should be the region in which the certificate lives | ||
* so we can correctly create `Metric` instances. | ||
*/ | ||
protected readonly region?: string; | ||
|
||
public metricDaysToExpiry(props?: cloudwatch.MetricOptions): cloudwatch.Metric { | ||
return new cloudwatch.Metric({ | ||
period: Duration.days(1), | ||
...props, | ||
dimensions: { CertificateArn: this.certificateArn }, | ||
metricName: 'DaysToExpiry', | ||
namespace: 'AWS/CertificateManager', | ||
region: this.region, | ||
statistic: Statistic.MINIMUM, | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters