Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: use Origin Access Control for CloudFront Distribution + S3 #659

Merged
merged 2 commits into from
Dec 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 1 addition & 24 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,27 +45,4 @@ jobs:
run: |
npm ci
npm run test
working-directory: infrastructure

lint:
name: Lint
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Setup Node and Caching
uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
cache: "npm"
cache-dependency-path: infrastructure/package-lock.json

- name: Build React project
run: |
npm ci
npm run lint
working-directory: prototype



working-directory: infrastructure
4 changes: 2 additions & 2 deletions infrastructure/lib/constructs/spa-website/spa-website.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import * as cf from "aws-cdk-lib/aws-cloudfront";
import * as acm from "aws-cdk-lib/aws-certificatemanager";
import { Duration, RemovalPolicy } from "aws-cdk-lib";
import * as route53 from "aws-cdk-lib/aws-route53";
import { S3Origin } from "aws-cdk-lib/aws-cloudfront-origins";
import { S3BucketOrigin, S3Origin } from "aws-cdk-lib/aws-cloudfront-origins";
import { CloudFrontTarget } from "aws-cdk-lib/aws-route53-targets";

export interface ISpaWebsite {
Expand Down Expand Up @@ -118,7 +118,7 @@ export class SpaWebsite extends Construct implements ISpaWebsite {

this.spaDistribution = new cf.Distribution(this, 'SpaDistribution', {
defaultBehavior: {
origin: new S3Origin(this.siteOriginBucket),
origin: S3BucketOrigin.withOriginAccessControl(this.siteOriginBucket),
allowedMethods: cf.AllowedMethods.ALLOW_GET_HEAD,
responseHeadersPolicy: new cf.ResponseHeadersPolicy(this, "ResponseHeader", {
securityHeadersBehavior: SpaWebsite.defaultResponseHeadersPolicy,
Expand Down
Loading