Alibaba Cloud Support
Terratags supports Alibaba Cloud (AliCloud) resources through the alicloud provider. AliCloud uses the same tag format as AWS, making it straightforward to validate tags across your AliCloud infrastructure.
Supported Resources
Terratags supports a comprehensive list of AliCloud resources that have tagging capabilities, including:
Compute Services
alicloud_instance- ECS instancesalicloud_reserved_instance- Reserved instancesalicloud_ecs_instance_set- Instance setsalicloud_simple_application_server_instance- Simple application servers
Storage Services
alicloud_oss_bucket- Object Storage Service bucketsalicloud_oss_bucket_object- OSS objects
Database Services
alicloud_db_instance- RDS instancesalicloud_mongodb_instance- MongoDB instancesalicloud_redis_tair_instance- Redis instancesalicloud_kvstore_instance- KVStore instances- And many more database services...
Networking
alicloud_vpc- Virtual Private Cloudsalicloud_vswitch- Virtual switchesalicloud_security_group- Security groupsalicloud_nat_gateway- NAT gatewaysalicloud_eip- Elastic IP addressesalicloud_slb- Server Load Balancers
Container Services
alicloud_cs_kubernetes_cluster- Kubernetes clustersalicloud_cs_managed_kubernetes- Managed Kubernetesalicloud_cs_serverless_kubernetes- Serverless Kubernetes
Security Services
alicloud_kms_key- KMS keysalicloud_bastionhost_instance- Bastion hostsalicloud_waf_instance- Web Application Firewallalicloud_cloud_firewall_instance- Cloud Firewall
And many more services across analytics, messaging, CDN, and other categories.
Tag Format
AliCloud uses the same tag format as AWS - a simple key-value map:
resource "alicloud_instance" "example" {
availability_zone = "cn-beijing-a"
instance_type = "ecs.n4.large"
image_id = "ubuntu_18_04_64_20G_alibase_20190624.vhd"
tags = {
Name = "web-server-01"
Environment = "production"
Project = "ecommerce"
Owner = "devops@company.com"
}
}
Tag Constraints
AliCloud has specific constraints for tag keys and values:
- Key: Up to 128 characters, cannot begin with "aliyun", "acs:", "http://", or "https://", cannot be null
- Value: Up to 128 characters, cannot begin with "aliyun", "acs:", "http://", or "https://", can be null
Configuration Example
Here's a complete example of using Terratags with AliCloud resources:
config.yaml:
required_tags:
Name: {}
Environment:
pattern: "^(dev|test|staging|prod)$"
Project: {}
Owner:
pattern: "^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$"
main.tf:
resource "alicloud_instance" "web" {
availability_zone = "cn-beijing-a"
instance_type = "ecs.n4.large"
image_id = "ubuntu_18_04_64_20G_alibase_20190624.vhd"
tags = {
Name = "web-server"
Environment = "prod"
Project = "website"
Owner = "devops@company.com"
}
}
resource "alicloud_oss_bucket" "assets" {
bucket = "company-assets-bucket"
tags = {
Name = "assets-bucket"
Environment = "prod"
Project = "website"
Owner = "devops@company.com"
}
}
Validation:
Pattern Validation
AliCloud resources support the same advanced pattern validation as other providers:
required_tags:
Environment:
pattern: "^(dev|test|staging|prod)$"
Owner:
pattern: "^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$"
Project:
pattern: "^[a-zA-Z0-9][a-zA-Z0-9-]*[a-zA-Z0-9]$"
Default Tags
Unlike AWS, AliCloud provider does not support default_tags at the provider level. All required tags must be specified at the resource level.
Volume Tags
ECS instances also support volume_tags for tagging attached storage devices:
resource "alicloud_instance" "example" {
# ... other configuration ...
tags = {
Name = "web-server"
Environment = "production"
}
volume_tags = {
VolumeType = "SystemDisk"
Backup = "Required"
}
}
Exemptions
You can exempt specific AliCloud resources from tag requirements:
exemptions:
- resource_type: alicloud_oss_bucket
resource_name: logs_bucket
exempt_tags: [Owner, Project]
reason: "Legacy bucket used for system logs only"
- resource_type: alicloud_instance
resource_name: "*"
exempt_tags: [Environment]
reason: "Environment determined by VPC placement"
Integration with Terraform Plan
Terratags can validate AliCloud resources in Terraform plans, including resources created by modules:
terraform plan -out=tfplan
terraform show -json tfplan > plan.json
terratags -config config.yaml -plan plan.json
This provides comprehensive validation across your entire AliCloud infrastructure, including resources created by external modules.