First AWS tutorial's sandbox is failing at "terraform apply."

While I wait for somebody to take pity on me with my previous question on authentication, I’ve gone to the interactive sandboxed lab at the bottom of the “aws-get-started/aws-create” tutorial page. I get as far as “aws configure list” just fine. Then, I tried the “terraform apply,” and got this:

# terraform apply
data.aws_ami.linux: Reading...
data.aws_ami.linux: Still reading... [00m10s elapsed]
data.aws_ami.linux: Still reading... [00m20s elapsed]
╷
│ Error: reading EC2 AMIs: operation error EC2: DescribeImages, exceeded maximum number of attempts, 9, https response error StatusCode: 0, RequestID: , request send failed, Post "http://localhost:4566/": dial tcp 127.0.0.1:4566: connect: connection refused
│ 
│   with data.aws_ami.linux,
│   on main.tf line 16, in data "aws_ami" "linux":
│   16: data "aws_ami" "linux" {
│ 
╵

What happened?

Good news first: nothing is wrong with your Terraform config. Port 4566 is the edge port of LocalStack - their docs describe 4566 as the port you expose and connect to - and the tutorial’s interactive lab uses exactly that to emulate AWS locally. “Connection refused” means the emulator inside your lab session isn’t running, so the data.aws_ami read never even reached the fake AWS; that’s a sandbox hiccup, not a Terraform problem. Restart the lab, and if it happens again, check inside the lab session whether the localstack service is actually up before running terraform apply. Your “aws configure list” succeeding fits this picture: it only reads local config values and makes no service calls.

Ok, and how do I do that? Up until this exercise, I’d never heard of localstack. Is the lab session running on my Mac, or is it a remote connection to something elsewhere?

I started a Claude session about this. After several exchanges, I finally ended up with:

# docker logs localstack

LocalStack version: 2026.10.0
LocalStack build date: 2026-10-13
LocalStack build git hash: 738d58ee

Localstack returning with exit code 55. Reason: 
===============================================
License activation failed! 🔑❌

Reason: No credentials were found in the environment. Please set the LOCALSTACK_AUTH_TOKEN variable to a valid auth token. Alternatively, run `lstk login` and start LocalStack with the lstk CLI, which configures the credentials for you.

Due to this error, Localstack has quit. LocalStack pro features can only be used with a valid license.

- Please check that your credentials are set up correctly and that you have an active license.
  You can find your credentials in our webapp at https://app.localstack.cloud.

It seems that the sandbox is legitimately broken.

To answer the question above: it is all local. The lab runs LocalStack in a Docker container on your own Mac, which is exactly why Terraform errors against 127.0.0.1:4566 and why docker logs works on your machine. Your own log already shows what changed: the container starts now but quits with exit 55, because current LocalStack images require an Auth Token at startup - the LocalStack docs describe this license activation step as mandatory for the current image. Fix: sign into the LocalStack web app, copy your Auth Token from the Auth Tokens page, and start the container with LOCALSTACK_AUTH_TOKEN set (or run lstk login, as the log itself suggests). Once the logs say Ready instead of quitting, terraform apply should get its fake AWS back.