All labs

Cloud lifecycle lab · Cloud, Platform & Security

Create, inspect, and clean up an S3 bucket

Use the AWS CLI to create a uniquely named bucket, upload one object, inspect what exists, and remove every resource you created.

35–45 min Beginner AWS CLI · PowerShell

Lab outcome

A complete create → inspect → verify → clean up workflow that leaves no lab resources behind.

Before you start

  • AWS CLI v2 installed and configured.
  • A sandbox AWS account with permission to call STS and create, inspect, and delete an S3 bucket and object.
  • PowerShell 7 or Windows PowerShell.

Guided procedure

Complete the lab

01

Confirm the account and create safe lab variables

Inspect the caller before creating anything. The GUID suffix makes the bucket name unlikely to collide with the shared S3 namespace.

PowerShellpowershell
aws --version
aws sts get-caller-identity
$env:LAB_REGION = "ap-south-1"
$env:LAB_BUCKET = "dr-lab-$([guid]::NewGuid().ToString('N').Substring(0,16))"
$env:LAB_BUCKET

Checkpoint

  • The caller identity is the sandbox account you intended to use.
  • The generated bucket name contains only lowercase letters, numbers, and hyphens.
02

Create the regional bucket

Create a general-purpose bucket in Mumbai. For Regions other than us-east-1, the CLI request includes the matching location constraint.

PowerShellpowershell
aws s3api create-bucket --bucket $env:LAB_BUCKET --region $env:LAB_REGION --create-bucket-configuration LocationConstraint=$env:LAB_REGION
aws s3api head-bucket --bucket $env:LAB_BUCKET

Checkpoint

  • create-bucket returns a Location value.
  • head-bucket exits successfully.
03

Upload one object

Create a tiny local JSON file and upload it as lab-object.json. The put-object body argument is a local file path.

PowerShellpowershell
'{"status":"hello from the Engineering Atlas"}' | Set-Content -Encoding utf8 .\lab-object.json
aws s3api put-object --bucket $env:LAB_BUCKET --key lab-object.json --body .\lab-object.json

Checkpoint

  • The response includes an ETag.
  • The local file is not empty.
04

Inspect before you delete

Practice evidence-first operations: inspect the exact object and list the bucket before cleanup.

PowerShellpowershell
aws s3api head-object --bucket $env:LAB_BUCKET --key lab-object.json
aws s3api list-objects-v2 --bucket $env:LAB_BUCKET --query "{count:KeyCount,objects:Contents[].{key:Key,size:Size}}"

Checkpoint

  • KeyCount is 1.
  • The key is lab-object.json and its size is greater than zero.

Verification

  • You can identify the AWS account and Region used for the exercise.
  • head-object returns metadata for lab-object.json.
  • list-objects-v2 reports exactly one object before cleanup.
  • The cleanup commands remove both the object and bucket.

Cleanup

Delete the object before the bucket, remove the local file, and then confirm that the bucket no longer exists. Keep the generated bucket name in your terminal until verification finishes. The final head-bucket command should fail because deletion is the expected state.

PowerShell
aws s3api delete-object --bucket $env:LAB_BUCKET --key lab-object.json
aws s3api delete-bucket --bucket $env:LAB_BUCKET --region $env:LAB_REGION
Remove-Item -LiteralPath .\lab-object.json
aws s3api head-bucket --bucket $env:LAB_BUCKET