How to add S3 BucketPolicy with AWS CDK

0 votes

I wanna translate this CloudFormation piece into CDK:

Type: AWS::S3::BucketPolicy
Properties:
  Bucket:
    Ref: S3BucketImageUploadBuffer
  PolicyDocument:
    Version: "2012-10-17"
    Statement:
      Action:
        - s3:PutObject
        - s3:PutObjectAcl
      Effect: Allow
      Resource:
        - ...

Mar 8 in Others by Edureka
• 9,700 points
45 views

1 answer to this question.

0 votes
In AWS CDK, there are two ways to build a bucket policy:

utilise the addToResourcePolicy function on a Bucket class object.
Create an instance of the BucketPolicy class.
With the addToResourcePolicy method, we take an implicit approach: once we add a policy statement to the bucket, CDK constructs a bucket policy for us.

The second technique is explicit and a little easier to understand for the reader of our code.

This article's code may be found on GitHub.
Let's take a look at a real-life example of both. First, let's look at the addToResourcePolicy method:

lib/cdk-starter-s
answered Mar 9 by Edureka
• 8,820 points

Related Questions In Others

0 votes
0 answers

How to import existing VPC in aws cdk?

Hi I am working on aws cdk. ...READ MORE

Mar 9 in Others by Edureka
• 9,700 points
84 views
0 votes
1 answer

NodeJS Amazon AWS S3 getObject how to send file in API response to download

Server Side const aws = require('aws-sdk'); router.get('/getfilefroms3', async (req, ...READ MORE

answered Mar 24 in Others by Edureka
• 8,820 points
138 views
0 votes
1 answer
0 votes
1 answer

How to communicate gRPC example working with Node.js?

hi.. you can read below link, it ...READ MORE

answered Dec 2, 2019 in Others by Narendra Reddy Dalli
1,420 views
0 votes
1 answer
+1 vote
0 answers

How to split a number with coma betweeen two colunms

Jul 3, 2019 in Others by anonymous
162 views
0 votes
1 answer

how to install Amazon AWS Command Line Interface tools on Bamboo build agent.

Hi@Abhishek, You need to set the following parameters ...READ MORE

answered Apr 6, 2020 in Others by MD
• 95,340 points
678 views
0 votes
0 answers

How to add S3 BucketPolicy with AWS CDK?

I wanna translate this CloudFormation piece into ...READ MORE

Mar 11 in Others by Edureka
• 9,700 points
132 views
0 votes
1 answer

How to install a GUI on Amazon AWS EC2 or EMR with the Amazon AMI

The top-level script for installing the GUI ...READ MORE

answered Mar 9 in Others by Edureka
• 8,820 points
32 views
0 votes
1 answer

How to use AWS S3 CLI to dump files to stdout in BASH?

All file objects must have their contents ...READ MORE

answered Mar 24 in Others by Edureka
• 8,820 points
183 views
webinar REGISTER FOR FREE WEBINAR X
Send OTP
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP