2024-02-25 16:26:09 +00:00
|
|
|
---
|
|
|
|
tags: [AWS]
|
|
|
|
---
|
|
|
|
|
2024-03-05 17:40:03 +00:00
|
|
|
# AWS CLI frequent commands
|
2024-02-25 16:26:09 +00:00
|
|
|
|
|
|
|
### Retrieve current user
|
|
|
|
|
|
|
|
```
|
|
|
|
aws-sts get-caller-identity
|
|
|
|
```
|
|
|
|
|
|
|
|
### List users
|
|
|
|
|
|
|
|
```
|
|
|
|
aws configure list
|
|
|
|
aws configure list-profiles
|
|
|
|
```
|
|
|
|
|
|
|
|
### View profile data
|
|
|
|
|
|
|
|
```
|
|
|
|
vim ./aws/credentials
|
|
|
|
```
|
2024-03-05 17:40:03 +00:00
|
|
|
|
|
|
|
## CloudFormation
|
|
|
|
|
|
|
|
### List stacks
|
|
|
|
|
|
|
|
```
|
|
|
|
aws cloudformation --list-stacks
|
|
|
|
```
|
|
|
|
|
|
|
|
### Delete a stack
|
|
|
|
|
|
|
|
```
|
|
|
|
aws cloudformation delete-stack --stack-name <my_stack> --region <region>
|
|
|
|
```
|
|
|
|
|
|
|
|
`region` is optional especially if only deployed to one region
|
2024-03-05 18:00:04 +00:00
|
|
|
|
|
|
|
## Billing ("Cost explorer")
|
|
|
|
|
|
|
|
### Usage for month
|
|
|
|
|
|
|
|
```
|
|
|
|
aws ce get-cost-and-usage --time-period Start=$(date +%Y-%m-01),End=$(date -d @$(( $(date +%s) + 86400 )) +%Y-%m-%d) --granularity MONTHLY --metrics "UnblendedCost" "UsageQuantity
|
|
|
|
```
|