Skip to content

Instantly share code, notes, and snippets.

@apoorvmote
Created February 24, 2021 12:13
Show Gist options
  • Save apoorvmote/3adbdadb77963a07b9651f43c50328e0 to your computer and use it in GitHub Desktop.
Save apoorvmote/3adbdadb77963a07b9651f43c50328e0 to your computer and use it in GitHub Desktop.
import { HostedZone } from '@aws-cdk/aws-route53';
import { HttpsRedirect } from '@aws-cdk/aws-route53-patterns';
import * as cdk from '@aws-cdk/core';
export class HttpsRedirectStack extends cdk.Stack {
constructor(scope: cdk.Construct, id: string, props?: cdk.StackProps) {
super(scope, id, props);
// The code that defines your stack goes here
const hostedZone = HostedZone.fromHostedZoneAttributes(this, 'HostedZoneWithAttrs', {
hostedZoneId: 'myZoneId',
zoneName: 'example.com'
})
new HttpsRedirect(this, 'wwwToNonWww', {
recordNames: ['www.example.com'],
targetDomain: 'example.com',
zone: hostedZone
})
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment