☁️
Cloud CLI

AWS CLI

Command-line interface for Amazon Web Services

🐧 Linux🍎 Mac🪟 Windows📋 Quick reference →
Reviewed: Tested on: Kubernetes 1.29 · Terraform 1.8 · Ubuntu 22.04

What is this?

The AWS CLI lets you manage Amazon cloud services (servers, storage, databases) from your terminal.

📁

Config files for AWS CLI

Where to create or edit the main configuration — paths below match the setup steps.

  • ~/.aws/credentials

    Location: User home

    Access key and secret for AWS API

  • ~/.aws/config

    Location: User home

    Default region and output format

📥

Step 01

Install AWS CLI

(01)Install AWS CLI v2

Linux
1# Linux x86_64
2curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
3unzip awscliv2.zip
4sudo ./aws/install
5rm -rf aws awscliv2.zip
6
7# Or via package manager (Ubuntu)
8sudo snap install aws-cli --classic

(02)Configure Credentials

Linux
1aws configure
2# AWS Access Key ID: YOUR_KEY
3# AWS Secret Access Key: YOUR_SECRET
4# Default region: us-east-1
5# Default output format: json

Step 02

Verify Installation

(01)Check Version & Identity

Linux
1aws --version
2aws sts get-caller-identity

Step 03

Manage AWS CLI

(01)EC2 Operations

Linux
1aws ec2 describe-instances
2aws ec2 start-instances --instance-ids i-1234567890abcdef0
3aws ec2 stop-instances --instance-ids i-1234567890abcdef0

(02)S3 Operations

Linux
1aws s3 ls
2aws s3 mb s3://my-bucket-name
3aws s3 cp file.txt s3://my-bucket-name/
4aws s3 sync ./local-dir s3://my-bucket-name/

(03)Profile Management

Linux
1aws configure --profile production
2aws s3 ls --profile production
3export AWS_PROFILE=production
🔧

Step 04

Common Problems

#1Unable to locate credentials

Linux
1# Configure credentials:
2aws configure
3# Or use env vars:
4export AWS_ACCESS_KEY_ID=...
5export AWS_SECRET_ACCESS_KEY=...
6export AWS_DEFAULT_REGION=us-east-1
7aws sts get-caller-identity

#2Access Denied on API call

Linux
1# Verify identity and IAM policy:
2aws sts get-caller-identity
3# Check user/role has required permissions for the service

📋Config templates

4 YAML templates for AWS CLI. Copy and deploy after setup.

4 ready-to-copy templates. Expand one, copy the YAML, then run the deploy commands.

Jenkinsfile

Deploy Python survey app to EKS — update kubeconfig, kubectl apply, reveal ELB URL

yaml
1pipeline {
2 agent any
3
4 parameters {
5 string(name: 'DEPLOYMENT', defaultValue: 'production')
6 }
7
8 stages {
9 stage('Update Kubeconfig') {
10 steps {
11 withCredentials([[
12 $class: 'AmazonWebServicesCredentialsBinding',
13 credentialsId: "aws-credentials",
14 accessKeyVariable: 'AWS_ACCESS_KEY_ID',
15 secretKeyVariable: 'AWS_SECRET_ACCESS_KEY'
16 ]]) {
17 sh """
18 aws eks update-kubeconfig --name python-cluster --region us-east-1
19 kubectl get nodes
20 """
21 }
22 }
23 }
24
25 stage('Deploy App') {
26 steps {
27 withCredentials([[
28 $class: 'AmazonWebServicesCredentialsBinding',
29 credentialsId: "aws-credentials",
30 accessKeyVariable: 'AWS_ACCESS_KEY_ID',
31 secretKeyVariable: 'AWS_SECRET_ACCESS_KEY'
32 ]]) {
33 sh """
34 kubectl create namespace python-app --dry-run=client -o yaml | kubectl apply -f -
35 kubectl -n python-app apply -f k8s/deployment.yaml
36 kubectl -n python-app apply -f k8s/services.yaml
37 kubectl -n python-app rollout status deployment/survey-app-deploy
38 """
39 }
40 }
41 }
42
43 stage('Reveal APP URL') {
44 steps {
45 withCredentials([[
46 $class: 'AmazonWebServicesCredentialsBinding',
47 credentialsId: "aws-credentials",
48 accessKeyVariable: 'AWS_ACCESS_KEY_ID',
49 secretKeyVariable: 'AWS_SECRET_ACCESS_KEY'
50 ]]) {
51 sh "kubectl -n python-app get svc"
52 }
53 }
54 }
55 }
56}

k8s/deployment.yaml

yaml
1apiVersion: apps/v1
2kind: Deployment
3metadata:
4 name: survey-app-deploy
5 namespace: python-app
6 labels:
7 app: survey-app
8spec:
9 selector:
10 matchLabels:
11 app: survey-app
12 replicas: 2
13 template:
14 metadata:
15 labels:
16 app: survey-app
17 spec:
18 containers:
19 - name: survey-app
20 image: your-registry/survey-app:latest
21 ports:
22 - containerPort: 8000
23 resources:
24 requests:
25 memory: "128Mi"
26 cpu: "100m"
27 limits:
28 memory: "256Mi"
29 cpu: "250m"

k8s/services.yaml

yaml
1apiVersion: v1
2kind: Service
3metadata:
4 name: survey-app-service
5 namespace: python-app
6spec:
7 type: LoadBalancer
8 selector:
9 app: survey-app
10 ports:
11 - port: 80
12 targetPort: 8000
13 protocol: TCP
📄

Step 01

Use the Pipeline

(01)Add Jenkins credentials and run

Linux
1# Jenkins → Manage Credentials → AWS credentials (ID: aws-credentials)
2# Create EKS cluster named python-cluster
3# Add Jenkinsfile to repo; create Pipeline job
4# Push image to ECR/Docker Hub, update deployment.yaml image