/cloud-skills:cloud-resource-post-provisioning-validation-and-drift-detectionfrom cloud-skills
Verifies provisioned AWS/Azure/GCP resources match declared intent via Terraform plan drift checks, AWS Config conformance packs, Azure Policy compliance scans, and tag/policy compliance checks.
Ships in cloud-skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
None: SKILL.md is the whole skill.
Infrastructure-as-code declares intent, but the running cloud account is
the only source of truth for what's actually there — and the two diverge
constantly: a console click-fix during an incident that never made it
back into Terraform, a policy exemption granted temporarily and
forgotten, a resource created by an entirely separate pipeline or a
different team that the "official" IaC state doesn't know about. Left
unchecked, this drift compounds until nobody can say with confidence
what a terraform apply will actually change, whether tag/policy
guardrails from the landing zone are still being enforced, or whether a
resource flagged in a security review was ever actually remediated. This
skill covers detecting that divergence — via terraform plan drift
detection, AWS Config conformance packs, Azure Policy compliance scans,
and tag/policy checks against a declared baseline — as a recurring
operational practice, distinct from validating a deploy's success at
deploy time (covered in the CI/CD-specific skills) and distinct from
designing the guardrails being checked against (covered in the
landing-zone skills).
terraform apply diff later.terraform plan show unexpected
changes on an otherwise-untouched module."refresh/plan -refresh-only behavior is
stable from 1.x but confirm the exact drift-detection UX — plan -refresh-only was introduced in 1.1) with read access to the state
backend and the cloud provider's read-only API scope at minimum.gcloud asset search-all-resources inventory diffed against declared IaC.Run terraform plan in refresh-only mode to detect drift without
risking an unintended apply. This updates state to reflect real
infrastructure and shows the diff, without proposing to change
anything:
terraform plan -refresh-only -out=drift.tfplan
terraform show -json drift.tfplan | jq '.resource_changes[] | select(.change.actions != ["no-op"])'
Any non-empty output is drift: a resource's real-world state differs
from what Terraform's state file last recorded. Distinguish this from
a normal terraform plan (no -refresh-only), which also shows
config changes not yet applied — refresh-only isolates just the
"reality moved without us" signal.
Classify each drifted resource before deciding what to do.
most_recent resolution, an auto-assigned
ID) — usually safe to accept into state via terraform apply -refresh-only after review, or exclude via lifecycle { ignore_changes } if it recurs.plan will keep surfacing it as noise.terraform plan only reports
drift on resources it already knows about.Run AWS Config / Azure Policy / GCP Organization Policy compliance
scans for guardrail-level checks that terraform plan won't catch
(things that are compliant/non-compliant regardless of which tool
created the resource):
# AWS: check compliance status of a specific Config rule across the account
aws configservice get-compliance-details-by-config-rule \
--config-rule-name required-tags \
--compliance-types NON_COMPLIANT
# AWS: evaluate an entire conformance pack on demand rather than waiting for the next periodic scan
aws configservice start-config-rules-evaluation --config-rule-names required-tags encrypted-volumes
# Azure: list non-compliant resources for a specific policy assignment
az policy state list \
--filter "complianceState eq 'NonCompliant' and policyAssignmentId eq '<POLICY_ASSIGNMENT_ID>'" \
--query "[].{Resource:resourceId, Policy:policyDefinitionName}"
# GCP: list resources violating an Organization Policy constraint, via Security Command Center findings
gcloud scc findings list <ORGANIZATION_ID> \
--source=<SECURITY_HEALTH_ANALYTICS_SOURCE_ID> \
--filter="category=\"MFA_NOT_ENFORCED\" OR category=\"PUBLIC_BUCKET_ACL\""
These checks catch resources created entirely outside Terraform (a console-created S3 bucket, a manually spun-up VM) that a Terraform- only drift check would never see, since Config/Policy/SCC evaluate every resource in scope regardless of how it was created.
Reconcile the full resource inventory against IaC state to find unmanaged resources, not just drifted ones:
# AWS: list all resources of a type, compare resource IDs against terraform state
aws resourcegroupstaggingapi get-resources --resource-type-filters ec2:instance \
--query "ResourceTagMappingList[].ResourceARN" > all-instances.json
terraform state list | grep aws_instance # then diff resource IDs by hand or with a small script
# GCP: full asset inventory, diffable against declared Terraform-managed resources
gcloud asset search-all-resources --scope=projects/<PROJECT_ID> --asset-types=compute.googleapis.com/Instance
A resource present in the inventory but absent from Terraform state is either legitimately unmanaged (a one-off sandbox resource, fine as long as it's tagged and low-risk) or a governance gap (something that should have gone through IaC and didn't) — flag for the owning team to confirm which, don't assume.
Check tag/label compliance against the declared taxonomy specifically, since tag drift is usually the highest-volume, lowest- individual-severity finding and benefits from a dedicated query rather than being buried in general compliance output:
aws resourcegroupstaggingapi get-resources \
--tags-per-page 100 \
--query "ResourceTagMappingList[?!contains(Tags[].Key, 'cost-center')].ResourceARN"
az resource list --query "[?tags.\"cost-center\" == null].{Name:name, Type:type, ResourceGroup:resourceGroup}"
Feed missing-tag findings back into cloud-cost-finops-optimization's tag-backfill process rather than treating tag drift as a one-off cleanup.
Automate drift/compliance checks as a scheduled recurring job
(nightly or per-merge for terraform plan -refresh-only in CI;
Config/Policy scans typically run on their own periodic schedule but
confirm the evaluation frequency matches the risk tolerance — some
Config rules default to 24-hour periodic evaluation, which may be too
slow for a Tier 0 guardrail). Route findings to a dashboard or ticket
queue, not just a log nobody reads.
Decide remediation deliberately, and prefer proposing rather than auto-applying for anything beyond the most routine, pre-approved drift categories:
Warning: Auto-remediating drift (an automatic
terraform applyto force reality back to declared state, or an AWS Config auto-remediation action) can be as disruptive as an unreviewed manual change if the drifted state was actually a deliberate, undocumented fix (e.g. a security-group rule widened during an active incident, a manually scaled-up instance count keeping a degraded service afloat). Default to alerting a human with the diff and requiring explicit confirmation before applying any corrective change to production resources; reserve auto- remediation for narrowly scoped, well-understood, low-risk drift categories (e.g. re-tagging) with a proven track record of safety.
Track drift/compliance trend over time, not just point-in-time snapshots — a recurring scan that shows the same category of drift reappearing every cycle (e.g. the same security group repeatedly drifting wider) is a signal to fix the underlying process (who has console write access, why the IaC pipeline isn't the only path to change) rather than just reverting the symptom each time.
terraform plan -refresh-only for drift specifically, not a
regular plan, when the goal is "did reality diverge from last-known
state" rather than "what would applying pending config changes do" —
conflating the two makes it hard to tell whether a diff is drift or
an unapplied intentional change.Symptom: terraform plan shows unexpected changes on a resource
nobody touched in the Terraform config, and the team assumes it's a
provider bug.
Fix: This is almost always drift from an out-of-band change (a
console edit, a separate automation, an AWS-side attribute
auto-updating). Run terraform plan -refresh-only first to isolate
drift from pending config changes, and check CloudTrail/Activity
Log/Cloud Audit Logs for the resource ID over the relevant window to
identify who or what made the out-of-band change before assuming
tooling is at fault.
Symptom: A drift-detection job auto-applies terraform apply to
"fix" drift on a production resource, and it turns out the drift was a
deliberate manual mitigation an on-call engineer made during an active
incident, which the auto-apply just reverted mid-incident.
Fix: Never auto-remediate drift on production resources without
a human-reviewed confirmation step — this can undo a legitimate,
time-sensitive fix. Default drift detection to alert-and-propose, and
reserve automatic correction for narrowly scoped, pre-approved,
low-risk categories only (see step 7's warning).
Symptom: An AWS Config conformance pack shows 100% compliance, but
a manual review finds several non-compliant resources that were
created after the last scheduled evaluation.
Fix: Config rules have an evaluation frequency (often 24 hours by
default for periodic rules), and compliance status reflects the last
evaluation, not real time. For Tier 0 guardrails, trigger evaluation
on-demand after significant changes
(start-config-rules-evaluation) or switch to change-triggered
evaluation where the rule type supports it, rather than relying solely
on the periodic schedule.
Symptom: A resource shows up in the cloud console and in the
billing export, but nobody can find it in any Terraform state file
across any of the team's repositories, and it's unclear whether it's
safe to just leave alone.
Fix: This is an unmanaged resource, not drift — terraform plan
will never surface it since it isn't in state to begin with. Run the
full inventory reconciliation (step 4) on a recurring basis, not just
ad hoc when someone happens to notice, and require every unmanaged
resource to be explicitly classified (import into IaC, confirmed
legitimate one-off, or a candidate for
orphaned-cloud-resource-cleanup
if it also looks unused).
Symptom: Tag-compliance scans keep flagging the same handful of resources every cycle, and the finding gets silently ignored because it's become routine noise. Fix: A repeatedly-ignored recurring finding is worse than no finding at all — it trains reviewers to skip real issues. Either fix the resource (backfill the tag) or, if there's a legitimate reason it can never be tagged that way, add an explicit, documented policy exemption with an owner and expiry rather than letting it recur as unresolved noise indefinitely.
Scenario: A quarterly infrastructure audit is scheduled for the
payments-prod AWS account ahead of a compliance review, to confirm
provisioned resources match Terraform-declared intent and required
guardrails (encryption, tagging, no public S3 buckets) are actually
enforced.
terraform plan -refresh-only across all payments-prod-scoped
Terraform workspaces (step 1): the diff shows one drifted resource —
a security group's ingress rule now allows 0.0.0.0/0 on port 22,
where the declared config specifies a restricted CIDR.get-compliance-details-by-config-rule --config-rule-name s3-bucket-public-read-prohibited --compliance-types NON_COMPLIANT
returns zero results (compliant); a separate rule for
encrypted-volumes flags two EBS volumes without encryption enabled.resourcegroupstaggingapi get-resources
output with no matching entry in any known Terraform state — traced
via CloudTrail to a one-off instance launched directly via console
for a proof-of-concept two months ago and never imported into IaC or
decommissioned.cost-center tag, overlapping partly with
the untagged instance from step 4.What SKILL.md sets; muted values are Claude Code's defaults
npx claudepluginhub selvarajmurugesan90/ops-engineering-skills --plugin cloud-skills14 skills in this plugin
/aws-landing-zone-setupGuides designing and implementing a multi-account AWS landing zone using AWS Organizations, Control Tower, and Account Factory — including the account/OU hierarchy, Service Control Policies, centralized logging, and baseline guardrails. Use when a user asks to "set up a new AWS account structure", "design an AWS landing zone", "implement AWS Control Tower", "create OUs and SCPs", "bootstrap a multi-account AWS environment", or "onboard a new AWS account into our organization".
/azure-landing-zone-setupGuides designing and implementing an Azure landing zone using Management Groups, subscription democratization, Azure Policy, and the Cloud Adoption Framework (CAF) Landing Zone Accelerator pattern. Use when a user asks to "design an Azure landing zone", "set up Management Groups and subscriptions", "implement Azure Policy guardrails", "onboard a new Azure subscription", "structure our Azure tenant", or "migrate to the CAF enterprise-scale landing zone".
/cloud-access-request-and-iam-lifecycle-managementHandles the everyday operational request to grant, time-box, and later revoke a scoped IAM permission for a contractor, new hire, or a temporary need (e.g. "give the new contractor read-only S3 access for 30 days," "grant break-fix access to prod for this incident," "revoke Priya's access, she left the team," "why does this access request keep getting rejected") — including expiry enforcement and the audit trail a security review will ask for. Use for a single access grant/revoke transaction, not for designing the underlying IAM policy/role structure (see cloud-iam-hardening for that).
/cloud-cost-anomaly-investigationWalks through investigating an unexpected cost spike on this month's cloud bill right now — querying AWS Cost Explorer/CUR, Azure Cost Management, or GCP BigQuery billing export to isolate the specific resource, tag, and team responsible before it becomes a formal FinOps review. Use when a user asks "why did our AWS/Azure/GCP bill jump this week/month," "what's driving this cost anomaly alert," "find what resource caused this spike," or "who do I ask about this spend before the finance review." Distinct from cloud-cost-finops-optimization, which covers the ongoing tagging/rightsizing/commitment program this investigation is a single incident inside of.
/cloud-cost-finops-optimizationGuides establishing cloud cost visibility and reducing spend across AWS, Azure, and GCP through tagging/labeling discipline, rightsizing, commitment-based discounts (Reserved Instances, Savings Plans, Committed Use Discounts), and FinOps showback/chargeback practices. Use when a user asks to "reduce our cloud bill", "set up cost allocation tags", "find idle/oversized resources", "decide between Reserved Instances and Savings Plans", "implement FinOps", "explain why cloud spend went up", or "build a cost dashboard per team".
/cloud-iam-hardeningGuides hardening identity and access management across AWS, Azure, and GCP — least-privilege policy design, eliminating long-lived credentials in favor of federation (OIDC/Workload Identity), break-glass access, and periodic access review. Use when a user asks to "reduce IAM permissions", "remove unused IAM roles", "set up federated/keyless access for CI/CD", "harden our cloud identity posture", "review who has admin access", "implement least privilege", or "get rid of long-lived access keys".
Other plugins' skills for the same job