0% found this document useful (0 votes)
249 views4 pages

AWS S3 Interview Questions

Amazon S3 is an object storage service that provides scalable, available, and secure storage. Objects and buckets are used to store data, with objects contained within buckets. S3 uses an object storage model, and the AWS SDK and spring-cloud-starter-aws dependency can be used to access S3 from Spring Boot applications. Common operations include listing, creating, uploading to, and deleting buckets and objects.

Uploaded by

Harsha Kasireddy
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
249 views4 pages

AWS S3 Interview Questions

Amazon S3 is an object storage service that provides scalable, available, and secure storage. Objects and buckets are used to store data, with objects contained within buckets. S3 uses an object storage model, and the AWS SDK and spring-cloud-starter-aws dependency can be used to access S3 from Spring Boot applications. Common operations include listing, creating, uploading to, and deleting buckets and objects.

Uploaded by

Harsha Kasireddy
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

AWS S3 Interview Questions

1)What is Amazon S3?

Ans: Amazon Simple Storage Service (Amazon S3) is an object storage service that
provides industry-leading scalability, data availability, security, and performance.

The service can be used as online backup and archiving of data and applications on Amazon
Web Services (AWS).

2): What is the use of AWS S3?

Ans: Amazon S3 (Amazon Simple Storage Service) is an object storage service.

Amazon S3 allows users to store and retrieve any amount of data from anywhere on the
internet at any time.

S3 can be used as online backup and archiving of data and applications on Amazon Web
Services (AWS).

2)What are Objects and Buckets in AWS S3?

Ans:

AWS Objects :

Objects are the actual items that we store in S3. They are marked by a key, which is a
sequence of Unicode characters with a maximum length of 1,024 bytes in UTF-8 encoding.

AWS Bucket :

AWS Simple Storage Service (S3) bucket is an public object storage service. Similar to file
folders, Amazon S3 buckets store objects that contain data and descriptive metadata.

Buckets are containers for objects that we choose to store. It is necessary to remember that
S3 allows the bucket name to be globally unique.

3)What type of storage is S3?

Ans: Amazon S3 is an object storage service that allows you to store and retrieve any
quantity of data from any location on the Internet.

4)Which Maven Dependencies is required to work with AWS S3?

Ans:

You can use starter dependency called spring-cloud-starter-aws, which have spring-cloud-
aws-context and spring-cloud-aws-autoconfigure dependencies.
<dependency>

<groupId>org.springframework.cloud</groupId>

<artifactId>spring-cloud-starter-aws</artifactId>

</dependency>

5) What are the prerequisites for using AWS SDK S3 with a Spring Boot app?

Ans:

We'll need a few things to use the AWS SDK:

AWS Account

We'll need an account with Amazon Web Services. If you don't already have one, go ahead
and create one.

AWS Security Credentials

These are the access keys that enable us to call AWS API actions programmatically. We can
obtain these credentials using IAM user credentials from the IAM console.

AWS Region to store S3 object

We must choose an AWS region (or regions) to store our Amazon S3 data.

AWS S3 Bucket

We will need S3 Bucket to store the objects/files.

6): How to connect to AWS S3 web service from Spring Boot application?

Ans: To access the Amazon S3 web service, we must first establish a client connection. For
this, we'll use the AmazonS3 interface:

AWSCredentials awsCredentials = new BasicAWSCredentials(

"<AWS accesskey>", "<AWS secretkey>");

AmazonS3 s3client = AmazonS3ClientBuilder

.standard() .withCredentials(new AWSStaticCredentialsProvider(awsCredentials))

//provide the region that you have chose while selecting AWS Region

.withRegion(Regions.US_EAST_2)

.build();
7) How to get the list of files under specific Bucket in AWS S3 in Spring Boot application?

Ans: Use listObjects method to get all the objects/files under specified bucket.

ListObjectsRequest listObjectsRequest =

new ListObjectsRequest()

.withBucketName(bucketName);

List<String> keys = new ArrayList<>();

ObjectListing objects = amazonS3Client.listObjects(listObjectsRequest);

8) What are the constraints that must be taken into consideration when creating an S3
bucket?

Ans: The following constraints must be taken into consideration will creating a S3 bucket:

Underscores should not be used in bucket names.

Bucket names should be between 3 and 63 characters long, with no dashes at the end.

There can't be any periods in the name of a bucket.

There can't be any dashes next to periods in bucket names (e.g., "abc-.testbucket.com" and
"abc.-testbucket" are invalid)

Uppercase characters are not permitted in bucket names.

9) How to create Bucket in AWS S3 in Spring Boot application?

Ans: Since Amazon S3 bucket names are globally unique, you won't be able to create
another bucket with the same name once it's been taken by another user.

String bucketName = "techgeeknext-bucket1";

//check if same bucket is already exist

if(s3client.doesBucketExist(bucketName)) {

LOG.info("Bucket name is not available."

+ " Try again with a different Bucket name.");

return;

s3client.createBucket(bucketName);
10) How to see all created buckets in AWS S3 in Spring Boot application?

Ans: listBuckets() method will return a list of all the Buckets available in our S3 environment.

List<Bucket> buckets = s3client.listBuckets();

11) How to delete the bucket from AWS S3 in Spring Boot application?

Ans: Before we delete our bucket, we must make sure it is empty.

If this is not the case, an exception will be thrown.

Also, only the owner of a bucket can delete it despite of its permissions (Access Control
Policies).

try {

s3client.deleteBucket(bucketName);

} catch (AmazonServiceException e) {

System.err.println("e.getErrorMessage());

return;

12) How to upload/store file in AWS S3 Bucket in Spring Boot application?

Ans:

putObject method of Amazon S3 Client is used to store the object/file into AWS S3 Bucket.

ObjectMetadata metadata = new ObjectMetadata();

metadata.setContentLength(file.getSize());

amazonS3Client.putObject(bucketName, keyName,

file.getInputStream(), metadata);

13) What is the default S3 bucket policy?

Ans:

Both Amazon S3 buckets and objects are private by default. Only the resource owner who
created the AWS account can access that bucket. However, the owner of the resource can
choose to grant access permissions to other resources and users.

You might also like