### Basic Backup Policy Source: https://github.com/opentelekomcloud/terraform-provider-opentelekomcloud/blob/devel/docs/resources/vbs_backup_policy_v2.md This example demonstrates the creation of a basic VBS backup policy with a specified name, status, start time, retention settings, and frequency. ```APIDOC ## opentelekomcloud_vbs_backup_policy_v2 Provides an VBS Backup Policy resource within OpenTelekomCloud. ~> Deprecated, use `opentelekomcloud_cbr_policy_v3` resource instead. ### Example Usage #### Basic Backup Policy ```hcl resource "opentelekomcloud_vbs_backup_policy_v2" "vbs_policy1" { name = "policy_001" status = "ON" start_time = "12:00" retain_first_backup = "N" rentention_num = 7 frequency = 1 tags = { key = "k1" value = "v1" } } ``` ## Argument Reference The following arguments are supported: * `name` - (Required) Specifies the policy name. The value is a string of 1 to 64 characters that can contain letters, digits, underscores (_), and hyphens (-). It cannot start with `default`. * `start_time` - (Required) Specifies the start time(UTC) of the backup job. The value is in the HH:mm format. You need to set the execution time on a full hour. You can set multiple execution times, and use commas (,) to separate one time from another. * `status` - (Optional) Specifies the backup policy status. Possible values are ON or OFF. Defaults to ON. * `retain_first_backup` - (Required) Specifies whether to retain the first backup in the current month. Possible values are Y or N. * `rentention_num` - (Optional) Specifies number of retained backups. Minimum value is 2. Either this field or `rentention_day` must be specified. * `rentention_day` - (Optional) Specifies days of retained backups. Minimum value is 2. Either this field or `rentention_num` must be specified. * `frequency` - (Optional) Specifies the backup interval. The value is in the range of 1 to 14 days. Either this field or `week_frequency` must be specified. * `week_frequency` - (Optional) Specifies on which days of each week backup jobs are executed. The value can be one or more of the following: "SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT". Either this field or `frequency` must be specified. * `resources` - (Optional) Specifies one or more volumes associated with the backup policy. Any previously associated backup policy will no longer apply. * `tags` - (Optional) Represents the list of tags to be configured for the backup policy. * `key` - (Required) Specifies the tag key. A tag key consists of up to 36 characters, chosen from letters, digits, hyphens (-), and underscores (_). * `value` - (Required) Specifies the tag value. A tag value consists of 0 to 43 characters, chosen from letters, digits, hyphens (-), and underscores (_). ## Attributes Reference All of the argument attributes are also exported as result attributes: * `id` - Specifies a backup policy ID. * `policy_resource_count` - Specifies the number of volumes associated with the backup policy. ## Import Backup Policy can be imported using the `id`, e.g. ```sh terraform import opentelekomcloud_vbs_backup_policy_v2.vbs 4779ab1c-7c1a-44b1-a02e-93dfc361b32d ``` ``` -------------------------------- ### OBS bucket policy example (OBS-specific) Source: https://github.com/opentelekomcloud/terraform-provider-opentelekomcloud/blob/devel/releasenotes/source/index.md This JSON defines an OBS-specific bucket policy. Use this format for OBS resources. ```json { "Statement": [ { "Effect": "Allow", "Principal": { "ID": [ "*" ] }, "Action": [ "*" ], "Resource": [ "tf-test-bucket-2185738448437901391", "tf-test-bucket-2185738448437901391/*" ] } ] } ``` -------------------------------- ### Example for encrypted disks usage with opentelekomcloud_ecs_instance_v1 Source: https://github.com/opentelekomcloud/terraform-provider-opentelekomcloud/blob/devel/releasenotes/source/index.md This snippet shows how to configure encrypted disks when creating an ECS instance. ```terraform resource "opentelekomcloud_ecs_instance_v1" "test" { # ... other configuration ... image_id = "test_image" flavor_id = "test_flavor" name = "test_instance" region = "eu-de" # Encrypted disk configuration disk { size = 100 type = "SATA" # Set to true to enable encryption encrypted = true # Specify KMS key ID if available, otherwise it uses default KMS key # kms_key_id = "your_kms_key_id" } # ... other configuration ... } ``` -------------------------------- ### OBS bucket policy example (S3-compatible - deprecated) Source: https://github.com/opentelekomcloud/terraform-provider-opentelekomcloud/blob/devel/releasenotes/source/index.md This JSON defines an S3-compatible bucket policy. This format is no longer supported for OBS resources. ```json { "Version": "2008-10-17", "Statement": [ { "Effect": "Allow", "Principal": { "AWS": [ "*" ] }, "Action": [ "s3:*" ], "Resource": [ "arn:aws:s3:::tf-test-bucket-2185738448437901391/*", "arn:aws:s3:::tf-test-bucket-2185738448437901391" ] } ] } ``` -------------------------------- ### Example Usage of opentelekomcloud_rms_policy_states_v1 Source: https://github.com/opentelekomcloud/terraform-provider-opentelekomcloud/blob/devel/releasenotes/source/resources/rms_policy_states_v1.md Use this data source to get the list of RMS policy states. No specific setup or imports are required beyond standard Terraform configuration. ```hcl data "opentelekomcloud_rms_policy_states_v1" "test" {} ``` -------------------------------- ### Create and Configure a Network, Subnet, Security Group, Port, and Instance Source: https://github.com/opentelekomcloud/terraform-provider-opentelekomcloud/blob/devel/docs/resources/networking_network_v2.md This example demonstrates the creation of a network, subnet, security group, port, and compute instance. It shows how to link these resources together, with the instance connecting to the network via a specific port and security group. Ensure the security group rules are correctly defined for desired network access. ```hcl resource "opentelekomcloud_networking_network_v2" "network_1" { name = "network_1" admin_state_up = "true" } resource "opentelekomcloud_networking_subnet_v2" "subnet_1" { name = "subnet_1" network_id = opentelekomcloud_networking_network_v2.network_1.id cidr = "192.168.199.0/24" ip_version = 4 } resource "opentelekomcloud_compute_secgroup_v2" "secgroup_1" { name = "secgroup_1" description = "a security group" rule { from_port = 22 to_port = 22 ip_protocol = "tcp" cidr = "0.0.0.0/0" } } resource "opentelekomcloud_networking_port_v2" "port_1" { name = "port_1" network_id = opentelekomcloud_networking_network_v2.network_1.id admin_state_up = "true" security_group_ids = [opentelekomcloud_compute_secgroup_v2.secgroup_1.id] fixed_ip { subnet_id = opentelekomcloud_networking_subnet_v2.subnet_1.id ip_address = "192.168.199.10" } } resource "opentelekomcloud_compute_instance_v2" "instance_1" { name = "instance_1" security_groups = [opentelekomcloud_compute_secgroup_v2.secgroup_1.name] network { port = opentelekomcloud_networking_port_v2.port_1.id } } ``` -------------------------------- ### Instance Boot From Volume Image Source: https://github.com/opentelekomcloud/terraform-provider-opentelekomcloud/blob/devel/releasenotes/source/resources/compute_bms_server_v2.md This example shows how to boot a BMS server from a volume image, specifying details for the block device, including UUID, source type, volume type, size, boot index, destination type, deletion behavior, and device name. ```APIDOC ## Resource: opentelekomcloud_compute_bms_server_v2 ### Description Manages a BMS Server resource within OpenTelekomCloud. ### Argument Reference The following arguments are supported: * `name` - (Required) The name of the BMS. * `image_id` - (Optional; Required if `image_name` is empty.) Changing this creates a new bms server. * `image_name` - (Optional; Required if `image_id` is empty.) The name of the desired image for the bms server. Changing this creates a new BMS server. * `flavor_id` - (Optional; Required if `flavor_name` is empty) The flavor ID of the desired flavor for the BMS server. Changing this resizes the existing BMS server. * `flavor_name` - (Optional; Required if `flavor_id` is empty) The name of the desired flavor for the BMS server. Changing this resizes the existing BMS server. * `user_data` - (Optional) The user data to provide when launching the instance. Changing this creates a new BMS server. * `security_groups` - (Optional) An array of one or more security group names to associate with the BMS server. Changing this results in adding/removing security groups from the existing BMS server. * `availability_zone` - (Required) The availability zone in which to create the BMS server. * `network` - (Optional) An array of one or more networks to attach to the BMS instance. Changing this creates a new BMS server. * `metadata` - (Optional) Metadata key/value pairs to make available from within the instance. Changing this updates the existing BMS server metadata. * `admin_pass` - (Optional) The administrative password to assign to the BMS server. Changing this changes the root password on the existing server. * `key_pair` - (Optional) The name of a key pair to put on the BMS server. The key pair must already be created and associated with the tenant's account. Changing this creates a new BMS server. * `stop_before_destroy` - (Optional) Whether to try stop instance gracefully before destroying it, thus giving chance for guest OS daemons to stop correctly. If instance doesn't stop within timeout, it will be destroyed anyway. * `tags` - (Optional) Tags key/value pairs to associate with the instance. The `network` block supports: * `uuid` - (Required unless `port` or `name` is provided) The network UUID to attach to the BMS server. Changing this creates a new BMS server. * `name` - (Required unless `uuid` or `port` is provided) The human-readable name of the network. Changing this creates a new BMS server. * `port` - (Required unless `uuid` or `name` is provided) The port UUID of a network to attach to the BMS server. Changing this creates a new server. * `fixed_ip_v4` - (Optional) Specifies a fixed IPv4 address to be used on this network. Changing this creates a new BMS server. * `fixed_ip_v6` - (Optional) Specifies a fixed IPv6 address to be used on this network. Changing this creates a new BMS server. * `access_network` - (Optional) Specifies if this network should be used for provisioning access. Accepts true or false. Defaults to false. The `block_device` block supports: * `uuid` - (Required unless `source_type` is `local` or `blank`) The UUID of the volume or image to attach to the BMS server. Changing this creates a new BMS server. * `source_type` - (Required) The type of the source. Possible values are `volume`, `image`, `blank`, `local`. * `volume_type` - (Optional) The type of the volume. Possible values are `SATA`, `SAS`, `SSD`. * `volume_size` - (Optional) The size of the volume in GB. Changing this creates a new BMS server. * `boot_index` - (Required) Specifies the boot index of the volume. Changing this creates a new BMS server. * `destination_type` - (Required) The type of the destination. Possible values are `volume` or `instance`. * `delete_on_termination` - (Optional) Specifies whether to delete the volume on instance termination. Defaults to `false`. * `device_name` - (Optional) The name of the device. Changing this creates a new BMS server. ### Attributes Reference In addition to all arguments above, the following attributes are exported: * `id` - The id of the BMS server. * `config_drive` - Whether to use the config_drive feature to configure the instance. * `kernel_id` - The UUID of the kernel image when the AMI image is used. * `user_id` - The ID of the user to which the BMS belongs. * `host_status` - The nova-compute status: `UP`, `UNKNOWN`, `DOWN`, `MAINTENANCE` and `Null`. ``` -------------------------------- ### Start or Restart a DMS Smart Connect Task Source: https://github.com/opentelekomcloud/terraform-provider-opentelekomcloud/blob/devel/releasenotes/source/resources/dms_smart_connect_task_action.md This example illustrates how to start or restart a running or paused DMS Kafka smart connect task. ```APIDOC ## opentelekomcloud_dms_smart_connect_task_action_v2 ### Description Start or pause a DMS kafka smart connect task resource within OpenTelekomCloud. ### Method Not applicable (Terraform resource) ### Endpoint Not applicable (Terraform resource) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body * `instance_id` (String) - Required - Specifies the kafka instance ID. * `task_id` (String) - Required - Specifies the smart connect task ID. * `action` (String) - Required - Specifies the action to be performed on the smart connect task. Supported values: `pause`, `resume`, `restart` ### Request Example ```hcl variable "instance_id" {} variable "task_id" {} resource "opentelekomcloud_dms_smart_connect_task_action_v2" "test" { instance_id = var.instance_id task_id = var.task_id action = "restart" } ``` ### Response #### Success Response (200) * `task_status` (String) - Indicates the status of the smart connect task. * `region` (String) - The region in which the resource is created. #### Response Example None explicitly provided in source, but would reflect the task status. ``` -------------------------------- ### Start or Restart a DMS Smart Connect Task Source: https://github.com/opentelekomcloud/terraform-provider-opentelekomcloud/blob/devel/docs/resources/dms_smart_connect_task_action.md This example illustrates how to start a new or restart a running or paused DMS Kafka smart connect task. ```APIDOC ## opentelekomcloud_dms_smart_connect_task_action_v2 ### Description Start or pause a DMS kafka smart connect task resource within OpenTelekomCloud. ### Arguments * `instance_id` - (Required, String, ForceNew) Specifies the kafka instance ID. * `task_id` - (Required, String, ForceNew) Specifies the smart connect task ID. * `action` - (Required, String, ForceNew) Specifies the action to be performed on the smart connect task. Supported values: `pause`, `resume`, `restart` ### Example Usage - Start or restart a running or paused task ```hcl variable "instance_id" {} variable "task_id" {} resource "opentelekomcloud_dms_smart_connect_task_action_v2" "test" { instance_id = var.instance_id task_id = var.task_id action = "restart" } ``` ``` -------------------------------- ### BMS Server Instance Boot From Volume Image Source: https://github.com/opentelekomcloud/terraform-provider-opentelekomcloud/blob/devel/docs/resources/compute_bms_server_v2.md This example shows how to create a BMS server instance by booting from a volume image, specifying details like volume type and size. ```APIDOC ## Resource: opentelekomcloud_compute_bms_server_v2 ### Description Manages a BMS Server resource within OpenTelekomCloud. ### Argument Reference The following arguments are supported: * `name` - (Required) The name of the BMS. * `image_id` - (Optional; Required if `image_name` is empty.) Changing this creates a new bms server. * `image_name` - (Optional; Required if `image_id` is empty.) The name of the desired image for the bms server. Changing this creates a new BMS server. * `flavor_id` - (Optional; Required if `flavor_name` is empty) The flavor ID of the desired flavor for the BMS server. Changing this resizes the existing BMS server. * `flavor_name` - (Optional; Required if `flavor_id` is empty) The name of the desired flavor for the BMS server. Changing this resizes the existing BMS server. * `user_data` - (Optional) The user data to provide when launching the instance. Changing this creates a new BMS server. * `security_groups` - (Optional) An array of one or more security group names to associate with the BMS server. Changing this results in adding/removing security groups from the existing BMS server. * `availability_zone` - (Required) The availability zone in which to create the BMS server. * `network` - (Optional) An array of one or more networks to attach to the BMS instance. Changing this creates a new BMS server. * `metadata` - (Optional) Metadata key/value pairs to make available from within the instance. Changing this updates the existing BMS server metadata. * `admin_pass` - (Optional) The administrative password to assign to the BMS server. Changing this changes the root password on the existing server. * `key_pair` - (Optional) The name of a key pair to put on the BMS server. The key pair must already be created and associated with the tenant's account. Changing this creates a new BMS server. * `stop_before_destroy` - (Optional) Whether to try stop instance gracefully before destroying it, thus giving chance for guest OS daemons to stop correctly. If instance doesn't stop within timeout, it will be destroyed anyway. * `tags` - (Optional) Tags key/value pairs to associate with the instance. The `network` block supports: * `uuid` - (Required unless `port` or `name` is provided) The network UUID to attach to the BMS server. Changing this creates a new BMS server. * `name` - (Required unless `uuid` or `port` is provided) The human-readable name of the network. Changing this creates a new BMS server. * `port` - (Required unless `uuid` or `name` is provided) The port UUID of a network to attach to the BMS server. Changing this creates a new server. * `fixed_ip_v4` - (Optional) Specifies a fixed IPv4 address to be used on this network. Changing this creates a new BMS server. * `fixed_ip_v6` - (Optional) Specifies a fixed IPv6 address to be used on this network. Changing this creates a new BMS server. * `access_network` - (Optional) Specifies if this network should be used for provisioning access. Accepts true or false. Defaults to false. The `block_device` block supports: * `uuid` - (Required) The UUID of the image or volume to attach. * `source_type` - (Required) The type of the source, "image" or "volume". * `volume_type` - (Optional) The type of the volume, e.g., "SATA", "SSD", "GPSSD". * `volume_size` - (Optional) The size of the volume in GB. * `boot_index` - (Required) The boot index of the volume. * `destination_type` - (Required) The type of the destination, "volume" or "local_disk". * `delete_on_termination` - (Optional) Whether to delete the volume on instance termination. Defaults to false. * `device_name` - (Optional) The device name of the volume, e.g., "/dev/sda". ### Attributes Reference In addition to all arguments above, the following attributes are exported: * `id` - The id of the BMS server. * `config_drive` - Whether to use the config_drive feature to configure the instance. * `kernel_id` - The UUID of the kernel image when the AMI image is used. * `user_id` - The ID of the user to which the BMS belongs. * `host_status` - The nova-compute status: `UP`, `UNKNOWN`, `DOWN`, `MAINTENANCE` and `Null`. ``` -------------------------------- ### Creating a DMS instance with a topic Source: https://github.com/opentelekomcloud/terraform-provider-opentelekomcloud/blob/devel/docs/resources/dms_topic_v1.md This example demonstrates how to create a DMS instance and then create a topic within that instance. It requires setting up networking resources, retrieving availability zone and product information, and then defining the instance and topic resources. ```hcl resource "opentelekomcloud_networking_secgroup_v2" "secgroup_1" { name = "secgroup_1" description = "secgroup_1" } data "opentelekomcloud_dms_az_v1" "az_1" { name = "eu-de-01" } data "opentelekomcloud_dms_product_v1" "product_1" { engine = "kafka" version = "2.3.0" instance_type = "cluster" partition_num = 300 storage = 600 storage_spec_code = "dms.physical.storage.high" } resource "opentelekomcloud_dms_instance_v1" "instance_1" { name = "kafka-test" engine = "kafka" product_id = data.opentelekomcloud_dms_product_v1.product_1.id engine_version = data.opentelekomcloud_dms_product_v1.product_1.version specification = data.opentelekomcloud_dms_product_v1.product_1.bandwidth partition_num = data.opentelekomcloud_dms_product_v1.product_1.partition_num storage_spec_code = data.opentelekomcloud_dms_product_v1.product_1.storage_spec_code storage_space = data.opentelekomcloud_dms_product_v1.product_1.storage available_zones = [data.opentelekomcloud_dms_az_v1.az_1.id] security_group_id = opentelekomcloud_networking_secgroup_v2.secgroup_1.id vpc_id = var.vpc_id subnet_id = var.subnet_id access_user = var.access_user password = var.password } resource "opentelekomcloud_dms_topic_v1" "topic_1" { instance_id = resource.opentelekomcloud_dms_instance_v1.instance_1.id name = "topic-test" partition = 10 replication = 2 sync_replication = true retention_time = 80 } ``` -------------------------------- ### Get ECS Instance by Name Source: https://github.com/opentelekomcloud/terraform-provider-opentelekomcloud/blob/devel/releasenotes/source/data-sources/compute_instance_v2.md This example demonstrates how to fetch ECS instance details by specifying its name. ```APIDOC ## Data Source: opentelekomcloud_compute_instance_v2 ### Description Provides information about an Elastic Cloud Server (ECS) instance. ### Argument Reference * `name` - (Required) The name of the instance to search for. * `id` - (Required) The UUID of the instance. * `ssh_private_key_path` - (Optional) The path to the private key to use for SSH access. Required only if you want to get the password from the windows instance. ### Attributes Reference In addition to the above, the following attributes are exported: * `name` - The name of the server. * `description` - Server description. * `image_id` - The image ID used to create the server. * `image_name` - The image name used to create the server. * `flavor_id` - The flavor ID used to create the server. * `flavor_name` - The flavor name used to create the server. * `user_data` - The user data added when the server was created. * `security_groups` - An array of security group names associated with this server. * `availability_zone` - The availability zone of this server. * `network` - An array of maps, detailed below. * `access_ip_v4` - The first IPv4 address assigned to this server. * `access_ip_v6` - The first IPv6 address assigned to this server. * `key_pair` - The name of the key pair assigned to this server. * `tags` - A set of string tags assigned to this server. * `password` - The password of the server. This is only available if the server is a Windows server. If privateKey != nil the password is decrypted with the private key. * `encrypted_password` - The encrypted password of the server. This is only available if the server is a Windows server. If privateKey == nil the encrypted password is returned and can be decrypted with: echo '' | base64 -D | openssl rsautl -decrypt -inkey The `network` block is defined as: * `uuid` - The UUID of the network * `name` - The name of the network * `fixed_ip_v4` - The IPv4 address assigned to this network port. * `fixed_ip_v6` - The IPv6 address assigned to this network port. * `port` - The port UUID for this network * `mac` - The MAC address assigned to this network interface. ## Example Usage ```hcl data "opentelekomcloud_compute_instance_v2" "instance" { # Search ecs by name name = "server_1" } ``` ``` -------------------------------- ### Create an RDS Instance and a Read Replica Source: https://github.com/opentelekomcloud/terraform-provider-opentelekomcloud/blob/devel/docs/resources/rds_read_replica_v3.md This example demonstrates how to provision an RDS instance and then create a read replica for it using the `opentelekomcloud_rds_instance_v3` and `opentelekomcloud_rds_read_replica_v3` resources. ```hcl resource "opentelekomcloud_rds_instance_v3" "instance" { name = "test-instance" availability_zone = var.az_main db { password = var.db_password type = "PostgreSQL" version = "16" port = "8635" } security_group_id = var.sg_id subnet_id = var.os_network_id vpc_id = var.os_router_id flavor = "rds.pg.n1.medium.4.rr" volume { type = "CLOUDSSD" size = 40 } backup_strategy { start_time = "08:00-09:00" keep_days = 1 } tag = { created = "terraform" } } resource "opentelekomcloud_rds_read_replica_v3" "replica" { name = "test-replica" replica_of_id = opentelekomcloud_rds_instance_v3.instance.id flavor_ref = "${opentelekomcloud_rds_instance_v3.instance.flavor}.rr" availability_zone = var.az_replica volume { type = "CLOUDSSD" } } ``` -------------------------------- ### Get all CES alarm rules Source: https://github.com/opentelekomcloud/terraform-provider-opentelekomcloud/blob/devel/releasenotes/source/data-sources/ces_alarm_rules_v2.md This example demonstrates how to retrieve all CES alarm rules available in the OpenTelekomCloud account. ```APIDOC ## Data Source: opentelekomcloud_ces_alarm_rules_v2 Use this data source to get the list of CES alarm rules within OpenTelekomCloud. ### Example Usage ```hcl data "opentelekomcloud_ces_alarm_rules_v2" "all" {} ``` ## Argument Reference The following arguments are supported: * `alarm_id` - (Optional, String) Specifies the alarm rule ID. * `name` - (Optional, String) Specifies the name of an alarm rule. * `namespace` - (Optional, String) Specifies the namespace of a service. * `resource_id` - (Optional, String) Specifies the alarm resource ID. ## Attribute Reference In addition to all arguments above, the following attributes are exported: * `id` - The data source ID. * `alarms` - The alarm rule list. The `alarms` structure is documented below. The `alarms` block supports: * `alarm_id` - The alarm rule ID. * `name` - The alarm rule name. * `description` - The alarm rule description. * `namespace` - The namespace of a service. * `type` - The alarm rule type. * `alarm_enabled` - Whether the alarm rule is enabled. * `notification_enabled` - Whether the action to be triggered by an alarm is enabled. * `notification_begin_time` - The time when the alarm notification was enabled. * `notification_end_time` - The time when the alarm notification was disabled. * `enterprise_project_id` - The enterprise project ID. * `alarm_template_id` - The ID of an alarm template associated with an alarm rule. * `policies` - The alarm policy list. The `policies` structure is documented below. * `resources` - The resource list. The `resources` structure is documented below. * `alarm_actions` - The action triggered by an alarm. The `alarm_actions` structure is documented below. * `ok_actions` - The action triggered after an alarm is cleared. The `ok_actions` structure is documented below. The `policies` block supports: * `metric_name` - The metric name of a resource. * `period` - The monitoring period of a metric. * `filter` - The data rollup method. * `comparison_operator` - The comparison condition of alarm thresholds. * `value` - The alarm threshold. * `unit` - The metric unit. * `count` - The number of consecutive times that the alarm triggering conditions are met. * `suppress_duration` - The interval for triggering an alarm if the alarm persists. * `level` - The alarm severity. The `resources` block supports: * `dimensions` - The dimension information. The `dimensions` structure is documented below. The `dimensions` block supports: * `name` - The name of the metric dimension. * `value` - The value of the metric dimension. The `alarm_actions` or `ok_actions` blocks support: * `type` - The type of action triggered by an alarm. * `notification_list` - The list of objects to be notified if the alarm status changes. ``` -------------------------------- ### Get Identity Group by Name Source: https://github.com/opentelekomcloud/terraform-provider-opentelekomcloud/blob/devel/releasenotes/source/data-sources/identity_group_v3.md This example demonstrates how to use the `opentelekomcloud_identity_group_v3` data source to find an IAM group by its name. ```APIDOC ## Data Source: opentelekomcloud_identity_group_v3 Use this data source to get the ID of an OpenTelekomCloud group. -> **Note:** You *must* have `Security Administrator` privileges in your OpenTelekomCloud cloud to use this data source. Please refer to [User Management Model](https://docs.otc.t-systems.com/en-us/usermanual/iam/iam_01_0034.html). ### Example Usage ```hcl data "opentelekomcloud_identity_group_v3" "admins" { name = "admins" } ``` ### Argument Reference * `name` - (Required) The name of the group. * `domain_id` - (Optional) The domain the group belongs to. ### Attributes Reference `id` is set to the ID of the found group. In addition, the following attributes are exported: * `name` - See Argument Reference above. * `domain_id` - See Argument Reference above. ``` -------------------------------- ### Basic Port Creation Example Source: https://github.com/opentelekomcloud/terraform-provider-opentelekomcloud/blob/devel/docs/resources/networking_port_v2.md This example demonstrates how to create a basic network port, associating it with a specific subnet and assigning a static IP address. It also shows the necessary network and subnet resources that must be defined. ```hcl resource "opentelekomcloud_networking_port_v2" "port_1" { name = "port_1" admin_state_up = "true" network_id = opentelekomcloud_networking_network_v2.network_1.id fixed_ip { subnet_id = opentelekomcloud_networking_subnet_v2.subnet_1.id ip_address = "192.168.199.23" } } resource "opentelekomcloud_networking_network_v2" "network_1" { name = "network_1" admin_state_up = "true" } resource "opentelekomcloud_networking_subnet_v2" "subnet_1" { name = "subnet_1" cidr = "192.168.199.0/24" ip_version = 4 network_id = opentelekomcloud_networking_network_v2.network_1.id } ``` -------------------------------- ### Create CSS Cluster and Snapshot Configuration Source: https://github.com/opentelekomcloud/terraform-provider-opentelekomcloud/blob/devel/docs/resources/css_snapshot_configuration_v1.md This example demonstrates how to provision a CSS cluster and then configure automatic snapshot creation, specifying the OBS bucket, agency, base path, and creation policy details. ```hcl data "opentelekomcloud_networking_secgroup_v2" "secgroup" { name = var.security_group } resource "opentelekomcloud_css_cluster_v1" "cluster" { name = "terraform_test_cluster" expect_node_num = 1 node_config { flavor = "css.medium.8" network_info { security_group_id = data.opentelekomcloud_networking_secgroup_v2.secgroup.id network_id = var.network_id vpc_id = var.vpc_id } volume { volume_type = "COMMON" size = 40 } availability_zone = var.availability_zone } } resource "opentelekomcloud_obs_bucket" "bucket" { bucket = "tf-snap-testing" force_destroy = true } resource "opentelekomcloud_css_snapshot_configuration_v1" "config" { cluster_id = opentelekomcloud_css_cluster_v1.cluster.id configuration { bucket = opentelekomcloud_obs_bucket.bucket.bucket agency = "css_obs_agency" base_path = "css/snapshot" } creation_policy { prefix = "snapshot" period = "00:00 GMT+03:00" keepday = 2 enable = true delete_auto = true frequency = "DAY" } } ``` -------------------------------- ### Get ECS Instance by ID Source: https://github.com/opentelekomcloud/terraform-provider-opentelekomcloud/blob/devel/releasenotes/source/data-sources/compute_instance_v2.md This example shows how to retrieve ECS instance details using its unique ID (UUID). ```APIDOC ## Data Source: opentelekomcloud_compute_instance_v2 ### Description Provides information about an Elastic Cloud Server (ECS) instance. ### Argument Reference * `name` - (Required) The name of the instance to search for. * `id` - (Required) The UUID of the instance. * `ssh_private_key_path` - (Optional) The path to the private key to use for SSH access. Required only if you want to get the password from the windows instance. ### Attributes Reference In addition to the above, the following attributes are exported: * `name` - The name of the server. * `description` - Server description. * `image_id` - The image ID used to create the server. * `image_name` - The image name used to create the server. * `flavor_id` - The flavor ID used to create the server. * `flavor_name` - The flavor name used to create the server. * `user_data` - The user data added when the server was created. * `security_groups` - An array of security group names associated with this server. * `availability_zone` - The availability zone of this server. * `network` - An array of maps, detailed below. * `access_ip_v4` - The first IPv4 address assigned to this server. * `access_ip_v6` - The first IPv6 address assigned to this server. * `key_pair` - The name of the key pair assigned to this server. * `tags` - A set of string tags assigned to this server. * `password` - The password of the server. This is only available if the server is a Windows server. If privateKey != nil the password is decrypted with the private key. * `encrypted_password` - The encrypted password of the server. This is only available if the server is a Windows server. If privateKey == nil the encrypted password is returned and can be decrypted with: echo '' | base64 -D | openssl rsautl -decrypt -inkey The `network` block is defined as: * `uuid` - The UUID of the network * `name` - The name of the network * `fixed_ip_v4` - The IPv4 address assigned to this network port. * `fixed_ip_v6` - The IPv6 address assigned to this network port. * `port` - The port UUID for this network * `mac` - The MAC address assigned to this network interface. ## Example Usage ```hcl data "opentelekomcloud_compute_instance_v2" "instance" { # Randomly generated UUID, for demonstration purposes id = "2ba26dc6-a12d-4889-8f25-794ea5bf4453" } ``` ``` -------------------------------- ### Terraform Example Usage Commands Source: https://github.com/opentelekomcloud/terraform-provider-opentelekomcloud/blob/devel/examples/README.md Standard commands to initialize, plan, apply, and destroy Terraform resources. Run these in your example directory. ```shell terraform init terraform plan terraform apply terraform destroy ``` -------------------------------- ### Get VPC EIP by ID Source: https://github.com/opentelekomcloud/terraform-provider-opentelekomcloud/blob/devel/docs/data-sources/vpc_eip_v1.md This example demonstrates how to retrieve details of a specific VPC Elastic IP using its ID. ```APIDOC ## Get VPC EIP by ID ### Description Retrieves details of a specific VPC Elastic IP using its unique identifier. ### Method GET ### Endpoint /v1.0/eips/{id} ### Parameters #### Path Parameters - **id** (string) - Required - The unique identifier (UUID) of the elastic IP. ### Response #### Success Response (200) - **id** (string) - The unique identifier of the elastic IP. - **name** (string) - The name of the elastic IP. - **public_ip_address** (string) - The public IP address. - **private_ip_address** (string) - The private IP address associated with the EIP (if any). - **status** (string) - The status of the elastic IP. - **ip_version** (string) - The IP version of the elastic IP. - **bandwidth_share_type** (string) - The bandwidth share type. - **bandwidth_size** (integer) - The bandwidth size in Mbit/s. - **create_time** (string) - The time (UTC) when the elastic IP was assigned. - **tenant_id** (string) - The project ID. - **type** (string) - The type of the elastic IP. - **port_id** (string) - The ID of the associated port (if any). - **bandwidth_id** (string) - The ID of the associated bandwidth. - **tags** (map[string]string) - Tags associated with the elastic IP. ### Response Example ```json { "id": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", "name": "my-eip-name", "public_ip_address": "192.168.1.1", "private_ip_address": "10.0.0.1", "status": "ACTIVE", "ip_version": "ipv4", "bandwidth_share_type": "PER", "bandwidth_size": 100, "create_time": "2023-10-27T10:00:00Z", "tenant_id": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", "type": "5_bgp", "port_id": "yyyyyyyy-yyyy-yyyy-yyyy-yyyyyyyyyyyy", "bandwidth_id": "zzzzzzzz-zzzz-zzzz-zzzz-zzzzzzzzzzzz", "tags": { "environment": "production" } } ``` ``` -------------------------------- ### Create a Cloud WAF Instance Source: https://github.com/opentelekomcloud/terraform-provider-opentelekomcloud/blob/devel/docs/resources/waf_cloud_instance_v1.md Example of how to declare and configure a `opentelekomcloud_waf_cloud_instance_v1` resource. Ensure the `website` argument is set to the correct cloud website value. ```hcl resource "opentelekomcloud_waf_cloud_instance_v1" "cloud_1" { charging_mode = "postPaid" website = "dt" } ``` -------------------------------- ### Get all CCI v2 namespaces Source: https://github.com/opentelekomcloud/terraform-provider-opentelekomcloud/blob/devel/docs/data-sources/cci_namespaces_v2.md This example demonstrates how to use the data source to fetch all available CCI v2 namespaces. ```APIDOC ## opentelekomcloud_cci_namespaces_v2 Use this data source to get the list of CCI v2 namespaces within OpenTelekomCloud. ### Example Usage ```hcl data "opentelekomcloud_cci_namespaces_v2" "all" {} ``` ### Argument Reference The following arguments are supported: * `name` - (Optional, String) Specifies the name of the namespace used to query the namespace detail. If omitted, the list of all namespaces is returned. ### Attribute Reference In addition to all arguments above, the following attributes are exported: * `id` - The data source ID. * `region` - The region in which the namespaces are queried. * `namespaces` - The list of namespaces. The [namespaces]() structure is documented below. The `namespaces` block supports: * `name` - The name of the namespace. * `api_version` - The API version of the namespace. * `kind` - The kind of the namespace. * `annotations` - The annotations of the namespace. * `labels` - The labels of the namespace. * `creation_timestamp` - The creation timestamp of the namespace. * `finalizers` - The finalizers of the namespace. * `resource_version` - The resource version of the namespace. * `uid` - The uid of the namespace. * `status` - The status of the namespace. ``` -------------------------------- ### Creating a basic DDM instance Source: https://github.com/opentelekomcloud/terraform-provider-opentelekomcloud/blob/devel/releasenotes/source/resources/ddm_instance_v1.md Example of creating a basic DDM instance with essential parameters like name, availability zones, flavor, node count, engine, VPC, subnet, and security group. ```APIDOC ## Resource: opentelekomcloud_ddm_instance_v1 ### Description Manages a DDM instance resource within OpenTelekomCloud. ### Arguments * `name` - (Required, String) Specifies the DDM instance name. The DDM instance name of the same type is unique in the same tenant. It can be 4 to 64 characters long. It must start with a letter and it can only contain letters, digits, and hyphens (-). * `availability_zones` - (Required, List, ForceNew) Specifies the list of availability zones. * `vpc_id` - (Required, String, ForceNew) Specifies the VPC ID. * `subnet_id` - (Required, String, ForceNew) Specifies the subnet Network ID. * `security_group_id` - (Required, String) Specifies the security group ID of the DDM instance. * `node_num` - (Required, Integer) Specifies the number of nodes for the instance. * `flavor_id` - (Required, String, ForceNew) Specifies the flavor ID of the instance nodes. * `engine_id` - (Required, String, ForceNew) Specifies the Engine ID of the instance. * `purge_rds_on_delete` - (Optional, Boolean) Specifies whether data stored on the associated DB instances is deleted. The value can be: `true` or `false` (default). ### Request Example ```hcl resource "opentelekomcloud_ddm_instance_v1" "instance_1" { name = "ddm-instance" availability_zones = ["eu-de-01", "eu-de-02", "eu-de-03"] flavor_id = var.flavor_id node_num = 2 engine_id = var.engine_id vpc_id = var.vpc_id subnet_id = var.subnet_id security_group_id = var.security_group.id purge_rds_on_delete = true } ``` ```