# AWS infrastructure lab

Original LockedIn Labs exercise · reviewed 20 October 2026.
Companion: /training/vendors#aws.

## Understand model requests before connecting AI

Use the [free model request workbook](/templates/cloud-model-request-workbook.md)
to separate the SDK, service endpoint, model and agent loop. Compare this
provider's normal text, output-limit and custom function responses. Then open
the [runnable response lab](/training/guides/cloud-responses): predict a decision,
run the standard-library Python adapter and change one synthetic response. No
cloud account or model key is needed; no function proposal is executed.

## What you will understand

An account owns resources. A VPC spans one Region; its subnets each occupy one
Availability Zone. An EC2 instance starts from an AMI and uses an instance type,
network interface and EBS volume. Build one private server, inspect it and
remove the dedicated lab resources. No GPU or model invocation is needed.

## Read a private request before changing access

This no-account exercise comes before provisioning. A private IP is an address,
not a guarantee of reachability or permission. DNS finds an address; routes and
traffic rules let a connection reach a listener; TLS verifies the server and
protects the connection; the application authorizes the requested data.

Draw a document assistant at `10.24.1.10` calling a records service at
`10.24.2.15:443` inside a Amazon VPC. These are fictional addresses.
The name `records.example.test` is for illustration only. Do not send requests
to these addresses. A port identifies the service endpoint on a host; this
example uses TCP port 443 for HTTPS.

Label the name lookup **Route 53 private hosted zone** and the traffic check
**effective security-group rules**. A DNS lookup does not carry the API request.
Account for forward and return routes, other applicable traffic controls and
the running server's listener. Application identity and data policy are separate.

For each case, write (1) what is observed, (2) what cannot yet be concluded,
and (3) the next observation or bounded action:

| Case | Supplied evidence | Your next step |
| --- | --- | --- |
| Only a timeout | DNS returns the intended address; a new TCP connection times out; no other path evidence | Explain why the firewall is not yet a proven cause. |
| A different address | DNS returns `10.24.2.99`; the deployment record expects `.15`; no connection attempted | Inspect the caller's DNS view before changing traffic or TLS settings. |
| A policy finding | An authorized investigation additionally establishes that this specific new connection is not allowed by the effective traffic policy | If the path is approved, scope a proposed change to the caller, destination and port, then retest. |
| The service says no | Connection and TLS succeed; the intended service's correlated log denies another customer's document; HTTP 403 | Preserve the denial and test an approved document with the same workload identity. |
| One approved read | The service identifies the caller, allows its document and returns the expected ID and revision; HTTP 200 | Record this success alongside the forbidden-read evidence. |

Review: a timeout alone does not distinguish routing, traffic policy, an
unavailable host or another connection failure. A private address may be the
wrong destination. Saving a rule does not prove a working request. A 403 alone
could originate at an intermediary; in this case the service's correlated log
identifies the denying layer. One permitted request does not establish readiness
for all callers, failures or loads. Never turn an unobserved layer into a pass.

The protected regions-and-networks lesson provides the visual version and
case-specific feedback. For a local runnable exercise with real sockets and
TLS, use the [free networking lab](https://training.lockedinlabs.ai/training/guides/networking).
This teaching case is separate from the isolated VM below: that VM deliberately
has no exposed application or inbound access. Do not open it merely to reproduce
the diagram.

## Before creating anything

Use an authorized sandbox account, current AWS CLI v2 and your organization's
approved sign-in flow. You need permission for the named EC2 operations and
reading the public image parameter. Check current prices, quota, organization
policy and an agreed cleanup time. This creates real resources and may incur
charges. Do not run with a production profile or use root credentials.

Use one shell, execute one block at a time, and stop on an error. Preserve the
returned resource IDs. Re-running a creation block can create another resource;
inspect the account before retrying. The named profile and Region are explicit.

```bash
LAB_PROFILE="replace-with-approved-training-profile"
LAB_REGION="us-east-1"
LAB_NAME="fde-lab-$(date +%Y%m%d%H%M%S)"
aws sts get-caller-identity --profile "$LAB_PROFILE"
aws ec2 describe-availability-zones --profile "$LAB_PROFILE" --region "$LAB_REGION" \
  --query 'AvailabilityZones[].{Name:ZoneName,Id:ZoneId,State:State}' --output table
```

Match the account ID against the approved account. Choose one available AZ from
the output and set `LAB_ZONE` below. Check that it belongs to `LAB_REGION`.

```bash
LAB_ZONE="replace-with-an-observed-zone-name"
LAB_AMI=$(aws ssm get-parameter --profile "$LAB_PROFILE" --region "$LAB_REGION" \
  --name /aws/service/ami-amazon-linux-latest/al2023-ami-kernel-default-x86_64 \
  --query Parameter.Value --output text)
aws ec2 describe-images --image-ids "$LAB_AMI" --profile "$LAB_PROFILE" --region "$LAB_REGION" \
  --query 'Images[].{Id:ImageId,Name:Name,Architecture:Architecture,Root:RootDeviceName}' --output table
aws ec2 describe-instance-types --instance-types t3.micro \
  --profile "$LAB_PROFILE" --region "$LAB_REGION" \
  --query 'InstanceTypes[].{Type:InstanceType,Architecture:ProcessorInfo.SupportedArchitectures}' --output table
```

Verify the official image is available and x86_64 matches the selected instance
type. Record the AMI ID; the public “latest” parameter changes over time.
The commands are not a claim that any particular Region has spare capacity.

## Create a dedicated private network

```bash
LAB_VPC=$(aws ec2 create-vpc --cidr-block 10.26.0.0/16 \
  --profile "$LAB_PROFILE" --region "$LAB_REGION" --query Vpc.VpcId --output text)
LAB_SUBNET=$(aws ec2 create-subnet --vpc-id "$LAB_VPC" --cidr-block 10.26.1.0/24 \
  --availability-zone "$LAB_ZONE" --profile "$LAB_PROFILE" --region "$LAB_REGION" \
  --query Subnet.SubnetId --output text)
LAB_SG=$(aws ec2 create-security-group --group-name "$LAB_NAME" \
  --description "Dedicated FDE training no inbound access" --vpc-id "$LAB_VPC" \
  --profile "$LAB_PROFILE" --region "$LAB_REGION" --query GroupId --output text)
```

There is no internet gateway or NAT gateway, and the new security group has no
inbound allow rules. The isolated VM will not be reachable by SSH or download
packages from the internet. That is intentional for this inspection exercise.

## Launch one instance

Before running the next block, confirm the image root device is `/dev/xvda`.
If your inspected image differs, change the mapping to its actual root device.

```bash
LAB_INSTANCE=$(aws ec2 run-instances \
  --image-id "$LAB_AMI" --instance-type t3.micro --count 1 \
  --subnet-id "$LAB_SUBNET" --security-group-ids "$LAB_SG" \
  --no-associate-public-ip-address --client-token "$LAB_NAME" \
  --metadata-options HttpTokens=required,HttpEndpoint=enabled \
  --block-device-mappings '[{"DeviceName":"/dev/xvda","Ebs":{"VolumeSize":8,"VolumeType":"gp3","Encrypted":true,"DeleteOnTermination":true}}]' \
  --tag-specifications "ResourceType=instance,Tags=[{Key=Name,Value=$LAB_NAME},{Key=Purpose,Value=fde-training}]" \
  --profile "$LAB_PROFILE" --region "$LAB_REGION" \
  --query 'Instances[0].InstanceId' --output text)
aws ec2 wait instance-running --instance-ids "$LAB_INSTANCE" \
  --profile "$LAB_PROFILE" --region "$LAB_REGION"
```

The image's root device must match `/dev/xvda` from the inspection above; change
the mapping if the selected official image differs. No key pair or application
role is attached. The root disk is encrypted and configured for deletion when
the instance terminates. The client token makes this exact launch idempotent;
it does not make the preceding network creation blocks idempotent.

## Inspect the actual server

```bash
aws ec2 describe-instances --instance-ids "$LAB_INSTANCE" \
  --profile "$LAB_PROFILE" --region "$LAB_REGION" \
  --query 'Reservations[].Instances[].{Id:InstanceId,State:State.Name,Image:ImageId,Type:InstanceType,AZ:Placement.AvailabilityZone,Private:PrivateIpAddress,Public:PublicIpAddress,Metadata:MetadataOptions,Disks:BlockDeviceMappings}'
aws ec2 describe-security-groups --group-ids "$LAB_SG" \
  --profile "$LAB_PROFILE" --region "$LAB_REGION" \
  --query 'SecurityGroups[].{Id:GroupId,Inbound:IpPermissions}'
```

Verify one instance, the intended AMI/AZ, no public IP, required metadata tokens
and empty inbound rules. Record the root volume ID from the returned mapping.
An instance state of `running` is not an application health result.

## Terminate and remove only this lab

Compare every ID with your recorded inventory first.

```bash
aws ec2 terminate-instances --instance-ids "$LAB_INSTANCE" \
  --profile "$LAB_PROFILE" --region "$LAB_REGION"
aws ec2 wait instance-terminated --instance-ids "$LAB_INSTANCE" \
  --profile "$LAB_PROFILE" --region "$LAB_REGION"
aws ec2 delete-security-group --group-id "$LAB_SG" \
  --profile "$LAB_PROFILE" --region "$LAB_REGION"
aws ec2 delete-subnet --subnet-id "$LAB_SUBNET" \
  --profile "$LAB_PROFILE" --region "$LAB_REGION"
aws ec2 delete-vpc --vpc-id "$LAB_VPC" \
  --profile "$LAB_PROFILE" --region "$LAB_REGION"
```

Confirm the root volume is deleted and the network resources are absent in the
console or with read-only describe commands. A terminated instance can remain
visible temporarily; that is different from a running instance. If cleanup is
blocked by a dependency, identify it rather than deleting unrelated resources.
Check billing for residual usage.

## Build the AI architecture on paper

Add a workload role, an authorized S3 source, a Bedrock model and a bounded tool
executor. Specify the exact model/API and permitted processing locations.
Prepare normal, denied-source and unavailable-model cases. Explain which
controls are cloud IAM and which belong to your application.

The live model lab is a separate exercise in the official provider environment.
This private VM lifecycle is not a production agent deployment.

## Follow the cost after an alert — no cloud account required

A budget is a plan for a scope and time period. A notification tells someone
that a threshold was reached or forecast. Enforcement is a separate control
that refuses work or changes a resource. A quota can limit requests or resources
without limiting the currency cost of the whole application.

Draw three cost streams for the fictional Field Desk: model usage, running
compute and retained data. Use these **invented teaching rates, not vendor
prices**: $14/hour for model usage, $4/hour for compute and $2/hour for retained
resources. Start with $80 already accrued and a $100 notification threshold.

1. At the end of hour 1, the total reaches $100. Assume notification and response
   occur two hours later, at the end of hour 3. This is a teaching delay, not a
   claim about the provider's reporting schedule.
2. Predict the total at the end of hour 6 for each response: notify only; stop
   new model work; stop new model work and release compute. Keep the data in
   every case. A response affects subsequent hours, not costs already accrued.
3. Draw each accumulated-cost line. Label the threshold, response time and each
   cost stream that remains. Explain why none of the lines stops at $100.
4. Repeat with an immediate response at the end of hour 1. What changes? What
   still costs money?
5. Write the scope, owner, action, required permission, remaining billable
   resources and safe restart rule for a real training environment. Keep this
   proposed design separate from an observed cloud result.

Review after making your prediction:

| Response | Hour 6 total: two-hour delay | Hour 6 total: immediate response |
| --- | ---: | ---: |
| Notify only | $200 | $200 |
| Stop new model work | $158 | $130 |
| Stop new model work and release compute | $146 | $110 |

For example, with the delayed compute response: $80 + (3 × $20) + (3 × $2)
= $146. Storage remains. This simplified exercise excludes in-flight requests,
commitments, taxes and other services; a real inventory must account for them.
Model token limits and bounded retries help control request costs, but do not
cap the entire cloud bill. Do not run a shutdown or delete data just to reproduce
this paper exercise.

AWS Budgets notifications and Budget actions are distinct. An action may
apply a policy or target selected EC2/RDS instances; review its permissions and
approval mode. Denying new provisioning does not stop existing workloads. An
EC2 stop can leave EBS volumes and other resources billable.

- [AWS Budgets and reporting delay](https://docs.aws.amazon.com/cost-management/latest/userguide/budgets-managing-costs.html)
- [Configuring Budget actions](https://docs.aws.amazon.com/cost-management/latest/userguide/budgets-controls.html)

Provider references checked 21 October 2026.

## Study map

Bring your account passport, network diagram, image/type compatibility check,
actual inventory and cleanup evidence to a peer review. Identify the remaining
service breadth, resilience, data and ML/AI implementation gaps.

- [AWS Solutions Architect training](https://aws.amazon.com/training/learn-about/architect/)
- [SAA-C03 exam guide](https://docs.aws.amazon.com/aws-certification/latest/solutions-architect-associate-03/solutions-architect-associate-03.html)
- [Generative AI Developer – Professional preparation](https://aws.amazon.com/certification/certified-generative-ai-developer-professional/)
- [EC2 run-instances reference](https://docs.aws.amazon.com/cli/latest/reference/ec2/run-instances.html)

These commands have not provisioned resources on your behalf. Record your own
sandbox observations; course completion does not award an AWS credential.
