Skip to content

Commit

Permalink
allow priceClass to be specified for sites
Browse files Browse the repository at this point in the history
  • Loading branch information
joshbalfour committed Aug 3, 2023
1 parent 71cedce commit 0718275
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
2 changes: 2 additions & 0 deletions packages/ts-scripts/src/cdk/components/multi-region-site.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { PriceClass } from 'aws-cdk-lib/aws-cloudfront'
import { Stack } from '../index'
import { CreateSiteInterface, createSite } from './site'
import {
Expand Down Expand Up @@ -64,6 +65,7 @@ export const createMultiRegionSite = async (stack: cdk.Stack, props: MultiRegion
const { distribution } = await createSite(stack, {
...props,
viewerCertificateOverride,
priceClass: PriceClass.PRICE_CLASS_ALL,
})

const auArecordStack = new cdk.Stack(certStack, 'arecord', {
Expand Down
10 changes: 9 additions & 1 deletion packages/ts-scripts/src/cdk/components/site.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export interface CreateSiteInterface {
defaultRootObject?: string
location: string
viewerCertificateOverride?: cloudfront.ViewerCertificate
priceClass?: cloudfront.PriceClass
}

const findCert = async (stack: Stack, domain: string): Promise<ICertificate> => {
Expand Down Expand Up @@ -49,7 +50,13 @@ const findCert = async (stack: Stack, domain: string): Promise<ICertificate> =>

export const createSite = async (
stack: Stack,
{ defaultRootObject = 'index.html', env = 'dev', location, viewerCertificateOverride }: CreateSiteInterface,
{
defaultRootObject = 'index.html',
env = 'dev',
location,
viewerCertificateOverride,
priceClass,
}: CreateSiteInterface,
) => {
const stackNamePieces = stack.stackName.split('-')
stackNamePieces.pop()
Expand Down Expand Up @@ -99,6 +106,7 @@ export const createSite = async (
},
],
defaultRootObject,
priceClass,
viewerCertificate:
viewerCertificateOverride ||
cloudfront.ViewerCertificate.fromAcmCertificate(certificate, {
Expand Down

0 comments on commit 0718275

Please sign in to comment.