AWS CLI Cheatsheet

Install AWS Lambda Tools

dotnet tool install --global Amazon.Lambda.Tools
dotnet new --install Amazon.Lambda.Templates

AWS SSO Authentication

List configured profiles:

aws configure list-profiles

## or
cat ~/.aws/config

Authenticate and verify access:

aws sso login --profile aws-profile

## Verify authentication
aws s3 ls --profile aws-profile

## or
dotnet lambda list-functions

Download Lambda Function Package

aws lambda get-function --profile AWS_PROFILE --function-name FUNCTION_NAME --query 'Code.Location' --output text

Invoke Lambda Function

aws lambda invoke --profile AWS_PROFILE --function-name FUNCTION_NAME output-file --log-type Tail --query 'LogResult' --output text | base64 -d

Login Docker to ECR

aws sso login --profile PROFILE
aws ecr get-login-password --region REGION --profile PROFILE | docker login --username AWS --password-stdin ECR_URL

Example:

aws sso login --profile aws-infrastructure
aws ecr get-login-password --region eu-central-1 --profile aws-infrastructure | docker login --username AWS --password-stdin 258781458051.dkr.ecr.eu-central-1.amazonaws.com