Selo
05/26/2022, 5:28 PMFrank
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>}/*",
],
}),
]);
Here we are saying that users can only access files in this path /private/$userId/*
and the files are uploaded to here.Frank
/public
folder, and grant access to /public
, ie.
auth.attachPermissionsForAuthUsers([
...
// Policy granting access to the public folder in the bucket
new iam.PolicyStatement({
actions: ["s3:*"],
effect: iam.Effect.ALLOW,
resources: [bucket.bucketArn + "/public/*"],
}),
]);
Frank
Selo
05/26/2022, 10:32 PM