This is pretty vast subject, I will be listing down here most used commands, simple fixes, queries with in AWS world. This will be an ongoing post and can get as long as it exists 🙂
Q1. How to set up a new AWS Profile?
A1.
Type the below in command prompt, prerequisite is that AWS CLI is already installed, if not use this link.
Type,aws configure
to set the default profile or below to setup a new profile.
aws --profile {PROFILENAME} configure
Q2. How to set a default profile?
A2.
for LINUX, type export AWS_PROFILE={profilename}
for WINDOWS, type setx AWS_PROFILE {profilename}
Q3. Where could I view/edit my AWS profiles?
A3.
for WINDOWS, check folder C:\Users\{username}\.aws, you might see as below,
for LINUX & MAC, check under your home, ~/.aws/config and ~/.aws/credentials
config file has the region and output format if we had provided as part of profile creation.
credentials file has access key id (aws_access_key_id) and secret access key(aws_secret_access_key).
Important!! – These are like credentials to your AWS account so make sure these are not shared or added in your code. You can rotate this from IAM screen in AWS console.
Q4. How to list all profiles?
A4.
Type, aws configure list-profiles
Q5. How to create or replicate RDS DB from one account to another account in same or different region?
A5.
One Account to Another Account – Same Region:
Step 1 Create Snapshot
Step 2 Use the Share Snapshot option and add the account id. Refer below screenshots for details.
Don’t make it public !!!!, as it will be come visible for everyone.
One Account to Another Account – Different Region:
Step 1: Use Copy Snapshot to copy it different region as your destination account. Refer screenshots below for details.
Repeat Steps for One Account to Another Account – Same Region:
Q6. How to copy S3 bucket data from one account to another account?
A6.
Step 1: Update Policy for source account – source bucket as below,
Step 2: If you are planning to use root account, skip this step; Otherwise Add a new IAM programmatic user with the following inline policy as below,
Step 3: Run the below command in AWS CLI to simulate the sync command,
aws s3 sync –profile PROFILE1 –dryrun s3://SOURCE_BUCKET_NAME s3://DESTINATION_BUCKET_NAME –source-region SOURCE_BUCKET_REGION –region DESTINATION_BUCKET_REGION
Step 4: Remove –dryrun from the above command in AWS CLI to proceed with sync command. Please note –profile PROFILE1 is not mandatory if you are using the default AWS profile or you have only profile configured.
aws s3 sync –profile PROFILE1 s3://SOURCE_BUCKET_NAME s3://DESTINATION_BUCKET_NAME –source-region SOURCE_BUCKET_REGION –region DESTINATION_BUCKET_REGION
Comments (0)