If a CDN resource was created via Terraform, you can add a rule to it via Terraform. To do this, use the following instructions.
1. Open the main.tf file.
2. The file is supposed to contain the code for the creation of your CDN resource. If it is missing, add the code according to the Create a new CDN resource section.
Don't worry, Terraform won't duplicate a resource. Terraform requires the code used to create a resource only to identify a resource that should be changed.
3. At this step, you will add the necessary strings for creating a rule to the configuration file.
Add the code below to a new string. Replace the hints in the brackets with your values and remove the brackets.
4. If you want to add options to the rule, paste the code below. Replace the hints in the brackets with your values and remove the brackets.
If you don't need options, do not add the options code segment.
5. Be aware to add a curly bracket to a new string below.
}
Here is an example of a configuration file. Let's say you want to add a rule with the following characteristics:
The final code in the configuration file will look as follows:
6. Save the changes in the configuration file.
7. Access the "Terraform" folder in the command-line interface unless you are already in it, and run the terraform plan
command — it will show what changes Terraform is going to make. If the code contains an error, the output will give a brief description of it.
8. Run the terraform apply
command — it will make changes to the CDN. Terraform will ask you to confirm the action — enter "yes".
Was this article helpful?
Learn more about our next-gen CDN