Day 100: An Alarm With No Subscriber and App Gateway Built in Seconds
Day 100 of DevOps, Day 50 of Azure. The last ones, and the two halves, say opposite things about the hundred.
The Terraform half is the third task running, whose final link is missing. The Azure half is the same Application Gateway I built on Day 43, done in a fraction of the time, because the things that cost me then were written down.
One Terraform task, one Azure task. A CloudWatch alarm, then a gateway distributing traffic across two VMs. The tasks come from the KodeKloud Engineer platform.
Task 1: A CloudWatch alarm on EC2 CPU
An instance and an alarm at 90 per cent CPU, notifying an SNS topic that already exists.
Step 1: The configuration
resource "aws_cloudwatch_metric_alarm" "devops_alarm" { alarm_name = "devops-alarm" comparison_operator = "GreaterThanOrEqualToThreshold" evaluation_periods = 1 metric_name = "CPUUtilization" namespace = "AWS/EC2" period = 300 statistic = "Average" threshold = 90 dimensions = { InstanceId = aws_instance.devops_ec2.id } alarm_actions = [aws_sns_topic.sns_topic.arn] } "StateValue": "INSUFFICIENT_DATA", "StateReason": "Unchecked: Initial alarm creation", "Dimensions": [{ "Name": "InstanceId", "Value": "i-83214e38eeb3ed132" }] Every requirement met: threshold, comparison, metric, the dimension tying it to this instance, and the SNS action.
Step 2: The topic I accidentally took ownership of
The task says devops-sns-topic already exists. I wrote:
resource "aws_sns_topic" "sns_topic" { name = "devops-sns-topic" } A resource block is a claim of ownership. It tells Terraform this object is part of the desired state, which means Terraform will create it if absent, reconcile it if it drifts, and delete it on terraform destroy. A topic the task describes as pre-existing is now something a teardown of my configuration would remove.
The right form for something you reference but do not own is a data source:
data "aws_sns_topic" "existing" { name = "devops-sns-topic" } A data source reads. It never creates, modifies or destroys.
What makes this worth writing down is that it never announced itself:
aws_sns_topic.sns_topic: Refreshing state... [id=arn:aws:sns:...:devops-sns-topic] Plan: 2 to add SNS CreateTopic is idempotent on an existing name, returning the existing topic rather than erroring. So the first apply adopted the topic silently, the plan was clean, the apply was clean, and the state file now believes it owns something it did not make.
Step 3: Following the notification
aws sns list-topics One topic. Nothing in this task creates or shows a subscription to it.
An SNS topic with no subscribers accepts a publish and delivers it to nobody. So the chain is: CPU crosses 90, CloudWatch changes the alarm state, the alarm publishes, and the message stops there. Every component is correct, and the notification reaches no one.
That is three days running. Day 97 was a policy attached to no principal. Day 99 was a role with no instance profile. Today is an alarm notifying a topic with no subscriber. None of the three is a configuration error. All three pass their verification. In all three, the artefact is one hop short of doing its job.
What the docs recommend
The state the alarm is sitting in, and the number that decides whether it ever leaves.
INSUFFICIENT_DATA is correct here rather than a fault. treat_missing_data defaults to missing, and the docs say what that does: "missing – If all data points in the alarm evaluation range are missing, the alarm transitions to INSUFFICIENT_DATA." A brand-new alarm on a brand-new instance has no data points yet.
One exception worth carrying, which lands neatly after yesterday's DynamoDB task: "Alarms that evaluate metrics in the AWS/DynamoDB namespace default to ignore missing data." The default is namespace-dependent.
Then the period. My instance reports "Monitoring": { "State": "disabled" }, so detailed monitoring is off, and AWS documents the difference: "Amazon EC2 detailed monitoring provides more frequent metrics, published at one-minute intervals, instead of the five-minute intervals used in Amazon EC2 basic monitoring."
So this instance publishes CPU every five minutes, and period = 300 is five minutes. They match, which is why the alarm will start evaluating once the first datapoint lands. Set period = 60 on the same instance and four evaluation windows in five are empty, so the alarm sits in INSUFFICIENT_DATA more or less permanently. Either match the period to the interval or pay for detailed monitoring.
To be straight about the sourcing: AWS documents both intervals and documents what missing does. It gives no explicit guidance on matching an alarm period to the publishing interval, so that conclusion follows from the two documented facts rather than from a sentence saying it.
Two smaller things. evaluation_periods = 1 fires on a single five-minute average, including one compile or one backup job; two or three periods is the usual trade. And I ran describe-alarms twice with identical arguments, labelled "verify the alarm exists" and "verify the alarm is monitoring your instance". Identical command, identical output. The second question is real, and the first output already answered it, in the Dimensions field. Two checks that are the same check is one check wearing a second label.
Task 2: An Application Gateway across two VMs
Two VMs serving different content, behind a gateway that distributes between them.
Step 1: Everything Day 43 cost me, skipped
This is the same build as Day 43, and the difference is the point of keeping notes at all.
| Day 43 | Day 50 | |
|---|---|---|
Discovering the policy blocks Standard_v2 | A failed create | Skipped |
Discovering the CLI --sku has no Basic | A --help grep after the failure | Skipped |
| Deciding CLI versus ARM | Worked through a port-conflict plan first | Template from the start |
| Pre-flight | Added after the fact | Validate, before anything |
| NSG rule timing | Failed. --nsg <name> destroyed the rule | Added to the auto-created NSG |
| Gateway writes | Would have been nine via CLI | One deployment |
Two policy facts and one CLI gap cost a failed create and a help lookup the first time, and nothing the second. az deployment group validate came back in seconds, confirming the SKU, the API version and the policy in one call, before committing to a ten-minute deploy.
Four more decisions came straight from earlier notes with no rediscovery: no NSG on the gateway subnet, a Standard static public IP, NSG rules added to the auto-created NSGs with names derived from each NIC's resource ID, and the VMs created before the gateway so concurrent VNet writes could not collide.
Step 2: The requirement that is actually the instrument
The task asks for "Version 1" on one VM and "Version 2" on the other, which reads like arbitrary filler.
20 requests through the gateway: 10 Welcome to KKE Labs:Version 1 10 Welcome to KKE Labs:Version 2 Had both VMs served identical content, every possible gateway behaviour would produce identical output. A gateway sending everything to VM1, a gateway with one backend removed, a gateway with VM2 unhealthy, and a correctly balancing gateway would all return the same string to every request. The distribution would be invisible from the client.
So the two strings are a per-backend fingerprint. That is the difference between "the gateway responds" and "the gateway distributes".
Three things followed. I checked each VM on its own public IP first, so a silently failed cloud-init could not be mistaken for a routing fault. I counted twenty requests rather than sampling one, because a tally proves proportion. And cookieBasedAffinity: Disabled is what permits the test at all: with affinity on, the gateway pins a client to one backend, and a correct configuration reads as broken.
What the docs recommend
Exactly 10 and 10 is worth a second look. A fair random choice over 20 requests lands there about 18 per cent of the time. Deterministic round-robin lands there every time. Microsoft documents Application Gateway as using round-robin, and this is consistent with that rather than with random selection.
One trial is not a proof, and the exactness is the informative part. A 13 to 7 split would have been equally good evidence of distribution and would have said nothing about how the gateway chooses. Which changes what an uneven split means later: under round-robin it points at something real, like a backend failing a probe mid-test.
Two more that cost nothing and catch silent failures.
The gateway reports provisioningState: Updating during initial creation and never Creating. My poll loop broke on Succeeded|Failed, so it did not care. A loop waiting while the state equals Creating would have exited on the first reading and declared the gateway ready ten minutes early. Wait for the terminal state, not for the absence of a transitional one.
And cloud-init fails silently. A malformed file boots a VM that reports success, serves nothing, and buries the evidence in a log on a machine you then have to reach. So I parsed it locally first, and the useful part was not that the YAML was valid but that the extracted content came back as 'Welcome to KKE Labs:Version 1\n', proving the literal block scalar had captured the colon intact without any shell quoting.
What I learned
A resource block claims ownership. For something that already exists and you only reference, use a data source, or terraform destroy will delete it.
An SNS topic with no subscribers accepts a publish and delivers it to nobody.
treat_missing_data defaults to missing, and the default is namespace-dependent.
An alarm period shorter than the metric's publishing interval leaves mostly empty evaluation windows.
Two identical commands with two different labels is one check, and an output that reads a value set in the same file is an echo rather than a verification.
Distinct content per backend is what makes distribution observable at all.
Wait on terminal states, and parse cloud-init before you use it.
And the one the second half of today is entirely about: a constraint written down once costs nothing the second time.
So here is the last question. What did you write down this year that you have since needed twice? Day 43 cost me an afternoon and Day 50 cost me nothing, and the only difference between them was a paragraph in a file.
Day 100 down. That is the hundred.