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/fixing merge conflicts #1115

Merged
merged 6 commits into from
Oct 17, 2023
Merged
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
23 changes: 14 additions & 9 deletions packages/static-hosting/lib/static-hosting.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
IResponseHeadersPolicy,
LambdaEdgeEventType,
OriginAccessIdentity,
IDistribution,
} from "aws-cdk-lib/aws-cloudfront";
import { HttpOrigin, S3Origin } from "aws-cdk-lib/aws-cloudfront-origins";
import {
Expand All @@ -37,6 +38,7 @@
Bucket,
BucketEncryption,
BucketProps,
IBucket,
} from "aws-cdk-lib/aws-s3";
import { CSP } from "../types/csp";
import { PathRemapFunction } from "./path-remap";
Expand Down Expand Up @@ -119,6 +121,9 @@
type Writeable<T> = { -readonly [P in keyof T]: T[P] };

export class StaticHosting extends Construct {
public readonly distribution: IDistribution;
public readonly bucket: IBucket;

private staticFiles = [
"js",
"css",
Expand Down Expand Up @@ -172,7 +177,7 @@
});
}

const bucket = new Bucket(this, "ContentBucket", {
this.bucket = new Bucket(this, "ContentBucket", {
bucketName: siteName,
encryption: BucketEncryption.S3_MANAGED,
blockPublicAccess: BlockPublicAccess.BLOCK_ALL,
Expand All @@ -185,11 +190,11 @@
comment: "Allow CloudFront to access S3",
});

bucket.grantRead(oai);
this.bucket.grantRead(oai);

new CfnOutput(this, "Bucket", {
description: "BucketName",
value: bucket.bucketName,
value: this.bucket.bucketName,
exportName: `${exportPrefix}BucketName`,
});

Expand All @@ -212,7 +217,7 @@
: undefined;

if (publisherGroup) {
bucket.grantReadWrite(publisherGroup);
this.bucket.grantReadWrite(publisherGroup);

new CfnOutput(this, "PublisherGroupName", {
description: "PublisherGroup",
Expand Down Expand Up @@ -245,7 +250,7 @@
});
}

const s3Origin = new S3Origin(bucket, {
const s3Origin = new S3Origin(this.bucket, {
originAccessIdentity: oai,
});
let backendOrigin = undefined;
Expand Down Expand Up @@ -394,11 +399,11 @@
"cloudfront:ListInvalidations",
],
resources: [
`arn:aws:cloudfront::*:distribution/${distribution.distributionId}`,
`arn:aws:cloudfront::*:distribution/${this.distribution.distributionId}`,
],
});

const cloudFrontInvalidationPolicy = new Policy(

Check warning on line 406 in packages/static-hosting/lib/static-hosting.ts

View workflow job for this annotation

GitHub Actions / build

'cloudFrontInvalidationPolicy' is assigned a value but never used. Allowed unused vars must match /^_/u
this,
"CloudFrontInvalidationPolicy",
{
Expand All @@ -409,12 +414,12 @@
}
new CfnOutput(this, "DistributionId", {
description: "DistributionId",
value: distribution.distributionId,
value: this.distribution.distributionId,
exportName: `${exportPrefix}DistributionID`,
});
new CfnOutput(this, "DistributionDomainName", {
description: "DistributionDomainName",
value: distribution.distributionDomainName,
value: this.distribution.distributionDomainName,
exportName: `${exportPrefix}DistributionName`,
});

Expand All @@ -425,7 +430,7 @@

new ARecord(this, "SiteAliasRecord", {
recordName: siteName,
target: RecordTarget.fromAlias(new CloudFrontTarget(distribution)),
target: RecordTarget.fromAlias(new CloudFrontTarget(this.distribution)),
zone: zone,
});
}
Expand Down
Loading