tencent cloud

Using Installation Parameters, Variables and Output

Download
Focus Mode
Font Size
Last updated: 2026-05-11 16:09:53
AI-Translated

Installation Parameters

Installation parameters can let customers install software in a suitable way. Common scenarios include:
Select and install in the specified Virtual Private Cloud (VPC) and subnet (Subnet) to implement network planning.
Select the customer's security group (Security Group) to implement network access policies.
Select the model to better fit the user's actual capacity.
Select the domain name and certificate for final deployment, so that the certificate can be automatically deployed.

Declare Installation Parameters in package.yaml

The installation package can declare installation parameters in package.yaml. The Marketplace will generate an appropriate installation interface for these declared installation parameters. The following example comes from the Marketplace template CT_001_cvm-ip.
# <package.yaml>
# Custom installation parameters, declare the installation form to be retrieved through the widget.
args:
- name: app_target
label: target network
widget: subnet-select
- name: cvm_type
label: Cloud Virtual Machine (CVM) type
widget: cvm-instance-type-select
region: ${app_target.region}
zone: ${app_target.subnet.zone}
- name: sg
label: security group
widget: security-group-select
regions:
- ${app_target.region}




Fields used in declaring installation parameters in package.yaml are explained as follows:
Field
Description
args
Declare a parameter list with args. Each item is a parameter. The installation interface will render installation components in the declared order.
args[i].name
Parameter identification. This is also the variable name to be declared and used in Terraform subsequently.
args[i].label
Parameter name. The installation interface will show the parameter name.
args[i].widget
The installation components for parameter use.
args[i].region
args[i].zone
...
The configuration of installation components for parameters. Different component types have different configuration fields.
The configuration of components generally provides a finer selection range when users enter data. For example, after the user has selected the target network, the server type can be limited to the example type range supported by the target subnet to avoid invalid selections.
args[i].when
(Advanced usage) Conditions for the occurrence of parameters. Parameters do not appear in the installation interface by default and only appear when the conditions of when are met. Applicable to the form linkage of installation components.
args[i].hidden
(Advanced usage) Conditions for hiding parameters. Parameters will appear in the installation interface by default and hide when the conditions of when are met. Applicable to the form linkage of installation components.
args[i].validator
(Advanced usage) Verification rules for parameters can help users reduce configuration errors.

Using Installation Parameters in a tf File

After defining the installation parameters in the package.yaml file, you can declare and use them in the tf file. The following example comes from CT_001_cvm-ip.
# <variable.tf>
# CVM model selection variable
variable "cvm_type" {
type = object({
region = string
region_id = string
zone = string
instance_type = string
})
}
Different types of installation parameters have different variable value types.
After declaration, it can be used as an ordinary Terraform variable.
# <deployment.tf>
resource "tencentcloud_instance" "demo_cvm" {
# CVM model
instance_type = var.cvm_type.instance_type
}

Variable

Declare a Variable

All variables used in the installation package need to be declared before use.
# <variable.tf>
# CVM model selection variable
variable "cvm_type" {
type = object({
region = string
region_id = string
zone = string
instance_type = string
})
}
Similar to a resource block, use a variable block variable to declare a variable. In the above declaration, cvm_type is the variable name, and var.cvm_type can be used to refer to it in the resource block.

Variable Separation Practice

Using variables can effectively manage orchestration parameters of resources. For example, if a service provider has two components with basically the same orchestration architectures but different server images, the image ID can be extracted as a variable.
In practice, it is recommended to separate variables and orchestration parts in the infrastructure directory of the installation package according to variable.tf and deployment.tf. See Marketplace template library for more practical ideas.

Variable Type

The available variables in the installation package are divided into two kinds: system variables and application variables.
System variable: Used to provide deployment requirements information, such as image repository address and credentials, CAM role information, etc. It is prefixed with cloudapp_ and can be used by ALL installation packages.
Parameter variable: The application parameters defined in package.yaml will generate corresponding application variables. The variable name is exactly the parameter name.
Common variable: A variable declared and used by the application itself, such as CVM image ID, basic database settings, etc.
Variables used must be declared
Although the values of both system variables and application variables are automatically injected, they must be declared when used in TF files. If variables are used without being declared, it will cause the installation package to fail to package.

Output

The results after application installation need to be provided to the customer. For example, the access address of the application, the address of the management system, or the initial password of the management system, etc. This can be achieved by declaring output in the tf file.
output "main" {
value = "https://my.${var.selected_domain}"
# value = "http://${tencentcloud_instance.cloudapp_cvm.public_ip}:8080"
description = "access entrance"
}
output "a_admin_url" {
value = "https://admin.${var.selected_domain}"
description = "operation system"
}
output "b_admin_default_user" {
value = "admin"
description = "default admin user"
}
output "c_admin_default_password" {
value = random_password.default_admin.result
description = "default administrator password"
sensitive = true
}
Note:
It is recommended to add an output variable named main and set its value to URL. This value will serve as the default access address for customer applications.
If sensitive = true is declared, it is considered sensitive information (customers can apply CAM or MFA security restrictions to the sensitive information interface).
The display order of final result items is not determined by the order of declaration in the tf files, but rather by sorting output variable names in alphabetical order.
The declared output. Customers can see the corresponding installation result in the dashboard app details.


Help and Support

Was this page helpful?

Help us improve! Rate your documentation experience in 5 mins.

Feedback