Skip to content

Commit 8e3186d

Browse files
feat: disabling public access block before adding policy
1 parent 688f524 commit 8e3186d

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@ublend-npm/serverless-website-component",
3-
"version": "0.0.16",
3+
"version": "0.0.18",
44
"main": "./serverless.js",
55
"publishConfig": {
66
"access": "public"

utils.js

+14
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
const { utils } = require('@serverless/core')
22

33
const configureBucketForHosting = async (s3, bucketName) => {
4+
const publicAccessBlockConfig = {
5+
BlockPublicAcls: false,
6+
BlockPublicPolicy: false,
7+
IgnorePublicAcls: false,
8+
RestrictPublicBuckets: false
9+
}
10+
411
const s3BucketPolicy = {
512
Version: '2012-10-17',
613
Statement: [
@@ -41,6 +48,13 @@ const configureBucketForHosting = async (s3, bucketName) => {
4148
}
4249

4350
try {
51+
await s3
52+
.putPublicAccessBlock({
53+
Bucket: bucketName,
54+
PublicAccessBlockConfiguration: publicAccessBlockConfig
55+
})
56+
.promise()
57+
4458
await s3
4559
.putBucketPolicy({
4660
Bucket: bucketName,

0 commit comments

Comments
 (0)