Skip to content

Commit

Permalink
feat: disabling public access block before adding policy
Browse files Browse the repository at this point in the history
  • Loading branch information
guicostaarantes committed May 1, 2023
1 parent 688f524 commit 2ee9721
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ublend-npm/serverless-website-component",
"version": "0.0.16",
"version": "0.0.17",
"main": "./serverless.js",
"publishConfig": {
"access": "public"
Expand Down
14 changes: 14 additions & 0 deletions utils.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
const { utils } = require('@serverless/core')

const configureBucketForHosting = async (s3, bucketName) => {
const publicAccessBlockConfig = {
BlockPublicAcls: false,
BlockPublicPolicy: false,
IgnorePublicAcls: false,
RestrictPublicBuckets: false
}

const s3BucketPolicy = {
Version: '2012-10-17',
Statement: [
Expand Down Expand Up @@ -41,6 +48,13 @@ const configureBucketForHosting = async (s3, bucketName) => {
}

try {
await s3
.putPublicAccessBlock({
Bucket: bucketName,
PublicAccessBlockConfiguration: JSON.stringify(publicAccessBlockConfig)
})
.promise()

await s3
.putBucketPolicy({
Bucket: bucketName,
Expand Down

0 comments on commit 2ee9721

Please sign in to comment.