Pages

Showing posts with label aws cli. Show all posts
Showing posts with label aws cli. Show all posts

Wednesday, December 1, 2021

AWS CLI using Role and MFA

 AWS CLI using Role and MFA

1. Setting AWS CLI Credential location : ~/.aws/credentials

[myuser]
aws_access_key_id = xxxx
aws_secret_access_key = xxxx


2. Setting AWS CLI Config location : ~/.aws/config

[profile myusermfa]
region = yourregion
role_arn = arn:aws:iam::xxAccountIDxx:role/xxRoleNamexx
source_profile = myuser
mfa_serial = arn:aws:iam::xxAccountIDxx:mfa/myuser
role_session_name = Session_MyUser_MFA

3. Access AWS CLI using profile

aws s3 ls s3:// --profile=myuser

Thursday, October 25, 2018

AWS S3 How to Find Files with by Keyword

open cmd
run command :
aws s3api list-objects --bucket BUCKETNAME --prefix FOLDERNAME1/FOLDERNAME2/ --output json --query "Contents[?contains(Key, `SearchKeyword`)]"



How to sum :
aws s3api list-objects --bucket BUCKETNAME --prefix FOLDERNAME1/FOLDERNAME2/ --output json --query "[sum(Contents[?contains(Key, `SearchKeyword`)].Size), length(Contents[?contains(Key, `SearchKeyword`)])]"

Wednesday, April 11, 2018

AWS S3 How to Count Folder Size

open cmd
run command :
aws s3api list-objects --bucket BUCKETNAME --prefix FOLDERNAME1/FOLDERNAME2/ --output json --query "[sum(Contents[].Size), length(Contents[])]"

ShareThis