Day 98 of DevOps, Day 48 of Azure. In both tasks, the property that decides everything lives somewhere other than the obvious place.

The instance is private because of a route table that does not appear anywhere in my configuration. The container works because of a requirement that reads like padding in the task description.

One Terraform task, one Azure task. An EC2 instance in a private subnet, then a containerised app pulling its config from blob storage. The tasks come from the KodeKloud Engineer platform.

Task 1: An EC2 instance in a private subnet

A VPC, a private subnet, a security group that allows traffic only within the VPC CIDR, and a t2.micro instance in that subnet.

Step 1: Variables first

variable "KKE_VPC_CIDR" { default = "10.0.0.0/16" } variable "KKE_SUBNET_CIDR" { default = "10.0.1.0/24" } 

Worth one line on why this matters beyond ticking the requirement. The security group rule references var.KKE_VPC_CIDR rather than repeating 10.0.0.0/16 as a literal. Change the VPC CIDR and the rule follows. The alternative is two places that silently drift apart, and the drift shows up as traffic being refused for no visible reason.

Step 2: The subnet and the instance

resource "aws_subnet" "nautilus_priv_subnet" { vpc_id = aws_vpc.nautilus_priv_vpc.id cidr_block = var.KKE_SUBNET_CIDR map_public_ip_on_launch = false tags = { Name = "nautilus-priv-subnet" } } 
"PrivateIpAddress": "10.0.1.4", "PublicDnsName": "None", "Groups": [ { "GroupName": "nautilus-priv-sg" } ] 

No public IP, no public DNS name, and the instance is in the named security group. That last one is a small win over two days ago, where I omitted vpc_security_group_ids and the instance silently landed in the VPC's default group.

Step 3: Working out what actually made it private

This is the bit I want to write down, because my configuration contains no evidence of it.

AWS defines a public subnet by its route table: "It has a route that sends all traffic to the internet gateway, which is what makes the subnet a public subnet."

There is no aws_internet_gateway in my configuration and no aws_route_table. So the VPC has no internet gateway at all, and the subnet has no route table explicitly associated with it, which means the main route table applies: "When a subnet does not have an explicit routing table associated with it, the main routing table is used by default." And that table has exactly one entry, because "Every route table contains a local route for communication within the VPC."

One local route covering 10.0.0.0/16, and nothing else. That is the entire reason the instance cannot reach the internet, and it is three resources I never wrote.

Which means map_public_ip_on_launch = false is not doing the job people usually think it does. It stops the subnet from handing out automatic public IPs. It does not make the subnet private. A subnet whose route table has an internet gateway route is a public subnet whether or not that flag is set, and instances there just need an Elastic IP to use the path.

One honest caveat: AWS documents the positive case, the IGW route making a subnet public, and does not give a one-sentence definition of a private subnet. The nearest thing on the same page is a VPN-only subnet, with "no route to the internet gateway, which is what makes the subnet a VPN-only subnet." So "private means no IGW route" is the documented pattern applied by negation, not a quoted definition.

What the docs recommend

The egress rule is the interesting one here.

 egress { from_port = 0, to_port = 0, protocol = "-1", cidr_blocks = [var.KKE_VPC_CIDR] } 

The task says to allow access only from within the VPC CIDR, which reads as a statement about inbound traffic. I applied it outbound too. In this topology, that changes nothing, because there is no route out for the rule to restrict. Two independent mechanisms now block internet egress, and only one is doing any work.

It is still the right configuration, for a reason that cost me on Day 95. That security group had no egress block at all, and the provider removes the AWS default allow-all egress rule when it creates a group, so the result was a group with no outbound permission whatsoever and an instance where everything timed out. Here the block is present and says what it means. And if somebody later attaches an internet gateway and writes a route, the security group still refuses.

The -1 form is documented and strict: "If you select a protocol of -1 (semantically equivalent to all, which is not a valid value here), you must specify a from_port and to_port equal to 0." The string all is not accepted. Only -1 is.

One more thing I would want on a real build. Nobody can log into this instance: no key pair, no public IP, no gateway, no NAT. The modern answer is Systems Manager Session Manager, and that does not work here either, because the SSM agent has to reach the SSM endpoints, and from a subnet with no NAT that means interface VPC endpoints for ssm, ssmmessages and ec2messages. So "launch an EC2 in a private subnet" produces a machine that is running, correct, and unreachable by every route. For the task, that is the point. For anything real, it is the next three resources.

Task 2: A containerised app pulling config from blob storage

Build an image, push it to a registry, run it on a VM, and have it serve content from a blob.

Step 1: Reading the Dockerfile before planning anything

with open("config.json", "r") as f: config = json.load(f) 
COPY app.py /app/ # app.py, and nothing else 

The app opens config.json relative to /app. The image contains app.py and nothing else. Build it exactly as specified, run it, and every request raises FileNotFoundError and returns a 500.

And config.json sits at /root/config.json while the build context is /root/pyapp/, so adding a COPY for it would fail at build time too. The file is outside the build context on purpose.

So the task's stated validation, "confirm the application can be accessed on the browser", is unreachable from the provided materials alone.

Step 2: Noticing which requirements are load-bearing

Three lines in the task read like filler:

Requirement Why it exists
"to interact with an Azure Blob Storage container for storing and retrieving data" The retrieval is the fix
"Install Docker and Azure CLI on the VM" The CLI is how the VM retrieves the blob
"Upload a file named config.json to the container" That blob is the app's missing file

Docker alone runs the container. Azure CLI on a VM that only pulls from a registry has no job at all, because docker login with registry credentials does not need it. The CLI is there to fetch config.json, and once you see that the task has one shape instead of four unrelated ones.

az storage blob download -c xfusion-config -n config.json -f /home/azureuser/config.json sudo docker run -d -p 80:80 -v /home/azureuser/config.json:/app/config.json:ro \ $ACR.azurecr.io/xfusion/python-app:latest 

A bind mount rather than a rebuild, which keeps the provided Dockerfile untouched and matches how configuration is supposed to reach a container: injected at runtime, so one image runs against different configs.

Step 3: The single quotes that prove it worked

Welcome to KKE Azure Labs: {'key': 'value', 'version': 1} 

The blob contains double quotes. The response has single quotes because the app interpolates a Python dict into an f-string rather than re-serialising it.

Which is more informative than it looks. Single quotes mean json.load() ran and returned a dict. A file that was present but malformed would have raised JSONDecodeError and returned a 500. So this proves the file was found and parsed, whereas a 200 with echoed text would only prove it was found.

What the docs recommend

Three habits, and one admission.

Compare the digest, not the tag. The image reported sha256:d5ff44bb... at push, at pull and in the registry manifest. "The pull succeeded" does not establish that you got the right image: a stale latest, or a cached layer set, produces a successful pull too. latest is the most mutable tag there is.

Run the local curl before the external one. curl 127.0.0.1 on the VM proves Flask is running and the mount delivered a parseable file. curl from outside proves that, plus the published port and the NSG rule. Doing the local one first means a failing external request has one candidate instead of four.

Add the rule to the NSG that az vm create built, rather than attaching one you made earlier. Attaching a named NSG replaces its rule set, which cost me a whole afternoon on Day 43.

The admission is this:

az acr repository show-manifests ... 2>/dev/null || az acr manifest list-metadata ... 

That produced the right output, and I cannot tell which half produced it. The first command is deprecated in favour of the second, both queries were identical, and the 2>/dev/null swallowed whatever the first one said. Second time this habit has cost me clarity, which is why it is in the notes rather than quietly fixed.

What I learned

A route to an internet gateway is what makes a subnet public. No gateway and no route table means the main route table and its single local route.

map_public_ip_on_launch = false stops the automatic public IP. It does not make a subnet private.

protocol = "-1" requires both ports to be 0, and all is not a valid value.

A private instance with no NAT cannot reach Systems Manager either, so Session Manager needs VPC endpoints.

Read every provided file before planning. A file deliberately placed outside the build context is telling you it arrives at runtime.

Requirements that look decorative are often the fix.

Compare the digest at push, pull and manifest.

Never 2>/dev/null the first half of a fallback chain.

So here is the Day 98 question. For the thing in your infrastructure that is safe right now, can you name the resource that makes it safe? Mine was three resources that did not exist, which is a fine answer until somebody adds one of them for an unrelated reason.

Day 98 down. Two to go.