DevOps(Day-58) :S3 Programmatic access with AWS-CLI - Part2
TABLE OF CONTENTS
Task 2: Creating a EC2 snapshot and integrating to S3
Create an S3 bucket and upload a file to it using the AWS Management Console.
Navigate to the S3 page in the AWS console and provide the bucket name and choose the region for it.
The S3 bucket is created now.
Now upload a file to the S3 bucket.
I have added my resume and a fileS3.txt to the bucket from my local system.
The file is now uploaded to the S3 bucket.
Access the file from the EC2 instance using the AWS Command Line Interface (AWS CLI).
Navigate to your instance and install AWS CLI.
Configure this with the IAM user having specific permission to have a connection between AWS CLI to the management console.
Provide the necessary Access key IDs to build the connection.
Now you can view the S3 bucket list and copy the file from S3 to EC2.
You can view the file content now in AWS CLI.
Task 2: Creating a EC2 snapshot and integrating to S3
Create a snapshot of the EC2 instance and use it to launch a new EC2 instance.
Navigate to the snapshot section in the AWS console.
Snapshot is now created.
Now create an image from the snapshot.
Navigate to AMIs section in EC2 dashboard and you can see the Machine image. Then create an instance from the image.
You can see the new instance now.
Download a file from the S3 bucket using the AWS CLI.
Now, connect the instance from AWS CLI to the AWS management console.
Verify that the contents of the file are the same on both EC2 instances.
Download the file from S3 on the new instance and verify the content is matched with the old instance.
Some important AWS S3 commands are:-
aws s3 ls
- This command lists all of the S3 buckets in your AWS account.aws s3 mb
s3://bucket-name
- This command creates a new S3 bucket with the specified name.aws s3 rb
s3://bucket-name
- This command deletes the specified S3 bucket.aws s3 cp file.txt
s3://bucket-name
- This command uploads a file to an S3 bucket.aws s3 cp
s3://bucket-name/file.txt
.
- This command downloads a file from an S3 bucket to your local file system.aws s3 sync local-folder
s3://bucket-name
- This command syncs the contents of a local folder with an S3 bucket.aws s3 ls
s3://bucket-name
- This command lists the objects in an S3 bucket.aws s3 rm
s3://bucket-name/file.txt
- This command deletes an object from an S3 bucket.aws s3 presign
s3://bucket-name/file.txt
- This command generates a pre-signed URL for an S3 object, which can be used to grant temporary access to the object.aws s3api list-buckets
- This command retrieves a list of all S3 buckets in your AWS account, using the S3 API.
Thanks for reading my article. Have a nice day.
Comments
Post a Comment