AWS S3 Interview Questions
AWS S3 Interview Questions
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).
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).
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.
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.
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:
AWS Account
We'll need an account with Amazon Web Services. If you don't already have one, go ahead
and create one.
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.
We must choose an AWS region (or regions) to store our Amazon S3 data.
AWS S3 Bucket
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:
//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);
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:
Bucket names should be between 3 and 63 characters long, with no dashes at the end.
There can't be any dashes next to periods in bucket names (e.g., "abc-.testbucket.com" and
"abc.-testbucket" are invalid)
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.
if(s3client.doesBucketExist(bucketName)) {
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.
11) How to delete the bucket from AWS S3 in Spring Boot application?
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;
Ans:
putObject method of Amazon S3 Client is used to store the object/file into AWS S3 Bucket.
metadata.setContentLength(file.getSize());
amazonS3Client.putObject(bucketName, keyName,
file.getInputStream(), metadata);
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.