Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
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
export class StaticWebsiteStack extends Stack { | |
public readonly siteBucket: s3.Bucket; | |
public readonly logBucket: s3.Bucket; | |
public readonly cloudfrontOAI: cloudfront.OriginAccessIdentity; | |
constructor(parent: Construct, id: string, props: StaticWebsiteStackProps) { | |
super(parent, id, props); | |
// Create a new S3 bucket for logs with a lifecycle rule | |
this.logBucket = new s3.Bucket(this, 'logBucket', { |
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
#!/usr/bin/env node | |
import * as cdk from 'aws-cdk-lib'; | |
import { HostedZone } from '../lib/hosted-zone'; | |
/** | |
* This stack relies on getting the domain name from CDK context. | |
* Use 'cdk synth -c domain=mystaticsite.com -c subdomain=www' | |
* Or add the following to cdk.json: | |
* { | |
* "context": { |
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
import { aws_route53 as route53 } from 'aws-cdk-lib'; | |
import { CfnOutput, Stack } from 'aws-cdk-lib'; | |
import { Construct } from 'constructs'; | |
export interface HostedZoneProps { | |
domainName: string; | |
description: string; | |
} | |
export class HostedZone extends Construct { |
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
// CloudFront distribution | |
const distribution = new Distribution(this, 'SiteDistribution', { | |
certificate: certificate, | |
defaultRootObject: "index.html", | |
domainNames: [siteDomain], | |
minimumProtocolVersion: SecurityPolicyProtocol.TLS_V1_2_2021, | |
errorResponses:[ | |
{ | |
httpStatus: 403, | |
responseHttpStatus: 403, |
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
// inside the StaticWebsite class | |
// Content bucket | |
this.siteBucket = new s3.Bucket(this, 'SiteBucket', { | |
bucketName: props.domainName, | |
publicReadAccess: false, | |
blockPublicAccess: s3.BlockPublicAccess.BLOCK_ALL, | |
/** | |
* The default removal policy is RETAIN, which means that cdk destroy will not attempt to delete |
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
interface SlackChannel { | |
readonly name: string; | |
readonly id: string; | |
} | |
interface SlackBotProps { | |
readonly workspaceId: string; | |
readonly channel: SlackChannel; | |
readonly topics: ReadonlyArray<ITopic>; | |
} |
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
private generateAnomalyBandVolumeExpression = (metric: Metric) : MathExpression => new MathExpression({ | |
// this expression compares metric value with CloudWatch anomaly detection lower band | |
usingMetrics: { | |
["m1"]: metric, | |
}, | |
expression: `IF(m1 < FIRST(ANOMALY_DETECTION_BAND(m1, 2)), 1, 0)`, | |
label: `${metric.metricName} Anomaly Detection Volume Below Trend`, | |
}, | |
); |
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
createAnomalyAlarm(scope: cdk.Construct, jobName: string, pascalName: string, alarmActions: string[]): CfnAlarm { | |
// The job name is used to match job metrics and alarms | |
return new CfnAlarm(this, `${jobName}ExecutionTimeAlarm`, { | |
alarmName: `${jobName}-execution-time`, | |
comparisonOperator: 'GreaterThanUpperThreshold', | |
datapointsToAlarm: 1, | |
evaluationPeriods: 1, | |
metrics: [ | |
{ | |
id: pascalName, |
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
NewerOlder