@sylvesterllc/aws-constructs 1.1.62 → 1.1.63
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/publish.yml +9 -15
- package/__tests__/SpaCFRoute53.test.ts +80 -0
- package/bun.lock +1154 -0
- package/dist/constructs/SpaCFRoute53.d.ts +12 -0
- package/dist/constructs/SpaCFRoute53.js +103 -0
- package/dist/constructs/index.d.ts +1 -0
- package/dist/constructs/index.js +2 -1
- package/dist/helpers/ulid.d.ts +1 -0
- package/dist/helpers/ulid.js +17 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/interfaces/SpaProps.d.ts +7 -0
- package/dist/interfaces/SpaProps.js +3 -0
- package/dist/interfaces/lambda/index.d.ts +1 -1
- package/dist/interfaces/lambda/index.js +1 -1
- package/docs/SpaCFRoute53-usage.md +81 -0
- package/docs/spa-cf-construct-plan.md +111 -0
- package/package.json +7 -3
- package/readme.md +33 -0
- package/src/constructs/SpaCFRoute53.ts +151 -0
- package/src/constructs/index.ts +1 -0
- package/src/helpers/ulid.ts +13 -0
- package/src/index.ts +2 -2
- package/src/interfaces/SpaProps.ts +7 -0
- package/src/interfaces/lambda/index.ts +1 -1
|
@@ -16,38 +16,32 @@ jobs:
|
|
|
16
16
|
id-token: write # for provenance (optional)
|
|
17
17
|
steps:
|
|
18
18
|
- uses: actions/checkout@v4
|
|
19
|
-
-
|
|
19
|
+
- name: Setup Bun
|
|
20
|
+
uses: oven-sh/setup-bun@v1
|
|
20
21
|
with:
|
|
21
|
-
version:
|
|
22
|
+
bun-version: latest
|
|
22
23
|
- name: Setup Node
|
|
23
24
|
uses: actions/setup-node@v4
|
|
24
25
|
with:
|
|
25
|
-
node-version: "
|
|
26
|
-
|
|
26
|
+
node-version: "24.x"
|
|
27
|
+
# Note: actions/setup-node does not support bun caching
|
|
27
28
|
- name: Configure .npmrc for npm registry
|
|
28
29
|
run: |
|
|
29
30
|
cat > ~/.npmrc << EOF
|
|
30
31
|
//registry.npmjs.org/:_authToken=${{ secrets.NPM_REGISTRY_TOKEN }}
|
|
31
32
|
registry=https://registry.npmjs.org/
|
|
32
33
|
EOF
|
|
33
|
-
- name: Install dependencies
|
|
34
|
-
run:
|
|
35
|
-
if [ -f pnpm-lock.yaml ]; then
|
|
36
|
-
echo "Found pnpm-lock.yaml; using --frozen-lockfile"
|
|
37
|
-
pnpm install --frozen-lockfile
|
|
38
|
-
else
|
|
39
|
-
echo "No pnpm-lock.yaml present; performing regular install"
|
|
40
|
-
pnpm install
|
|
41
|
-
fi
|
|
34
|
+
- name: Install dependencies (bun)
|
|
35
|
+
run: bun install
|
|
42
36
|
- name: Verify npm auth & scope
|
|
43
37
|
run: |
|
|
44
38
|
npm whoami || { echo 'Not authenticated'; exit 1; }
|
|
45
39
|
npm ping
|
|
46
40
|
echo "Publishing package version $(jq -r '.version' package.json)"
|
|
47
41
|
- name: Run tests
|
|
48
|
-
run:
|
|
42
|
+
run: bun run test -- --passWithNoTests
|
|
49
43
|
- name: Build
|
|
50
|
-
run:
|
|
44
|
+
run: bun run build
|
|
51
45
|
- name: Guard against duplicate version
|
|
52
46
|
run: |
|
|
53
47
|
V=$(jq -r '.version' package.json)
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { App, Stack } from "aws-cdk-lib";
|
|
2
|
+
import { SpaCFRoute53 } from "../src/constructs/SpaCFRoute53";
|
|
3
|
+
import { SpaProps } from "../src/interfaces/SpaProps";
|
|
4
|
+
import { Template } from "aws-cdk-lib/assertions";
|
|
5
|
+
|
|
6
|
+
describe("SpaCFRoute53", () => {
|
|
7
|
+
const props: SpaProps = {
|
|
8
|
+
siteName: "testsite",
|
|
9
|
+
bucketName: "testsite-bucket-unique",
|
|
10
|
+
cloudfrontName: "testsite-cf",
|
|
11
|
+
domainName: "example.com",
|
|
12
|
+
fqdn: "spa.example.com",
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
it("provisions a private, versioned, encrypted S3 bucket with access logging", () => {
|
|
16
|
+
const app = new App();
|
|
17
|
+
const stack = new Stack(app, "TestStack");
|
|
18
|
+
new SpaCFRoute53(stack, "SpaCFRoute53", props);
|
|
19
|
+
const template = Template.fromStack(stack);
|
|
20
|
+
template.hasResourceProperties("AWS::S3::Bucket", {
|
|
21
|
+
BucketName: props.bucketName,
|
|
22
|
+
VersioningConfiguration: { Status: "Enabled" },
|
|
23
|
+
BucketEncryption: {
|
|
24
|
+
ServerSideEncryptionConfiguration: [
|
|
25
|
+
{ ServerSideEncryptionByDefault: { SSEAlgorithm: "AES256" } },
|
|
26
|
+
],
|
|
27
|
+
},
|
|
28
|
+
PublicAccessBlockConfiguration: {
|
|
29
|
+
BlockPublicAcls: true,
|
|
30
|
+
BlockPublicPolicy: true,
|
|
31
|
+
IgnorePublicAcls: true,
|
|
32
|
+
RestrictPublicBuckets: true,
|
|
33
|
+
},
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it("provisions a logs bucket with 14-day retention", () => {
|
|
38
|
+
const app = new App();
|
|
39
|
+
const stack = new Stack(app, "TestStack");
|
|
40
|
+
new SpaCFRoute53(stack, "SpaCFRoute53", props);
|
|
41
|
+
const template = Template.fromStack(stack);
|
|
42
|
+
template.hasResourceProperties("AWS::S3::Bucket", {
|
|
43
|
+
LifecycleConfiguration: {
|
|
44
|
+
Rules: [{ Status: "Enabled", ExpirationInDays: 14 }],
|
|
45
|
+
},
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
it("provisions a CloudFront distribution with TLS 1.3, GET/HEAD only, and SPA error routing", () => {
|
|
50
|
+
const app = new App();
|
|
51
|
+
const stack = new Stack(app, "TestStack");
|
|
52
|
+
new SpaCFRoute53(stack, "SpaCFRoute53", props);
|
|
53
|
+
const template = Template.fromStack(stack);
|
|
54
|
+
template.hasResourceProperties("AWS::CloudFront::Distribution", {
|
|
55
|
+
DistributionConfig: {
|
|
56
|
+
Aliases: [props.fqdn],
|
|
57
|
+
DefaultRootObject: "index.html",
|
|
58
|
+
ViewerCertificate: {
|
|
59
|
+
MinimumProtocolVersion: "TLSv1.3_2021",
|
|
60
|
+
},
|
|
61
|
+
DefaultCacheBehavior: {
|
|
62
|
+
AllowedMethods: ["GET", "HEAD"],
|
|
63
|
+
ViewerProtocolPolicy: "redirect-to-https",
|
|
64
|
+
},
|
|
65
|
+
CustomErrorResponses: [
|
|
66
|
+
{
|
|
67
|
+
ErrorCode: 403,
|
|
68
|
+
ResponseCode: 200,
|
|
69
|
+
ResponsePagePath: "/index.html",
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
ErrorCode: 404,
|
|
73
|
+
ResponseCode: 200,
|
|
74
|
+
ResponsePagePath: "/index.html",
|
|
75
|
+
},
|
|
76
|
+
],
|
|
77
|
+
},
|
|
78
|
+
});
|
|
79
|
+
});
|
|
80
|
+
});
|