Cloud Resource Protection Mechanisms
Cloud providers offer native protection mechanisms that prevent resource deletion regardless of the caller's IAM permissions. These are your last line of defense when an AI agent has the permissions to delete but the resource itself refuses to be destroyed.
AWS Resource Protection
EC2 Termination Protection
When enabled, any API call to terminate-instances will fail, forcing the caller to first disable protection:
# Enable termination protection on existing instances
aws ec2 modify-instance-attribute \
--instance-id i-0abc123def456 \
--disable-api-termination
# Enable at launch time via Terraform
resource "aws_instance" "production" {
ami = "ami-0abcdef1234567890"
instance_type = "m6i.xlarge"
disable_api_termination = true
tags = {
Name = "production-web-server"
Environment = "production"
Protected = "true"
}
}
RDS Deletion Protection
# Enable on existing database
aws rds modify-db-instance \
--db-instance-identifier prod-database \
--deletion-protection \
--apply-immediately
# Terraform configuration
resource "aws_rds_instance" "production" {
identifier = "prod-database"
engine = "postgres"
instance_class = "db.r6g.xlarge"
deletion_protection = true
lifecycle {
prevent_destroy = true
}
}
S3 Object Lock
S3 Object Lock prevents objects from being deleted or overwritten for a specified retention period. This is critical for compliance and backup data:
# Create bucket with Object Lock enabled (must be set at creation)
aws s3api create-bucket \
--bucket critical-backups \
--object-lock-enabled-for-bucket
# Set default retention policy (Governance mode - admin can override)
aws s3api put-object-lock-configuration \
--bucket critical-backups \
--object-lock-configuration '{
"ObjectLockEnabled": "Enabled",
"Rule": {
"DefaultRetention": {
"Mode": "GOVERNANCE",
"Days": 90
}
}
}'
# Compliance mode - NOBODY can delete, not even root
# Use for regulatory requirements
aws s3api put-object-lock-configuration \
--bucket regulatory-data \
--object-lock-configuration '{
"ObjectLockEnabled": "Enabled",
"Rule": {
"DefaultRetention": {
"Mode": "COMPLIANCE",
"Days": 2555
}
}
}'
Azure Resource Locks
Azure provides two types of resource locks that apply at the resource, resource group, or subscription level:
| Lock Type | Effect | Use Case |
|---|---|---|
| CanNotDelete | Allows read and modify, blocks delete | Production resources that may need updates but must never be deleted |
| ReadOnly | Allows read only, blocks modify and delete | Critical infrastructure that should never change (DNS zones, core networking) |
# Lock an entire resource group against deletion az lock create \ --name "protect-production" \ --resource-group production-rg \ --lock-type CanNotDelete \ --notes "AI agent safety: prevent accidental resource group deletion" # Lock a specific resource as read-only az lock create \ --name "protect-prod-db" \ --resource-group production-rg \ --resource-name prod-sql-server \ --resource-type Microsoft.Sql/servers \ --lock-type ReadOnly # Lock at subscription level (protects everything) az lock create \ --name "subscription-delete-lock" \ --lock-type CanNotDelete \ --notes "Subscription-wide deletion protection"
GCP Resource Protection
Project Liens
Project liens prevent a GCP project from being deleted. This is the strongest protection available:
# Create a lien to prevent project deletion gcloud alpha resource-manager liens create \ --project=production-project \ --restrictions=resourcemanager.projects.delete \ --reason="Production project - deletion blocked for AI agent safety" # Enable deletion protection on a Compute Engine instance gcloud compute instances update prod-web-server \ --zone=us-central1-a \ --deletion-protection # Enable deletion protection on a Cloud SQL instance gcloud sql instances patch prod-database \ --deletion-protection
Cross-Cloud Tagging Strategies
Use consistent tagging across all clouds to identify which resources are protected and why:
# Standard tags for all critical resources:
tags = {
Environment = "production" # production, staging, development
CriticalityLevel = "high" # high, medium, low
DeletionProtected = "true" # Indicates protection is enabled
Owner = "platform-team" # Team responsible
AgentAccess = "read-only" # What AI agents are allowed to do
BackupRetention = "90-days" # How long backups are kept
LastReviewDate = "2026-03-15" # When protection was last reviewed
}
DeletionProtected tag before allowing any destructive operation. Even if cloud-native protection is somehow bypassed, the tag check adds another layer of defense.Backup and Recovery as Safety Nets
Even with all protections in place, maintain backup and recovery capabilities as your ultimate safety net:
Automated Snapshots
Schedule automated EBS snapshots, RDS snapshots, Azure VM backups, and GCP persistent disk snapshots. Retain for at least 30 days with cross-region replication.
S3/Blob Versioning
Enable versioning on all storage buckets. Even if an AI agent deletes objects, previous versions are retained and recoverable.
Database Point-in-Time Recovery
Enable automated backups with point-in-time recovery on all databases. AWS RDS, Azure SQL, and Cloud SQL all support this natively.
Infrastructure State Backups
Maintain versioned copies of Terraform state files, Pulumi state, and CloudFormation templates so you can rebuild infrastructure from known-good state.
Ready to Go Deeper?
Live instructor-led courses from our partners. Affiliate disclosure.
AI & ML Courses - 30% Off
Live instructor-led AI, machine learning, data science, and cloud courses for working professionals. Use code Limited30 at checkout.
EdurekaDataCamp - AI & Data Science
Hands-on Python, machine learning, and AI courses with interactive exercises and real projects.
DataCampedX - Top AI Courses
University-level AI courses from MIT, Harvard, Stanford. Earn certificates that employers recognize.
edX