Day 97 of DevOps, Day 47 of Azure. Both tasks produced an artefact that is correct, verified, and confers nothing.
An IAM policy attached to no principal grants no permission to anybody. A database export with no data in it restores to an empty database. Both exist, both pass their checks, and neither does the thing its name implies.
One Terraform task, one Azure task. An IAM policy, then a SQL database exported to blob storage. The tasks come from the KodeKloud Engineer platform.
Task 1: An IAM policy in Terraform
A policy named iampolicy_javed, read-only access to the EC2 console, permitting three Describe actions.
Step 1: The configuration
resource "aws_iam_policy" "iampolicy_javed" { name = "iampolicy_javed" description = "Read-only access to EC2 console" policy = jsonencode({ Version = "2012-10-17" Statement = [ { Effect = "Allow" Action = ["ec2:DescribeInstances", "ec2:DescribeImages", "ec2:DescribeSnapshots"] Resource = "*" } ] }) } IAM wants JSON and Terraform speaks HCL, so jsonencode() bridges them. The alternative is a heredoc holding literal JSON, and jsonencode is better for a reason you can see in the plan: Terraform renders the call expanded, one action per line, and diffs it per key. A heredoc is a single opaque string, so changing one character shows up as a whole-block replacement.
Step 2: Apply and verify
aws_iam_policy.iampolicy_javed: Creation complete after 0s Apply complete! Resources: 1 added, 0 changed, 0 destroyed. "PolicyName": "iampolicy_javed", "AttachmentCount": 0, "IsAttachable": true, What the docs recommend
Two things, and the first one corrects a criticism I was about to make of my own code.
Resource = "*" looks like somebody could not be bothered to scope the policy. Here they could not have. AWS states it directly: "The Amazon EC2 ec2:Describe* API actions do not support resource-level permissions", and "Therefore, the * wildcard is necessary in the Resource element of the above statement."
So these three actions cannot be narrowed by resource at all. The same page draws the contrast: "you can apply resource-level permissions on the ec2:RunInstances API action to restrict which resources users can use to launch an instance." Describe is a listing operation, and AWS does not filter listings per principal.
That cuts both ways. Flagging this wildcard in review would be wrong, and waving through a wildcard on a mutating action because the Describe one had it would be wrong in the much more expensive direction. The question is always whether that specific action supports resource-level permissions.
The second thing is the verification. I ran:
aws iam list-policies --query "Policies[?PolicyName=='iampolicy_javed']" That works, and it fetches every AWS-managed policy in the account, several hundred of them, before discarding them client-side with the filter. --scope Local restricts it server-side to customer-managed policies. Same answer, far fewer pages.
The thing I actually want to write down
"AttachmentCount": 0, The policy exists. No user, no group, no role is attached to it. An unattached managed policy is a document sitting in an account, and it authorises nobody to do anything.
Day 19 of this series was called "A Policy Is Just a Document Until It's Attached". That was about the same confusion in a different form, and the lesson survived seventy-eight days without my applying it here.
The task asked for the policy and only the policy, so the configuration is correct. What is worth noticing is that nothing in the verification distinguishes a working permission from an inert one. terraform state list shows the resource. list-policies shows the policy. AttachmentCount: 0 is the only field in any of that output which says the policy does nothing, and it sits in the middle of a JSON blob where it is easy to read past.
Task 2: Exporting a SQL database to blob storage
A SQL server and database, locally redundant backup storage, exported to a container and downloaded.
Step 1: Noticing that "backup" means two things
Task 1 of this lab configures the real backup system. --backup-storage-redundancy Local sets where Azure SQL writes its automatic backups: a weekly full, differentials, and transaction logs, retained seven days on Basic. That is what powers point-in-time restore, and it was already running before I touched anything else.
Task 3 is an export, which is a different thing wearing the same word. az sql db export produces a BACPAC, a portability package. It is not transactionally consistent on a live database, because the export reads tables sequentially with no snapshot, so a BACPAC taken while writes are happening can hold half a transaction. The documented workaround is to export from a copy.
That matters because "we take a nightly BACPAC" is a common backup strategy and a quietly broken one.
Step 2: Watching the export run
{ "requestType": "ExportDatabase", "queuedTime": "10/27/2026 4:46:20 AM", "lastModifiedTime": "10/27/2026 4:50:24 AM", "status": "Completed", "errorMessage": null } A queued time and a request ID. This is not something the database does. It is a job handed to the Azure SQL Import/Export service, which starts a worker, connects to my server as an ordinary SQL client, reads the data and writes the blob.
Three things follow. The worker comes in over the public endpoint, so the server firewall applies to it. It needs the SQL admin credentials because my ARM permissions submit the job and the SQL login reads the data. And it took four minutes for an empty database, which is worker provisioning rather than data transfer, so a small database does not export quickly.
Step 3: Opening the artefact
zip entries: 4 ['model.xml', 'DacMetadata.xml', '[Content_Types].xml', 'Origin.xml'] A BACPAC is an OPC package, which is a zip. Opening it and finding model.xml proves the export produced a valid package rather than something merely named like one. file was not installed on the lab host, which turned out not to matter: file reads magic bytes and would have said "Zip archive data" for any zip, including a corrupt one.
And then the thing that makes this day's two halves the same day.
There is no Data/ directory. A BACPAC of a database with rows contains Data/<schema>.<table>/TableData-0.BCP for each table. This one has none, because the database was created empty.
So the export is schema-only. 2770 bytes is an empty model.xml plus metadata. Running the task a second time proved it by accident: the second database was named xfusion-sqldb instead of devops-sqldb, one character longer, and the package came out at 2771 bytes. The database name is embedded in the schema, and with no data in the package, the name length is a measurable fraction of the whole thing.
A schema-only BACPAC restores to an empty database and looks, from outside, exactly like a successful recovery.
What the docs recommend
I failed the grader on this one, and the rule that came out of it has been useful since.
The backup file devops-db-backup.bacpac does not exist in the container The task says the backup file name is devops-db-backup in one place, and says to name the file based on its extension in another. I read that as two artefacts: the blob named exactly as stated, and the downloaded file carrying the extension. The grader reads the extension requirement as applying to both.
My reasoning was that an exact match on the literal name satisfies more of the stated requirements. That weighed two hypothetical graders against each other and missed the cheaper move entirely: the two readings do not conflict. A server-side blob copy costs one command and moves no bytes, so both names could have existed from the start.
Flagging an ambiguity and then picking a side is right when the options conflict. It is wrong when satisfying both is free. Check whether an ambiguity is actually a fork before choosing a branch.
That one paid for itself three days later, on an Application Gateway task where "a frontend IP configuration named X" could have meant the public IP resource or the gateway's own configuration object. They are independent names on different resources, so both got it, and there was no decision to make.
What I learned
ec2:Describe* actions do not support resource-level permissions, so the wildcard is required rather than careless.
An unattached managed policy grants nothing, and AttachmentCount: 0 is the only field that tells you.
aws iam list-policies returns AWS managed policies too. --scope Local is the server-side filter.
Automatic backups and a BACPAC export are different things sharing one word.
A BACPAC with no Data/ entries is schema-only, and only an import with a row count proves a backup is real.
Verify an archive by opening it and reading its member list.
Check whether an ambiguity is actually a fork.
So here is the Day 97 question. Of the things you built this month that passed their checks, how many are wired to anything? I have a policy and a backup today, and neither is connected to the thing that would make it matter.
Day 97 down. Three to go.
