Updated on 2023-08-11 GMT+08:00

Resources

Resources are the most important element in the Terraform language and are declared using the keyword resource. Each cloud service supported by the provider corresponds to one or more resources. For example, indicates ECS, and indicates VPC.

Resource Reference

You can use an expression to reference a resource attribute in the format of <Resource type>.<Name>.<Attribute>. Assume that a huaweicloud_compute_instance resource named myinstance has been created. The following is an example:

# Instance ID
> huaweicloud_compute_instance.myinstance.id
55534eaa-533a-419d-9b40-ec427ea7195a

# Instance security group
> huaweicloud_compute_instance.myinstance.security_groups
["default", "internet"]

# IP address of the first NIC of the instance
> huaweicloud_compute_instance.myinstance.network[0].fixed_ip_v4
192.168.0.245

# IP addresses of all NICs of the instance
huaweicloud_compute_instance.myinstance.network[*].fixed_ip_v4
["192.168.0.24", "192.168.10.24"]

# Value of the tag key
> huaweicloud_compute_instance.myinstance.tags["key"]
value