Ivan Roskoshnyi
04/19/2022, 6:37 PMaws-amplify
but getting CORS
error. On the docs I have found this info only:
this.auth.attachPermissionsForAuthUsers([
// Allow access to the API
api,
// Policy granting access to a specific folder in the bucket
new iam.PolicyStatement({
actions: ["s3:*"],
effect: iam.Effect.ALLOW,
resources: [
bucket.bucketArn + "/private/${<http://cognito-identity.amazonaws.com:sub|cognito-identity.amazonaws.com:sub>}/*",
],
}),
]);
Ross Coundon
04/19/2022, 7:10 PMbucket.s3Bucket.addCorsRule( {
allowedMethods: [HttpMethods.GET, HttpMethods.PUT],
allowedOrigins: ['*'],
allowedHeaders: ['*'],
});
Ivan Roskoshnyi
04/19/2022, 8:12 PMHttpMethods
module from?Ross Coundon
04/19/2022, 8:13 PMimport { BlockPublicAccess, BucketAccessControl, EventType, HttpMethods } from 'aws-cdk-lib/aws-s3';
Ivan Roskoshnyi
04/19/2022, 8:22 PMFrank
v1.0.0-beta.22
Frank
new Bucket(stack, "Bucket", {
cors: [
{
allowedMethods: ["GET"],
allowedOrigins: ["<https://www.example.com>"],
}
],
});
No need to import HttpMethods
Frank
Ross Coundon
04/21/2022, 8:12 AMFrank
new Bucket(stack, "Bucket", {
cdk: {
bucket: { ...all cdk.s3.Bucket's props... }
}
});
And if we notice some prop is getting frequently used, we lift it to the top, ie.
new Bucket(stack, "Bucket", {
cors: { ... },
cdk: {
bucket: { ...all cdk.s3.Bucket's props... }
}
});
Frank
Ross Coundon
04/21/2022, 8:16 AM