|
1 | 1 | import { defineBackend } from "@aws-amplify/backend";
|
2 | 2 | import * as s3 from "aws-cdk-lib/aws-s3";
|
3 | 3 | import { auth } from "./auth/resource";
|
4 |
| -import { storage } from "./storage/resource"; |
| 4 | +import { firstBucket, secondBucket } from "./storage/resource"; |
5 | 5 |
|
6 | 6 | /**
|
7 | 7 | * @see https://docs.amplify.aws/react/build-a-backend/ to add storage, functions, and more
|
8 | 8 | */
|
9 | 9 | const backend = defineBackend({
|
10 | 10 | auth,
|
11 |
| - storage, |
| 11 | + firstBucket, |
| 12 | + secondBucket, |
12 | 13 | });
|
13 | 14 |
|
14 | 15 | // custom storage configurations
|
15 |
| -const s3Bucket = backend.storage.resources.bucket; |
| 16 | +const s3Bucket = backend.firstBucket.resources.bucket; |
16 | 17 | const cfnBucket = s3Bucket.node.defaultChild as s3.CfnBucket;
|
| 18 | +const s3SecondaryBucket = backend.secondBucket.resources.bucket; |
| 19 | +const cfnSecondaryBucket = s3SecondaryBucket.node.defaultChild as s3.CfnBucket; |
17 | 20 |
|
18 | 21 | cfnBucket.accelerateConfiguration = {
|
19 | 22 | accelerationStatus: "Enabled",
|
20 | 23 | };
|
21 | 24 |
|
| 25 | +cfnSecondaryBucket.accelerateConfiguration = { |
| 26 | + accelerationStatus: "Enabled", |
| 27 | +}; |
| 28 | + |
| 29 | +// required to add the metadata header, which amplify-backend does not support |
| 30 | +backend.firstBucket.resources.cfnResources.cfnBucket.corsConfiguration = { |
| 31 | + corsRules: [ |
| 32 | + { |
| 33 | + allowedHeaders: ["*"], |
| 34 | + allowedMethods: ["GET", "HEAD", "PUT", "POST", "DELETE"], |
| 35 | + allowedOrigins: ["*"], |
| 36 | + exposedHeaders: [ |
| 37 | + "x-amz-server-side-encryption", |
| 38 | + "x-amz-request-id", |
| 39 | + "x-amz-id-2", |
| 40 | + "ETag", |
| 41 | + "x-amz-meta-description", |
| 42 | + ], |
| 43 | + maxAge: 3000, |
| 44 | + }, |
| 45 | + ], |
| 46 | +}; |
| 47 | + |
22 | 48 | // required to add the metadata header, which amplify-backend does not support
|
23 |
| -backend.storage.resources.cfnResources.cfnBucket.corsConfiguration = { |
| 49 | +backend.secondBucket.resources.cfnResources.cfnBucket.corsConfiguration = { |
24 | 50 | corsRules: [
|
25 | 51 | {
|
26 | 52 | allowedHeaders: ["*"],
|
|
0 commit comments