aws-cli.md (1778B)
1 --- 2 title: "AWS - CLI" 3 section: "Cloud" 4 sectionSlug: "cloud" 5 sourcePath: "docs/cloud/aws/aws-cli.md" 6 sourceUrl: "https://github.com/swisskyrepo/InternalAllTheThings/blob/203bb0c0b290/docs/cloud/aws/aws-cli.md" 7 sha: "203bb0c0b290" 8 isIndex: false 9 --- 10 11 # AWS - CLI 12 13 The AWS Command Line Interface (CLI) is a unified tool to manage AWS services from the command line. Using the AWS CLI, you can control multiple AWS services, automate tasks, and manage configurations through profiles. 14 15 ## Set up AWS CLI 16 17 Install AWS CLI and configure it for the first time: 18 19 ```ps1 20 aws configure 21 ``` 22 23 This will prompt for: 24 25 * AWS Access Key ID 26 * AWS Secret Access Key 27 * Default region name 28 * Default output format 29 30 ## Creating Profiles 31 32 You can configure multiple profiles in `~/.aws/credentials` and `~/.aws/config`. 33 34 * `~/.aws/credentials` (stores credentials) 35 36 ```ini 37 [default] 38 aws_access_key_id = <default-access-key> 39 aws_secret_access_key = <default-secret-key> 40 41 [dev-profile] 42 aws_access_key_id = <dev-access-key> 43 aws_secret_access_key = <dev-secret-key> 44 45 [prod-profile] 46 aws_access_key_id = <prod-access-key> 47 aws_secret_access_key = <prod-secret-key> 48 ``` 49 50 * `~/.aws/config` (stores region and output settings) 51 52 ```ini 53 [default] 54 region = us-east-1 55 output = json 56 57 [profile dev-profile] 58 region = us-west-2 59 output = yaml 60 61 [profile prod-profile] 62 region = eu-west-1 63 output = json 64 ``` 65 66 You can also create profiles via the command line: 67 68 ```ps1 69 aws configure --profile dev-profile 70 ``` 71 72 ## Using Profiles 73 74 When running AWS CLI commands, you can specify which profile to use by adding the `--profile` flag: 75 76 ```ps1 77 aws s3 ls --profile dev-profile 78 ``` 79 80 If no profile is specified, the **default** profile is used.