Skip to main content

Lab: Environment Configuration

Lab Objectives​

By the end of this lab, you will have:

  • ✅ A complete and functional working environment
  • ✅ Docker Desktop installed and operational
  • ✅ AWS CLI v2 configured with a LocalStack profile
  • ✅ LocalStack started and tested
  • ✅ A mini-report with configuration proofs

Estimated Duration​

1 to 2 hours (depending on your system and Internet connection)

Prerequisites​

  • Computer with Windows 10/11, macOS, or Linux
  • Administrator rights
  • Stable Internet connection
  • Minimum 10 GB of free disk space

Part 1: Installing Docker Desktop​

Steps​

1.1 Download Docker Desktop

Visit: https://www.docker.com/products/docker-desktop/

Download the version corresponding to your system.

1.2 Install Docker Desktop

  • Windows: Double-click the installer, follow the wizard
  • macOS: Drag Docker to Applications
  • Linux: Follow your distribution's instructions

1.3 Start Docker Desktop

Launch Docker Desktop from the Start menu (Windows) or Applications (macOS).

Wait for the Docker icon to indicate "Docker is running".

1.4 Verify the installation

Open a terminal and execute:

docker --version
docker run hello-world

Part 1 Validation​

Screenshot required

Take a screenshot showing:

  1. The output of docker --version
  2. The "Hello from Docker!" message from docker run hello-world

Name this file: 01-docker-version.png


Part 2: Installing AWS CLI v2​

Steps​

2.1 Download AWS CLI v2

2.2 Install

Windows:

# Double-click AWSCLIV2.msi and follow the wizard
# OR
msiexec.exe /i https://awscli.amazonaws.com/AWSCLIV2.msi

macOS:

curl "https://awscli.amazonaws.com/AWSCLIV2.pkg" -o "AWSCLIV2.pkg"
sudo installer -pkg AWSCLIV2.pkg -target /

Linux:

curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
unzip awscliv2.zip
sudo ./aws/install

2.3 Verify the installation

Close and reopen your terminal, then:

aws --version

2.4 Configure the LocalStack profile

aws configure --profile localstack

Enter the following values:

AWS Access Key ID [None]: test
AWS Secret Access Key [None]: test
Default region name [None]: us-east-1
Default output format [None]: json

2.5 Verify the configuration

aws configure list --profile localstack

Part 2 Validation​

Screenshot required

Take a screenshot showing:

  1. The output of aws --version
  2. The output of aws configure list --profile localstack

Name this file: 02-aws-cli-config.png


Part 3: Starting LocalStack​

Steps​

3.1 Create a working directory

# Create a directory for this course
mkdir aws-course
cd aws-course

3.2 Create the docker-compose.yml file

Create a file docker-compose.yml with the following content:

version: '3.8'

services:
localstack:
container_name: localstack
image: localstack/localstack:latest
ports:
- "4566:4566"
- "4510-4559:4510-4559"
environment:
- SERVICES=s3,lambda,sqs,sns,dynamodb,cloudwatch,cloudformation,iam
- DEBUG=1
- DATA_DIR=/tmp/localstack/data
volumes:
- "./localstack-data:/var/lib/localstack"
- "/var/run/docker.sock:/var/run/docker.sock"

3.3 Start LocalStack

docker-compose up -d

Or without docker-compose:

docker run -d \
--name localstack \
-p 4566:4566 \
-e SERVICES=s3,lambda,sqs,dynamodb,cloudwatch,cloudformation \
localstack/localstack

3.4 Wait for startup (30-60 seconds)

# Verify the container is running
docker ps

# View logs (optional)
docker logs localstack

3.5 Check health status

# Linux/macOS
curl http://localhost:4566/_localstack/health

# Windows PowerShell
Invoke-RestMethod http://localhost:4566/_localstack/health

Part 3 Validation​

Screenshot required

Take a screenshot showing:

  1. The output of docker ps with the localstack container
  2. The output of the health check

Name this file: 03-localstack-running.png


Part 4: Testing AWS Commands​

Steps​

4.1 Configure alias (optional but recommended)

Windows PowerShell:

# Test first without alias
aws --endpoint-url=http://localhost:4566 s3 ls --profile localstack

macOS/Linux:

alias awslocal='aws --endpoint-url=http://localhost:4566 --profile localstack'

4.2 Create an S3 bucket

# With alias
awslocal s3 mb s3://my-first-test-bucket

# Without alias (Windows)
aws --endpoint-url=http://localhost:4566 s3 mb s3://my-first-test-bucket --profile localstack

4.3 List buckets

awslocal s3 ls

Expected result:

2024-12-18 10:30:00 my-first-test-bucket

4.4 Create a test file

# Create a local file
echo "Hello AWS LocalStack!" > test.txt

# Upload to S3
awslocal s3 cp test.txt s3://my-first-test-bucket/

# Verify
awslocal s3 ls s3://my-first-test-bucket/

4.5 Download the file

awslocal s3 cp s3://my-first-test-bucket/test.txt downloaded.txt
cat downloaded.txt

4.6 Clean up

# Remove the file from the bucket
awslocal s3 rm s3://my-first-test-bucket/test.txt

# Remove the bucket
awslocal s3 rb s3://my-first-test-bucket

Part 4 Validation​

Screenshot required

Take a screenshot showing:

  1. The creation of the bucket (s3 mb)
  2. The bucket listing with the file (s3 ls)
  3. The content of the downloaded file

Name this file: 04-aws-s3-test.png


Part 5: Lambda Test (Bonus)​

Steps​

5.1 Create a simple Lambda function

Create a file lambda_function.py:

def handler(event, context):
return {
'statusCode': 200,
'body': 'Hello from LocalStack Lambda!'
}

5.2 Zip the function

# Linux/macOS
zip function.zip lambda_function.py

# Windows PowerShell
Compress-Archive -Path lambda_function.py -DestinationPath function.zip

5.3 Create the Lambda function

awslocal lambda create-function \
--function-name my-first-function \
--runtime python3.9 \
--handler lambda_function.handler \
--zip-file fileb://function.zip \
--role arn:aws:iam::000000000000:role/lambda-role

5.4 Invoke the function

awslocal lambda invoke \
--function-name my-first-function \
--payload '{}' \
output.txt

cat output.txt

5.5 List functions

awslocal lambda list-functions

Part 5 Validation​

Screenshot required (Bonus)

Take a screenshot showing:

  1. The creation of the Lambda function
  2. The successful invocation with the result

Name this file: 05-lambda-test.png


Lab Deliverables​

Mini-Report "Environment Ready"​

Create a document (Word, PDF, or Markdown) containing:

1. Title Page

  • Student's name
  • Date
  • Title: "Lab 1 - AWS Environment Configuration"

2. Screenshots Include the 4 mandatory screenshots (5 with the Lambda bonus):

  • 01-docker-version.png
  • 02-aws-cli-config.png
  • 03-localstack-running.png
  • 04-aws-s3-test.png
  • 05-lambda-test.png (bonus)

3. Summary Table

ComponentVersionStatus
DockerX.X.X✅ Installed
AWS CLIX.X.X✅ Configured
LocalStacklatest✅ Functional

4. Issues Encountered (if applicable) Briefly describe any issues encountered and how you resolved them.

5. Final Checklist

  • Docker Desktop installed and functional
  • AWS CLI v2 installed
  • LocalStack profile configured
  • LocalStack started
  • S3 test successful (bucket creation, file upload)
  • Lambda test successful (bonus)

Evaluation Grid​

CriterionPoints
Docker installed and functional2
AWS CLI installed and configured2
LocalStack started2
S3 test successful2
Complete screenshots1
Well-structured report1
Total10

Bonus: Lambda test successful (+2 points)


Common Troubleshooting​

Docker does not start​

Windows:

  1. Enable virtualization in BIOS
  2. Enable WSL2: wsl --install
  3. Restart your computer

AWS CLI not recognized​

  1. Close and reopen the terminal
  2. Check the PATH
  3. Reinstall AWS CLI

LocalStack not responding​

  1. Wait 60 seconds after startup
  2. Check logs: docker logs localstack
  3. Restart: docker restart localstack

"No credentials" error​

# Reconfigure
aws configure --profile localstack

# Verify
aws configure list --profile localstack

Command Summary​

# Docker
docker --version
docker run hello-world
docker ps
docker logs localstack

# AWS CLI
aws --version
aws configure --profile localstack
aws configure list --profile localstack

# LocalStack
docker-compose up -d
curl http://localhost:4566/_localstack/health

# S3 Tests
awslocal s3 mb s3://bucket-name
awslocal s3 ls
awslocal s3 cp file.txt s3://bucket/
awslocal s3 rm s3://bucket/file.txt
awslocal s3 rb s3://bucket-name

# Lambda Tests
awslocal lambda create-function ...
awslocal lambda invoke ...
awslocal lambda list-functions

End of Lab Quiz​

  1. What is the default port for LocalStack?
  2. Which AWS CLI option points to LocalStack?
  3. Which command creates an S3 bucket?
  4. How do you verify that LocalStack is working?
  5. Why do we use "test" credentials with LocalStack?

Congratulations! You have configured your AWS environment. You are ready for MODULE 2!