Installing AWS CLI
Using WordPress on AWS Lightsail and Docker
Summary
The AWS CLI is a command-line tool that lets you manage and automate AWS services including Lightsail using PowerShell, Command Prompt, or Terminal. With AWS CLI, you can automate tasks, configure AWS resources, and streamline the deployment and management of Lightsail instances, Docker containers, and WordPress environments.
Prerequisites
- Python (if applicable):
- Required only for AWS CLI v1 (installed via pip): Python 3.7 or later recommended.
- AWS CLI v2: Python is bundled; you don’t need to install it separately.
- Administrator or sudo privileges: Required for installation and configuration on most systems.
Installation
Tip: All commands below should be run in your system’s terminal, PowerShell, or command prompt.
Windows
Option 1: MSI Installer
- Download the installer from the official AWS CLI documentation.
- Run the installer (e.g.,
AWSCLIV2.msi).Or, run this command:msiexec.exe /i https://awscli.amazonaws.com/AWSCLIV2.msi
Option 2: Chocolatey
Chocolatey is a command-line package manager for Windows.
To install or upgrade AWS CLI:
choco upgrade awscli
Verify Installation
aws --version
Linux
Option 1: Official Bundled Installer
curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
unzip awscliv2.zip
sudo ./aws/install
rm -rf awscliv2.zip aws/
Option 2: Snap (Ubuntu/Debian)
sudo snap install aws-cli --classic
Verify Installation
aws --version
macOS
Option 1: Homebrew
brew update
brew install awscli
Verify Installation
aws --version
Creating an IAM User Group for Lightsail Access
You can use either a service-linked role (created automatically by Lightsail) or set up a custom role with your own group and permissions.
1. Sign in to the AWS Management Console
- Go to the IAM (Identity and Access Management) service (search for “IAM” in the AWS Console search bar).
2. Create a User Group
- Navigate to User groups ? Create group.
- Name your group (e.g.,
LightsailUsers). - (Optional) Add users now, or skip and add later.
- Click Next.
3. Attach Permissions
- In Attach permissions policies, search for
AdministratorAccess. - Check the box for
AdministratorAccess. - Click Next, then Create group.
4. Add Users (if you didn�t earlier)
- In User groups, select your group.
- Go to the Users tab, click Create user.
5. Create User & Access Key
- Set a username (e.g.,
developer). - Leave console access unchecked (optional).
- On Permissions, choose Add user to group and pick
LightsailUsers. - Skip permission boundaries (optional).
- Click Create user.
Create Access Key:
- In Users, click your user’s name.
- Go to Security credentials tab, click Create access key.
- Select Command Line Interface (CLI).
- Confirm recommendations and continue.
- Download your credentials
.csvand store securely.
Tip: Tags (key-value pairs) can help organize and automate your Lightsail resources.
AWS CLI Configuration
1. Run the aws configure Command
aws configure
You’ll be prompted for:
- AWS Access Key ID: (From your downloaded
.csv) - AWS Secret Access Key: (From your downloaded
.csv) - Default region name: (e.g.,
ap-southeast-2) - Default output format: (
json,text, ortable)
These are stored as your default profile.
2. Add Additional Profiles (Optional)
You can create multiple named profiles (for different users/accounts):
aws configure --profile MyUbuntuProfile
3. Where Profiles Are Stored
Profiles are kept in two files:
- Linux/macOS:
~/.aws/ - Windows:
C:\Users\<YourUsername>\.aws\
Files:
credentials– stores access keysconfig– stores region and output format
Example:
~/.aws/credentials
[default]
aws_access_key_id = AKIAEXAMPLE1
aws_secret_access_key = secret1
[MyUbuntuInstance]
aws_access_key_id = AKIAEXAMPLE2
aws_secret_access_key = secret2
~/.aws/config
[default]
region = ap-southeast-2
output = json
[profile MyUbuntuInstance]
region = us-west-2
output = table
Using Multi-Profiles
Multi-profiles allow you to easily switch between AWS accounts, users, or environments from a single machine.
- View all profiles:
aws configure list-profiles - Use a profile:
aws s3 ls --profile default aws ec2 describe-instances --profile MyUbuntuProfile

Leave a Reply
You must be logged in to post a comment.