Terraform is an open source tool for automated resource orchestration. Terraform is available as a managed service in Resource Orchestration Service (ROS). You can create Terraform templates and stacks to orchestrate Alibaba Cloud, Amazon Web Services (AWS), and Microsoft Azure resources. Terraform features are compatible with the ROS API. After you create Terraform templates, you can use ROS API operations to implement the features.
Limits
Terraform supports only specific ROS features and resources. For more information, see Features and resources supported by Terraform in ROS.
Development methods
We recommend that you use a familiar development method to write and test Terraform code. The following development methods are supported:
Use an on-premises environment.
Use the Terraform online debugging tool. This method is supported only in Alibaba Cloud.
Recommended. Create a Terraform stack in the ROS console, and continue to create the stack or update the stack based on your business requirements. For more information, see Create a Terraform stack, Continue to create a stack, and Update a stack.
Benefits of using Terraform in ROS
Compared with Terraform CLI, ROS supports more features to manage Terraform code to enhance user experience. ROS provides the following benefits:
Same console experience as ROS templates
The ROS console provides the same user experience for ROS templates and Terraform templates. You can manage all resources of both types of templates in the same way in one console.
Dynamic queries and selection of parameters and properties
ROS supports dynamic queries for the valid values of parameters.
ROS supports comprehensive queries to allow you to reference the same parameter for multiple properties.
ROS displays parameters on a GUI and allows you to select parameter configurations based on optional values. For more information, see AssociationProperty and AssociationPropertyMetadata.
In the Parameters section of a template, you can specify
AssociationProperty
for parameters to query the resources in the specified region and specifyAssociationPropertyMetadata
to add filter conditions for the parameters. This way, you can select parameter configurations based on optional values in the ROS console.Price inquiry for template resources
Before you deploy resources, ROS automatically calculates and displays the estimated prices based on your Terraform template to help you better plan budgets.
Service activation and role checks
Automatic checks: ROS automatically checks whether the services involved in Terraform templates are activated and whether the required roles are available and permissions are granted. This ensures that preparations before the deployment are complete.
Hints and guidance: If the required service is not activated or role is missing, ROS provides hints and guidance to help you quickly complete the necessary configurations.
Risk detection
ROS automatically detects potential risks to help you prevent errors. For example, ROS detects risks when you delete a security group.
Template version management and sharing
Tag and resource group propagation
You can propagate tags and resource groups to all resources in a template at a time.
Scenarios
Create a Terraform stack
If you want to create and manage resources across cloud platforms such as AWS and Microsoft Azure or across on-premises platforms, you can create Terraform stacks to orchestrate and manage the resources on the platforms in a centralized manner. For more information, see Create a Terraform stack.
Create a Terraform template
If you want to create and manage resources of a third-party cloud platform such as AWS or Microsoft Azure on Alibaba Cloud, you can define the third-party resources and configure dependency relationships between the resources in a Terraform template. This way, you can conveniently manage resources across cloud platforms. For more information, see Create a Terraform template.
Template structure
Terraform templates are supported in ROS after Terraform is managed in ROS. You can use Terraform templates to orchestrate Alibaba Cloud, AWS, and Microsoft Azure resources. You can define resources and parameters and configure dependency relationships between resources in a Terraform template. For more information, see Structure of Terraform templates. For more information about how to define parameters in a Terraform template, see What is Terraform?
Development suggestions
After you familiarize yourself with the related concepts of Terraform that is managed in ROS, you can use the following suggestions to develop Terraform code and use the code in ROS. For more information, see Methods and suggestions for Terraform code development.
Refine variable definitions.
Specify the provider version.
Use pseudo parameters to obtain stack information.
Control the input mode of parameters and variables in the console.
Use Aliyun::Terraform-v1.0 or later.
Use Metadata to control the display of parameters and variables in the console.
Save on-premises code to the file whose name ends with ".debug.tf".
Do not declare the Alibaba Cloud provider (alicloud) in the ".tf" file.
Use ROS parameters other than ".tfvars" files to pass variable values.
Examples of Terraform templates
For more information, see Examples of Terraform templates.