You are asked to tag every untagged resource in an account with `Owner=unknown`. What questions do you ask and how do you implement it?
IntermediateScenarioAWS automation with boto3
Answer
Situation read → Bulk change across services; "untagged" and "every" need definitions.
What I'd do →
- Ask: which tag keys are required, which resource types, and is
unknowna real value or should we find the creator? - Find resources with the Resource Groups Tagging API (
get_resourcespaginator) and filter those missing the key. Note it only returns resources that have, or once had, tags; fully untagged resources may need per-service describes or AWS Config. - Look up creators via CloudTrail (
lookup_eventsforRunInstances) to set a real owner where possible. - Apply with
tag_resourcesin batches of 20 ARNs, dry-run first. - Prevent recurrence with tag policies and SCPs requiring tags on create.
Why → Backfilling once is pointless without enforcement going forward.
Interview tip → Say "find the creator in CloudTrail" before defaulting to unknown.
More on AWS automation with boto3
You are asked to write a script that stops all dev EC2 instances at 8 PM and starts them at 8 AM. How do you build it?BeginnerA script that lists all S3 objects in a bucket reports 1,000 objects, but the console says there are 48,000. What happened, and how do you fix the script?BeginnerYou need to find and delete EBS snapshots older than 90 days, but some are used by AMIs and backup plans. How do you write it safely?IntermediateYour audit script hits `ThrottlingException` / `RequestLimitExceeded` when scanning large accounts. What do you change?AdvancedYou must audit 40 AWS accounts in an Organization from one script. How do you handle credentials?AdvancedA Lambda written in Python times out at 15 minutes while processing a big S3 prefix. What are your options?Advanced