The document discusses using the AWS CLI (Command Line Interface) to interact with and manage AWS services like S3 and EC2. It provides instructions on installing and configuring the AWS CLI, including setting credentials and region. It then gives examples of AWS CLI commands for common S3 operations like creating and accessing buckets, and EC2 operations like starting, stopping and terminating instances.
The document discusses using the AWS CLI (Command Line Interface) to interact with and manage AWS services like S3 and EC2. It provides instructions on installing and configuring the AWS CLI, including setting credentials and region. It then gives examples of AWS CLI commands for common S3 operations like creating and accessing buckets, and EC2 operations like starting, stopping and terminating instances.
2) CLI setup AWS Instance – IAM user credential or IAM role
3) CLI setup Local server – IAM user credential or IAM role
4) S3 operation with CLI
5) EC2 instance operation with CLI
6) High Availability Lab
AWS CLI The AWS Command Line Interface (AWS CLI) is an open source tool that enables you to interact with AWS services using commands in your command-line shell. With minimal configuration, the AWS CLI enables you to start running commands that implement functionality equivalent to that provided by the browser-based AWS Management Console from the command prompt in your terminal program.
AWS CLI versions
• Version 2.x • Version 1.x
How to install AWS CLI
1) Amazon linux 2 AMI – already installed 2) Other OS -- download from AWS documentation link AWS CLI Setup
1) Create an IAM user and give administrator access.
2) Open it –security credential –create access key—download access key –note down access and secret key. 3) Install aws cli in windows and linux based system 4) Type command $ aws configure Access key: Secret access key: Default region: ap-south-1 Output format: JSON AWS CLI –with S3 Bucket To create a new bucket aws s3 mb s3://awsbatch100
To upload the file to s3 bucket
aws s3 cp “C:\data1\file1.txt” s3://awsbatch100/
To download file from s3 bucket
aws s3 cp s3://awsbatch100/file1.txt ./
To delete s3 bucket file
aws s3 rm s3://awsbatch100/file1.txt AWS CLI –with S3 Bucket To Sync the local directory with s3 bucket and vice versa
dest-check "{\"Value\": true}" AWS CLI—EC2 To modify the user data attached to an instance Contents of original file UserData.txt: #!/bin/bash yum install vsftpd -y systemctl start vsftpd systemctl enable vsftpd The contents of the file must be base64 encoded. The first command converts the text file to base64 and saves it as a new file. base64 UserData.txt > UserData.base64.txt CLI command aws ec2 modify-instance-attribute \ --instance-id=i-09b5a14dbca622e76 \ --attribute userData --value file://UserData.base64.txt