### cmccloudv2_volume_autobackup Resource Source: https://github.com/cmc-cloud/terraform-provider-cmccloudv2/blob/main/docs/resources/volume_autobackup.md Example of how to create a volume auto backup resource. ```APIDOC ## Resource: cmccloudv2_volume_autobackup ### Description Manages a volume auto backup configuration. ### Method Not Applicable (Terraform Resource) ### Endpoint Not Applicable (Terraform Resource) ### Parameters #### Required - **name** (String) - The name of the auto backup. - **schedule_time** (String) - The schedule time in HH:mm format, e.g., 19:05. - **volume_id** (String) - The ID of the Volume to backup. #### Optional - **incremental** (Boolean) - If true, it is incremental backup, if false, it is full backup. Default is true. - **interval** (Number) - The interval of the auto backup. - **max_keep** (Number) - The maximum number of backups to keep. - **timeouts** (Block, Optional) - Configuration block for timeouts. #### Nested Schema for `timeouts` - **create** (String) - Timeout for create operation. - **delete** (String) - Timeout for delete operation. ### Read-Only - **created_at** (String) - The creation time of the auto backup. - **id** (String) - The ID of this resource. - **last_run** (String) - The last run time of the auto backup. - **volume_size** (Number) - The size of the volume in GB. ### Request Example ```terraform resource "cmccloudv2_volume_autobackup" "example" { name = "my-auto-backup" volume_id = "642109d2-49ab-48b1-8fc7-8f1909c33a1c" schedule_time = "04:30" incremental = false interval = 1 max_keep = 7 } ``` ### Response Example (Terraform resource creation does not have a direct response body in this format. State is managed by Terraform.) ``` -------------------------------- ### Create CDN Resource Configurations Source: https://github.com/cmc-cloud/terraform-provider-cmccloudv2/blob/main/docs/resources/cdn.md Examples demonstrating how to define CDN resources for different origin types and VOD settings. ```terraform # create cdn for Origin Host resource "cmccloudv2_cdn" "cdn1" { vod = false name = "vnexpress site" origin_type = "host" domain_or_ip = "vnexpress.net" protocol = "https" port = 443 origin_path = "/content/" } ``` ```terraform # create cdn for S3 Host resource "cmccloudv2_cdn" "cdn2" { vod = false name = "dantri site" origin_type = "s3" s3_access_key = "F7KL3TOAIEKPD4PQ6DRF" s3_secret_key = "J4iwL4PyLPn1y79tg6fQsD2MwZruIEo39k2ckDG0" s3_bucket_name = "testbucket" s3_region = "hn-1" s3_endpoint = "s3.hn-1.cloud.cmctelecom.vn" } ``` ```terraform # create cdn for a VOD site resource "cmccloudv2_cdn" "cdn3" { vod = true name = "bongda" origin_type = "host" domain_or_ip = "bongda.com.vn" protocol = "https" port = 443 } ``` ```terraform # create cdn for a VOD site with S3 resource "cmccloudv2_cdn" "cdn4" { vod = true name = "bongda-s3" origin_type = "s3" s3_access_key = "F7KL3TOAIEKPD4PQ6DRF" s3_secret_key = "J4iwL4PyLPn1y79tg6fQsD2MwZruIEo39k2ckDG0" s3_bucket_name = "testbucket" s3_region = "hn-1" s3_endpoint = "s3.hn-1.cloud.cmctelecom.vn" } ``` -------------------------------- ### Create cmccloudv2_volume resources Source: https://github.com/cmc-cloud/terraform-provider-cmccloudv2/blob/main/docs/resources/volume.md Examples showing how to define a standard volume and an encrypted volume using a key management secret. ```terraform # create a simple volume resource "cmccloudv2_volume" "volume_1" { name = "volume_1" description = "volume create from terraform" size = 20 type = "highio" billing_mode = "hourly" zone = "AZ1" tags = [{"key": "env", "value": "prod"}] } # create a volume with encryption (this may not working in some zone) data "cmccloudv2_keymanagement_secret" "key1" { container_id = "your_keymanagement_secret_container_id" name = "key1" type = "symmetric" } resource "cmccloudv2_volume" "volume_2" { name = "volume_2" description = "volume create from terraform" size = 20 type = "highio-encryption" billing_mode = "hourly" zone = "AZ1" secret_id = "${data.cmccloudv2_keymanagement_secret.key1.id}" tags = [{"key": "env", "value": "prod"}] } ``` -------------------------------- ### Create instance with password Source: https://github.com/cmc-cloud/terraform-provider-cmccloudv2/blob/main/docs/resources/server.md This example demonstrates creating a server instance using a password for authentication. The password will be set as the root password for the server. ```terraform resource "cmccloudv2_server" "example_02" { name = "example-02" billing_mode = "monthly" zone = "AZ1" flavor_id = "2b9dea6e-f628-446b-91f9-1122cff5a418" source_id = "a9cb8f5e-b32a-4e89-b2d4-6dc2a25d0918" source_type = "image" volume_name = "root-2ds6" volume_size = 30 volume_type = "ssd" subnet_id = "be679ec3-e661-4010-8e9e-f8c041a68dc7" password = "UGFuq1TqeC@" } ``` -------------------------------- ### Create Autoscaling Group with Terraform Source: https://github.com/cmc-cloud/terraform-provider-cmccloudv2/blob/main/docs/resources/autoscalingv2_group.md Examples showing how to define an autoscaling group with and without a load balancer integration. ```terraform # create autoscale group do not using Load Balancer resource "cmccloudv2_autoscalingv2_group" "as_group_1" { name = "as-group-no-lb" zone = "AZ1" min_size = 1 max_size = 1 desired_capacity = 1 configuration_id = "9b398fb0-395b-459b-8531-c7ee41e15d30" scale_up_adjustment_type = "change_in_capacity" scale_up_adjustment = 2 scale_up_cooldown = 400 scale_down_adjustment_type = "change_in_capacity" scale_down_adjustment = 1 scale_down_cooldown = 400 } # create autoscale group using Load Balancer resource "cmccloudv2_autoscalingv2_group" "as_group_1" { name = "as-group-vjw2" zone = "AZ1" min_size = 1 max_size = 1 desired_capacity = 1 configuration_id = "9b398fb0-395b-459b-8531-c7ee41e15d30" cooldown = 600 scale_up_adjustment_type = "change_in_capacity" scale_up_adjustment = 2 scale_up_cooldown = 400 scale_down_adjustment_type = "change_in_capacity" scale_down_adjustment = 1 scale_down_cooldown = 400 lb_pool_id = "0e34fbc9-7ab8-4386-a3b9-ab2c1508330f" lb_protocol_port = 80 } ``` -------------------------------- ### Define an autoscaling configuration resource Source: https://github.com/cmc-cloud/terraform-provider-cmccloudv2/blob/main/docs/resources/autoscaling_configuration.md Example usage of the cmccloudv2_autoscaling_configuration resource with required and optional parameters. ```terraform resource "cmccloudv2_autoscaling_configuration" "as_configuration1" { name = "as_config_terraform" source_type = "image" source_id = "c9cd9428-84a1-4e77-946a-0f8c44a2eccc" flavor_id = "f195840e-1fe1-4816-af3b-54d7390a00a2" subnet_ids = [ "52257938-65ae-422b-97f4-211db1de00a1" ] use_eip = true domestic_bandwidth = 500 inter_bandwidth = 10 volumes { size = 20 type = "highio" delete_on_termination = true } volumes { size = 100 type = "commonio" delete_on_termination = true } security_group_names = [ "sg-cv8g", "default" ] # key_name = "" # user_data = "" password = "}2LBgdue5ty" ecs_group_id = "bfdcd02a-1ffe-4e24-9cc5-09a0a6689923" } ``` -------------------------------- ### Create Kubernetes Node Group Source: https://github.com/cmc-cloud/terraform-provider-cmccloudv2/blob/main/docs/resources/kubernetesv2_nodegroup.md Examples for creating a basic node group and one with advanced autoscaling and autohealing configurations. ```terraform # create a k8s nodegroup without autoscale data "cmccloudv2_flavor_k8s" "flavor_k8s" { name = "c6.small.1.k8s" } data "cmccloudv2_volume_type" "ssd" { description = "High I/O (SSD)" } resource "cmccloudv2_kubernetesv2_nodegroup" "nodegroup_1" { cluster_id = "ad5a8b1d-0c12-4cd5-b7d9-19a32abfb87f" billing_mode = "monthly" name = "nodegroup_1" zone = "AZ1" flavor_id = "${data.cmccloudv2_flavor_k8s.flavor_k8s.id}" key_name = "keypair-zn75" security_group_ids = [] image_gpu_tag = "default" volume_type = "${data.cmccloudv2_volume_type.ssd.name}" volume_size = 20 init_current_node = 1 max_pods = 110 } # create a k8s nodegroup with advance options resource "cmccloudv2_kubernetesv2_nodegroup" "nodegroup_1" { cluster_id = "ad5a8b1d-0c12-4cd5-b7d9-19a32abfb87f" billing_mode = "monthly" name = "nodegroup_1" zone = "AZ1" flavor_id = "${data.cmccloudv2_flavor_k8s.flavor_k8s.id}" key_name = "keypair-zn75" security_group_ids = [] image_gpu_tag = "default" volume_type = "${data.cmccloudv2_volume_type.ssd.name}" volume_size = 20 init_current_node = 1 max_pods = 110 #autoscale options enable_autoscale = true min_node = 1 max_node = 2 #autohealing options enable_autohealing = true max_unhealthy_percent = 80 node_startup_timeout_minutes = 10 node_metadatas { key = "group" value = "cmccloud" type = "label" } ntp_servers { host = "vn.pool.ntp.org" port = 123 protocol = "tcp" } } ``` -------------------------------- ### Create Redis Instance in Master/Slave Mode Source: https://github.com/cmc-cloud/terraform-provider-cmccloudv2/blob/main/docs/resources/redis_instance.md This example demonstrates creating a Redis instance in Master/Slave mode. It includes essential parameters like name, billing, engine, version, flavor, volume, network, and security group. ```terraform resource "cmccloudv2_redis_instance" "redis_instance_masterslave" { name = "redis-2bdr" billing_mode = "monthly" database_engine = "Redis" database_version = "6.0" zones = ["AZ3", "AZ2"] flavor_id = "${data.cmccloudv2_flavor_dbaas.flavor_dbaas.id}" volume_size = 20 subnet_id = "036f3b55-2ff8-4350-9fc0-4baf12deca03" password = "5k9DJoK1FqDQShwgocmqkZ23DIlFOaa" security_group_ids = [ "2465c8f5-1aa5-4fcd-9ea0-0713d6a1f685" ] database_mode = "Master/Slave" } ``` -------------------------------- ### Retrieve VPC details using various filters Source: https://github.com/cmc-cloud/terraform-provider-cmccloudv2/blob/main/docs/data-sources/vpc.md Use these examples to fetch VPC information by name, ID, or specific attributes like description and CIDR. ```terraform # get vpc by name data "cmccloudv2_vpc" "vpc_1" { name = "vpc-a9xj" } # get vpc by id data "cmccloudv2_vpc" "vpc_2" { vpc_id = "8a26f333-c1b6-4ebf-9ecf-2b155bfaa37d" } # get vpc by other filter options data "cmccloudv2_vpc" "vpc_2" { description = "vpc_tf" cidr = "192.168.0.0/16" } ``` -------------------------------- ### Retrieve EFS by ID or Name Source: https://github.com/cmc-cloud/terraform-provider-cmccloudv2/blob/main/docs/data-sources/efs.md Use these examples to fetch EFS details by providing either the efs_id or the name attribute. ```terraform # get efs by id data "cmccloudv2_efs" "efs1" { efs_id = "07d7eb8f-62ae-4751-968a-3955ef0a6974" } # get efs by name data "cmccloudv2_efs" "efs1" { name = "efs-88vm" } ``` -------------------------------- ### Create ELB Listener with HTTP Protocol Source: https://github.com/cmc-cloud/terraform-provider-cmccloudv2/blob/main/docs/resources/elb_listener.md Example of creating an ELB listener for Layer 7 HTTP protocol. Includes options for X-Forwarded headers. ```terraform resource "cmccloudv2_elb_listener" "listener_2"{ elb_id = "f054ad90-1d14-461b-958c-983d8a16c6a2" name = "listener_2" description = "your_listener_description" protocol = "HTTP" protocol_port = "80" default_pool_id = "fcd14e84-578f-46b7-ba2e-b88862903332" timeout_member_connect = 5000 timeout_member_data = 50000 connection_limit = -1 allowed_cidrs = [] timeout_client_data = 50000 timeout_tcp_inspect = 0 # options for layer 7 protocol x_forwarded_for = false x_forwarded_port = true x_forwarded_proto = true } ``` -------------------------------- ### Retrieve volume information using various filters Source: https://github.com/cmc-cloud/terraform-provider-cmccloudv2/blob/main/docs/data-sources/volume.md Use these examples to fetch volume details by name, server attachment, or unique volume ID. ```terraform # get volume by name data "cmccloudv2_volume" "volume_1" { name = "ev-k8s3" } # get root volume of server data "cmccloudv2_volume" "volume_root" { server_id = "44fa95ef-5b29-4c81-840f-c2ae310cdbdd" bootable = true } # get volume by id data "cmccloudv2_volume" "volume_root" { volume_id = "5d0fecd3-728d-46b1-98bd-93d1cefba685" } ``` -------------------------------- ### Create cmccloudv2_elb_l7policy_rule Source: https://github.com/cmc-cloud/terraform-provider-cmccloudv2/blob/main/docs/resources/elb_l7policy_rule.md Example of creating different types of L7 policy rules. Ensure the l7policy_id is valid and other parameters match the rule type. ```terraform resource "cmccloudv2_elb_l7policy_rule" "rule1" { l7policy_id = "5f59d19b-0e7b-42e0-a277-f7e1d13d6aad" type = "COOKIE" compare_type = "CONTAINS" key = "region-id" value = "hn-1" invert = false } ``` ```terraform resource "cmccloudv2_elb_l7policy_rule" "rule2" { l7policy_id = "5f59d19b-0e7b-42e0-a277-f7e1d13d6aad" type = "FILE_TYPE" compare_type = "EQUAL_TO" value = "png" invert = false depends_on = [cmccloudv2_elb_l7policy_rule.rule1] } ``` ```terraform resource "cmccloudv2_elb_l7policy_rule" "rule3" { l7policy_id = "5f59d19b-0e7b-42e0-a277-f7e1d13d6aad" type = "HEADER" compare_type = "STARTS_WITH" key = "key" value = "png" invert = false depends_on = [cmccloudv2_elb_l7policy_rule.rule2] } ``` -------------------------------- ### Create L7 Policy with REDIRECT_TO_URL action Source: https://github.com/cmc-cloud/terraform-provider-cmccloudv2/blob/main/docs/resources/elb_l7policy.md This example demonstrates creating an L7 policy to redirect traffic to a specified URL with a given HTTP code. It also shows how to set dependencies on other resources. ```terraform resource "cmccloudv2_elb_l7policy" "policy2" { listener_id = "e785611d-a21a-42d3-8062-6ae2cad66b28" name = "policy-qsav2" action = "REDIRECT_TO_URL" position = 4 redirect_url = "https://google.com" redirect_http_code = 301 depends_on = [cmccloudv2_elb_l7policy.policy1] } ``` -------------------------------- ### Create Public and Private ELB Resources Source: https://github.com/cmc-cloud/terraform-provider-cmccloudv2/blob/main/docs/resources/elb.md Examples demonstrating the creation of public and private ELB instances using the cmccloudv2_elb resource. Requires a valid flavor ID retrieved from the cmccloudv2_flavor_elb data source. ```terraform # create Public elb with flavor "small-lb" data "cmccloudv2_flavor_elb" "elb_flavor1" { name = "small-lb" } resource "cmccloudv2_elb" "elb_1" { name = "elb_1" billing_mode = "monthly" zone = "AZ1" flavor_id = "${data.cmccloudv2_flavor_elb.elb_flavor1.id}" network_type = "public" bandwidth_mbps = 500 tags = [{"key": "env", "value": "prod"}] description = "your description" } # create Private elb with flavor "small-lb" resource "cmccloudv2_elb" "elb_2" { name = "elb_2" billing_mode = "monthly" zone = "AZ1" flavor_id = "${data.cmccloudv2_flavor_elb.elb_flavor1.id}" network_type = "private" subnet_id = "d32fa7ba-2a02-4327-80d3-9e17274b9fdd" tags = [{"key": "env", "value": "prod"}] description = "your description" } ``` -------------------------------- ### Create DNS ACL Source: https://github.com/cmc-cloud/terraform-provider-cmccloudv2/blob/main/docs/resources/dns_acl.md Example of how to create a DNS ACL resource. Specify the zone ID, record type, domain, source IP, and desired action (allow or block). ```terraform resource "cmccloudv2_dns_acl" "acl1" { zone_id = "8dda9b63-3cfa-4b35-98ad-a495e6e1d052" record_type = "A" domain = "sub.example.com" source_ip = "1.2.5.0/24" action = "block" # allow, block } ``` -------------------------------- ### Create ELB Listener with HTTPS Protocol (Terminated) Source: https://github.com/cmc-cloud/terraform-provider-cmccloudv2/blob/main/docs/resources/elb_listener.md Example of creating an ELB listener for Layer 7 HTTPS protocol with SSL termination. Requires a certificate data source to be defined. ```terraform data "cmccloudv2_certificate" "cert1" { name = "certificate-xstm" } resource "cmccloudv2_elb_listener" "listener_3"{ elb_id = "f054ad90-1d14-461b-958c-983d8a16c6a2" name = "listener_3" description = "your_listener_description" protocol = "HTTP" protocol_port = "80" default_pool_id = "fcd14e84-578f-46b7-ba2e-b88862903332" timeout_member_connect = 5000 timeout_member_data = 50000 connection_limit = -1 allowed_cidrs = [] timeout_client_data = 50000 timeout_tcp_inspect = 0 x_forwarded_for = false x_forwarded_port = true x_forwarded_proto = true default_tls_container_ref = "${data.cmccloudv2_certificate.cert1.secret_ref}" } ``` -------------------------------- ### Create instance with advanced options Source: https://github.com/cmc-cloud/terraform-provider-cmccloudv2/blob/main/docs/resources/server.md This example shows how to create a server with advanced configurations, including specifying an IP address, associating with an ECS group and security groups, and providing user data. The `delete_on_termination` flag controls whether the root volume is kept after deletion. ```terraform resource "cmccloudv2_server" "example_04" { name = "example-04" billing_mode = "monthly" zone = "AZ1" flavor_id = "2b9dea6e-f628-446b-91f9-1122cff5a418" source_id = "a9cb8f5e-b32a-4e89-b2d4-6dc2a25d0918" source_type = "image" volume_name = "root-example-04" volume_size = 30 volume_type = "ssd" subnet_id = "be679ec3-e661-4010-8e9e-f8c041a68dc7" password = "UGFuq1TqeC@" ip_address = "192.168.0.55" ecs_group_id = "bfdcd02a-1ffe-4e24-9cc5-09a0a6689923" user_data = "" delete_on_termination = false tags = [{"key": "env", "value": "prod"}] security_group_names = [ "sg-cv8g", "default" ] } ``` -------------------------------- ### GET cmccloudv2_autoscaling_group Source: https://github.com/cmc-cloud/terraform-provider-cmccloudv2/blob/main/docs/data-sources/autoscaling_group.md Retrieves details of an autoscaling group by its ID or name. ```APIDOC ## GET cmccloudv2_autoscaling_group ### Description Retrieves information about an existing autoscaling group. ### Parameters #### Optional - **autoscaling_group_id** (String) - Optional - Id of the autoscaling group - **configuration_id** (String) - Optional - Configuration id of the autoscaling group, exact match - **configuration_name** (String) - Optional - Configuration name of the autoscaling group, exact match - **name** (String) - Optional - Name of the autoscaling group, exact match - **status** (String) - Optional - Status of the autoscaling group ### Response #### Read-Only - **created_at** (String) - Creation timestamp - **id** (String) - The ID of this resource ``` -------------------------------- ### cmccloudv2_kubernetesv2_nodegroup_gpu_config Resource Source: https://github.com/cmc-cloud/terraform-provider-cmccloudv2/blob/main/docs/resources/kubernetesv2_nodegroup_gpu_config.md Example usage for creating and configuring a Kubernetes nodegroup GPU configuration. ```APIDOC ## cmccloudv2_kubernetesv2_nodegroup_gpu_config Resource ### Description Manages a Kubernetes nodegroup GPU configuration in CMC Cloud V2. ### Method Resource Creation/Management (Terraform) ### Endpoint N/A (Terraform resource) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body - **cluster_id** (String) - Required - The ID of the Kubernetes cluster to attach the GPU config to - **nodegroup_id** (String) - Required - The ID of the node group to attach the GPU config to - **gpu_model** (String) - Required - The GPU model of the GPU config - **driver** (String) - Required - The driver of the GPU config - **strategy** (String) - Optional - The strategy of the GPU config, a valid value is single or mixed - **mig_profile** (String) - Optional - The MIG profile of the GPU config - **gpu_profiles** (Block Set) - Optional - The GPU profiles of the GPU config - **name** (String) - Required - The name of the GPU profile - **replicas** (Number) - Required - The replicas of the GPU profile - **timeouts** (Block) - Optional - **create** (String) - Optional - **delete** (String) - Optional - **update** (String) - Optional ### Request Example ```terraform resource "cmccloudv2_kubernetesv2_nodegroup_gpu_config" "nodegroup_gpu_1" { cluster_id = "93cf35f9-f570-4a6c-aeb1-115a0de256c9" nodegroup_id = "db478032-0d65-4f12-8d43-bdfeeab879f8" gpu_model = "GPU-Accelerated-1080Ti" driver = "580.65.06" strategy = "single" mig_profile = "all-1g.5gb" gpu_profiles { name = "nvidia.com/gpu" replicas = 2 } gpu_profiles { name = "nvidia.com/mig-1g.5gb" replicas = 2 } } ``` ### Response #### Success Response (200) - **id** (String) - The ID of this resource. #### Response Example (Terraform apply output will show resource creation status and ID) ``` -------------------------------- ### Create Kubernetes Cluster with Addons Source: https://github.com/cmc-cloud/terraform-provider-cmccloudv2/blob/main/docs/resources/kubernetesv2.md This example demonstrates creating a Kubernetes cluster with essential addons enabled, including autohealing, monitoring, and autoscaling. Configure autoscaling parameters like max node count, max RAM, and max core. ```terraform # create k8s cluster with addons resource "cmccloudv2_kubernetesv2" "k8s_2" { name = "k8s_2" zone = "AZ1" subnet_id = "ac67cf25-205d-440a-82de-1017f72653b7" kubernetes_version = "v1.28.9" master_flavor_name = "c6.large.2.k8s" master_count = 1 cidr_block_pod = "10.100.0.0/16" cidr_block_service = "10.254.0.0/16" network_driver = "calico" enable_autohealing = true enable_monitoring = true enable_autoscale = true autoscale_max_node = 50 autoscale_max_ram_gb = 500 autoscale_max_core = 500 } ``` -------------------------------- ### cmccloudv2_iam_group Data Source Source: https://github.com/cmc-cloud/terraform-provider-cmccloudv2/blob/main/docs/data-sources/iam_group.md Use the cmccloudv2_iam_group data source to get information about an IAM group. ```APIDOC ## cmccloudv2_iam_group (Data Source) ### Description Use the cmccloudv2_iam_group data source to get information about an IAM group. ### Method GET ### Endpoint /api/iam/groups ### Parameters #### Query Parameters - **name** (String) - Required - Filter by name of group ### Response #### Success Response (200) - **id** (String) - The ID of the group. - **name** (String) - The name of the group. - **description** (String) - Description of the group. ### Request Example ```terraform # get group by name data "cmccloudv2_iam_group" "dev" { name = "dev" } ``` ### Response Example ```json { "id": "group-id-123", "name": "dev", "description": "Development team group" } ``` ``` -------------------------------- ### Create a Server Instance with SSH Key Authentication Source: https://context7.com/cmc-cloud/terraform-provider-cmccloudv2/llms.txt Provision a virtual machine instance using SSH key authentication. Configure name, billing mode, zone, flavor, source image, volume details, subnet, and SSH key name. User data can be provided for initial setup. ```terraform # Create instance with SSH key authentication resource "cmccloudv2_server" "web_server" { name = "web-server-01" billing_mode = "monthly" zone = "AZ1" flavor_id = "2b9dea6e-f628-446b-91f9-1122cff5a418" source_id = "a9cb8f5e-b32a-4e89-b2d4-6dc2a25d0918" # Image ID source_type = "image" volume_name = "root-web-01" volume_size = 50 volume_type = "ssd" subnet_id = cmccloudv2_subnet.web_subnet.id key_name = "my-keypair" # Optional advanced settings ip_address = "192.168.1.20" ecs_group_id = "bfdcd02a-1ffe-4e24-9cc5-09a0a6689923" security_group_names = ["web-sg", "default"] delete_on_termination = true tags = [{"key": "role", "value": "webserver"}] user_data = <<-EOF #!/bin/bash yum update -y yum install -y nginx systemctl start nginx EOF } ``` -------------------------------- ### Create an EIP with advanced options Source: https://github.com/cmc-cloud/terraform-provider-cmccloudv2/blob/main/docs/resources/eip.md This snippet demonstrates creating an EIP with advanced configurations, including tags and DNS settings. It's suitable for production environments requiring specific tagging and domain name resolution. The `tags`, `dns_domain`, and `dns_name` arguments allow for detailed customization. ```terraform resource "cmccloudv2_eip" "eip_terraform" { billing_mode = "monthly" domestic_bandwidth = 500 inter_bandwidth = 10 description = "eip created from terraform" tags = [{"key": "env", "value": "prod"}] dns_domain = "example.com." dns_name = "my-ip" } ``` -------------------------------- ### GET /cmccloudv2_iam_custom_role Source: https://github.com/cmc-cloud/terraform-provider-cmccloudv2/blob/main/docs/data-sources/iam_custom_role.md Retrieves details for a specific IAM custom role based on the provided name. ```APIDOC ## GET /cmccloudv2_iam_custom_role ### Description Retrieves information about an existing IAM custom role by its name. ### Parameters #### Required Parameters - **name** (String) - Required - Filter by full custom role name ### Response #### Read-Only Fields - **created** (String) - Created time of role - **description** (String) - Description of role - **id** (String) - The ID of this resource. ``` -------------------------------- ### GET cmccloudv2_autoscaling_configuration Source: https://github.com/cmc-cloud/terraform-provider-cmccloudv2/blob/main/docs/data-sources/autoscaling_configuration.md Retrieves details of an autoscaling configuration using either its unique ID or its name. ```APIDOC ## GET cmccloudv2_autoscaling_configuration ### Description Retrieves information about an existing autoscaling configuration from the CMC Cloud provider. ### Parameters #### Optional Parameters - **autoscaling_configuration_id** (String) - Optional - Id of the autoscaling configuration - **name** (String) - Optional - Name of the autoscaling configuration ### Response #### Read-Only Fields - **created_at** (String) - Created at of the autoscaling configuration - **id** (String) - The ID of this resource. ``` -------------------------------- ### Create a Server Instance with Password Authentication Source: https://context7.com/cmc-cloud/terraform-provider-cmccloudv2/llms.txt Provision a virtual machine instance using password authentication. Configure essential details like name, billing mode, flavor, source, volume, and subnet. A strong password must be provided. ```terraform # Create instance with password authentication resource "cmccloudv2_server" "db_server" { name = "db-server-01" billing_mode = "monthly" zone = "AZ1" flavor_id = "2b9dea6e-f628-446b-91f9-1122cff5a418" source_id = "a9cb8f5e-b32a-4e89-b2d4-6dc2a25d0918" source_type = "image" volume_name = "root-db-01" volume_size = 100 volume_type = "ssd" subnet_id = cmccloudv2_subnet.web_subnet.id password = "SecureP@ssw0rd!" } ``` -------------------------------- ### GET /cmccloudv2_certificate Source: https://github.com/cmc-cloud/terraform-provider-cmccloudv2/blob/main/docs/data-sources/certificate.md Retrieves details for a specific certificate using either its unique ID or its name. ```APIDOC ## GET /cmccloudv2_certificate ### Description Retrieves information about a certificate from the CMC Cloud provider. You can query by certificate_id or name. ### Parameters #### Optional Parameters - **certificate_id** (String) - Optional - Id of the certificate - **name** (String) - Optional - Filter by name of certificate, match exactly ### Response #### Read-Only Fields - **created_at** (String) - Created at of the certificate - **id** (String) - The ID of this resource - **secret_ref** (String) - Secret reference of the certificate ``` -------------------------------- ### cmccloudv2_elb_l7policy_rule Resource Source: https://github.com/cmc-cloud/terraform-provider-cmccloudv2/blob/main/docs/resources/elb_l7policy_rule.md Example usage of the cmccloudv2_elb_l7policy_rule resource to create different types of L7 policy rules. ```APIDOC ## cmccloudv2_elb_l7policy_rule (Resource) ### Description Manages an L7 Policy Rule in CMC Cloud v2. ### Method Not Applicable (Terraform Resource) ### Endpoint Not Applicable (Terraform Resource) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None (Managed by Terraform) ### Request Example ```terraform resource "cmccloudv2_elb_l7policy_rule" "rule1" { l7policy_id = "5f59d19b-0e7b-42e0-a277-f7e1d13d6aad" type = "COOKIE" compare_type = "CONTAINS" key = "region-id" value = "hn-1" invert = false } resource "cmccloudv2_elb_l7policy_rule" "rule2" { l7policy_id = "5f59d19b-0e7b-42e0-a277-f7e1d13d6aad" type = "FILE_TYPE" compare_type = "EQUAL_TO" value = "png" invert = false depends_on = [cmccloudv2_elb_l7policy_rule.rule1] } resource "cmccloudv2_elb_l7policy_rule" "rule3" { l7policy_id = "5f59d19b-0e7b-42e0-a277-f7e1d13d6aad" type = "HEADER" compare_type = "STARTS_WITH" key = "key" value = "png" invert = false depends_on = [cmccloudv2_elb_l7policy_rule.rule2] } ``` ### Response #### Success Response (200) None (Managed by Terraform) #### Response Example None (Managed by Terraform) ### Schema #### Required - `compare_type` (String) - The compare type of the L7 policy rule - `l7policy_id` (String) - The ID of the L7 policy to attach the L7 policy rule to - `type` (String) - The type of the L7 policy rule - `value` (String) - The value of the L7 policy rule #### Optional - `invert` (Boolean) - The invert of the L7 policy rule - `key` (String) - The key of the L7 policy rule - `timeouts` (Block, Optional) - (see [below for nested schema](#nestedblock--timeouts)) #### Read-Only - `created` (String) - The created time of the L7 policy rule - `id` (String) - The ID of this resource. - `operating_status` (String) - The operating status of the L7 policy rule - `provisioning_status` (String) - The provisioning status of the L7 policy rule ### Nested Schema for `timeouts` Optional: - `create` (String) - `delete` (String) - `update` (String) ``` -------------------------------- ### Create a CMCCloud V2 Database Instance Source: https://github.com/cmc-cloud/terraform-provider-cmccloudv2/blob/main/docs/resources/database_instance.md Use this resource to provision a new database instance. Configure essential parameters like name, flavor, zone, datastore details, volume, and networking. Sensitive information such as admin password should be managed securely. ```terraform resource "cmccloudv2_database_instance" "database_instance_1" { name = "db-aie3" flavor_id = "d92cc916-a4cb-4ebf-ae81-801e963465ea" zone = "AZ1" source_type = "new" # backup/instance # source_id = "" # backup_id/instance_id datastore_type = "mysql" datastore_version = "8.0.28" volume_type = "highio" # commonio volume_size = 20 subnets { subnet_id = "321122f8-8a14-4384-bfec-0306882e9cbf" # ip_address = "192.168.4.10" } enable_public_ip = false admin_user = "rootaa" admin_password = "rOot#12aa" billing_mode = "monthly" replicate_count = 1 is_public = true # allowed_cidrs = "" # allowed_host = "" } ``` -------------------------------- ### Get cmccloudv2_certificate by Name Source: https://github.com/cmc-cloud/terraform-provider-cmccloudv2/blob/main/docs/data-sources/certificate.md Use this data source to retrieve a certificate by its name. The name must match exactly. ```terraform data "cmccloudv2_certificate" "cert_2" { name = "cert-a49t" } ``` -------------------------------- ### Create a simple EIP Source: https://github.com/cmc-cloud/terraform-provider-cmccloudv2/blob/main/docs/resources/eip.md Use this snippet to create a basic Elastic IP (EIP) with monthly billing, domestic, and international bandwidth. Ensure the `billing_mode`, `domestic_bandwidth`, and `inter_bandwidth` are set according to your requirements. ```terraform resource "cmccloudv2_eip" "eip_terraform" { billing_mode = "monthly" domestic_bandwidth = 500 inter_bandwidth = 10 description = "eip created from terraform" } ``` -------------------------------- ### Create instance from backup/snapshot Source: https://github.com/cmc-cloud/terraform-provider-cmccloudv2/blob/main/docs/resources/server.md Use this configuration to create a new server instance from an existing backup or snapshot. Specify the backup ID and set the source type to 'backup'. ```terraform resource "cmccloudv2_server" "example_03" { name = "example-03" billing_mode = "monthly" zone = "AZ1" flavor_id = "2b9dea6e-f628-446b-91f9-1122cff5a418" source_id = "58e458bc-c04e-4bc7-bb12-1b4dbc115a7c" # backup id source_type = "backup" volume_name = "root-example-03" volume_size = 30 volume_type = "ssd" subnet_id = "be679ec3-e661-4010-8e9e-f8c041a68dc7" password = "UGFuq1TqeC@" } ``` -------------------------------- ### Create a simple interface Source: https://github.com/cmc-cloud/terraform-provider-cmccloudv2/blob/main/docs/resources/server_interface.md Use this snippet to create a server interface. A random IP address will be assigned if none is specified. ```terraform resource "cmccloudv2_server_interface" "interface_1" { server_id = "90df1634-798d-4ba2-acb1-ae2a17a9cb94" subnet_id = "5d6159b5-8903-4b6c-b841-eeed9594b4ce" } ``` -------------------------------- ### Create a simple EFS Source: https://github.com/cmc-cloud/terraform-provider-cmccloudv2/blob/main/docs/resources/efs.md Use this resource to create a simple Elastic File System (EFS) with specified capacity, name, subnet, type, protocol, and optional billing mode, tags, and description. ```terraform resource "cmccloudv2_efs" "efs_1" { billing_mode = "monthly" capacity = 1000 name = "efs-aidx" subnet_id = "a7d6c281-64d6-44b6-b02c-cfbf8141adfa" type = "hdd_standard" protocol_type = "nfs" tags = [{"key": "env", "value": "prod"}] description = "your_description" } ``` -------------------------------- ### Create a WAF Certificate Source: https://github.com/cmc-cloud/terraform-provider-cmccloudv2/blob/main/docs/resources/waf_cert.md Use this resource to create a WAF certificate by providing its name, certificate file name and data, and private key file name and data. The description is optional. ```terraform resource "cmccloudv2_waf_cert" "cert1" { name = "cert1" cert_name = "waf_cert.cer" cert_data = file("waf_cert.cer") key_name = "waf_cert.key" key_data = file("waf_cert.key") description = "cert for waf" } ```