Alibaba Cloud Terraform Provider

repository·master·Indexed 20 days ago

https://github.com/aliyun/terraform-provider-alicloud

The Alibaba Cloud Terraform Provider enables the management of Alibaba Cloud resources using Terraform's Infrastructure as Code (IaC) workflows. It provides a Go-based implementation for interacting with various Alibaba Cloud services, including ECS, VPC, OSS, and PolarDB, utilizing a functional With*Client pattern for service client access and supporting both RPC and ROA API invocations.

Tokens
383.6K
Snippets
723
Records
1.5K
Agent score
69%

What's inside terraform-provider-alicloud

  1. Manage Lindorm Instances with alicloud_lindorm_instance

    master

    The alicloud_lindorm_instance resource allows you to provision and manage a Lindorm Instance on Alibaba Cloud.

    Important Limitations:

    • The Lindorm Instance does not support updating the specifications of multiple different engines or the number of nodes simultaneously.
    • Some parameters require ForceNew (recreation of the resource) if changed.

    Key Configuration Areas:

    • Network: Requires vswitch_id and optionally vpc_id.
    • Billing: Supports PayAsYouGo and Subscription via payment_type.
    • Storage: Configure disk_category (e.g., cloud_efficiency, cloud_ssd, cloud_essd) and instance_storage (in GB, must be divisible by 80).
    • Engine Specifications: You can configure specific nodes and specifications for various engines including table_engine, search_engine, file_engine, time_series_engine, stream_engine, and lts_node (Lindorm Tunnel Service).
    provider "alicloud" {
      region = local.region
    }
    
    variable "name" {
      default = "tf-example"
    }
    
    locals {
      region  = "cn-hangzhou"
      zone_id = "cn-hangzhou-h"
    }
    
    data "alicloud_zones" "default" {
      available_resource_creation = "VSwitch"
    }
    
    data "alicloud_vpcs" "default" {
      name_regex = "^default-NODELETING$"
    }
    
    data "alicloud_vswitches" "default" {
      vpc_id  = data.alicloud_vpcs.default.ids.0
      zone_id = local.zone_id
    }
    
    resource "alicloud_lindorm_instance" "default" {
      disk_category              = "cloud_efficiency"
      payment_type               = "PayAsYouGo"
      zone_id                    = local.zone_id
      vswitch_id                 = data.alicloud_vswitches.default.ids.0
      vpc_id                     = data.alicloud_vpcs.default.ids.0
      instance_name              = var.name
      table_engine_specification = "lindorm.g.4xlarge"
      table_engine_node_count    = "2"
      instance_storage           = "1920"
    }
  2. Manage Alibaba Cloud Kubernetes (ACK) clusters with alicloud_cs_kubernetes

    master

    The alicloud_cs_kubernetes resource allows you to manage a Kubernetes Cluster in Alibaba Cloud Container Service for Kubernetes (ACK).

    Important Notices:

    • DEPRECATION: This resource has been deprecated since v1.276.0 and will be removed in a future release. It is highly recommended to use alicloud_cs_kubernetes_node_pool to manage worker nodes instead of the deprecated parameters in this resource.
    • ACK Dedicated Clusters: As of August 21, 2024, ACK dedicated clusters are no longer being created.
    • Network Requirements: Kubernetes clusters only support VPC networks. To ensure the VPC can access the internet, you can use a NAT Gateway. If no NAT Gateway exists in the VPC, set new_nat_gateway = "true" to create one automatically.
    • Master Nodes: Each cluster contains 3 master nodes, and this number is currently fixed.
    • Setup Time: Creating a cluster involves installing several packages and typically takes approximately 15 minutes.
    • Post-Creation Config: Since version 1.9.4, the provider supports downloading kube config, client certificates, client keys, and cluster CA certificates to a specified location (e.g., ~/.kube/config) after successful creation.
    • Multi-AZ Support: Since version 1.16.0, you can create Multiple Availability Zone clusters by specifying 3 or 5 items in master_vswitch_ids and master_instance_types.
    resource "alicloud_cs_kubernetes" "example" {
      # Configuration details go here
    }
  3. List Global Accelerator (GA) ACLs with alicloud_ga_acls

    master

    The alicloud_ga_acls data source allows you to retrieve a list of Global Accelerator (GA) Access Control Lists (ACLs) associated with your Alibaba Cloud account. You can filter the results by name using a regex, by specific ACL IDs, by name, or by the resource status.

    Note: This data source is available since provider version v1.150.0.

    # Basic usage to fetch all ACLs
    data "alicloud_ga_acls" "ids" {}
    
    # Usage with a name filter using regex
    data "alicloud_ga_acls" "nameRegex" {
      name_regex = "^my-Acl"
    }
  4. Manage ACK Node Pools with alicloud_cs_kubernetes_node_pool

    master

    The alicloud_cs_kubernetes_node_pool resource allows you to manage node pools within an Alibaba Cloud Container Service for Kubernetes (ACK) cluster. It is recommended to create a cluster with zero worker nodes and then use node pools to manage the cluster's nodes.

    Key Version Features

    • v1.97.0+: Initial availability.
    • v1.109.1+: Support for managed node pools (professional managed clusters only) and removing node pool nodes.
    • v1.111.0+: Support for auto-scaling node pools.
    • v1.123.1+: Support for creating node pools using spot instances.
    • v1.127.0+: Support for adding existing nodes to a node pool.
    • v1.149.0+: Support for specifying deployment_set.
    • v1.158.0+: Support for specifying the desired size of nodes.
    • v1.166.0+: Support for system disk encryption.
    • v1.177.0+: Support for kms_encryption_context, rds_instances, system_disk_snapshot_policy_id, cpu_policy, and spot strategies SpotAsPriceGo and NoSpot.
    • v1.180.0+: Support for customized kubelet parameters via kubelet_configuration and rollout_policy.
    • v1.185.0+: rollout_policy is deprecated; use rolling_policy instead.
  5. Manage ROS Stack Instances in bulk with alicloud_ros_stack_instances

    master

    The alicloud_ros_stack_instances resource allows you to deploy, update, or remove Resource Orchestration Service (ROS) stack instances in bulk across multiple target regions and Alibaba Cloud accounts within a Stack Group. It supports two permission models:

    1. Self-managed permissions: Use the account_ids argument to specify target accounts.
    2. Service-managed permissions: Use the deployment_targets block to specify target accounts or Resource Directory (rd_folder_ids) folders.

    Note: You must specify either account_ids or deployment_targets, but not both.

    Available since v1.279.0.

    resource "alicloud_ros_stack_instances" "self_managed" {
      stack_group_name = alicloud_ros_stack_group.default.stack_group_name
      region_ids       = ["cn-beijing", "cn-shanghai"]
      account_ids      = ["123456789012****"]
    
      parameter_overrides {
        parameter_value = "VpcName"
        parameter_key   = "VpcName"
      }
      timeout_in_minutes    = 45
      operation_description = "Batch deployment for production environment"
      disable_rollback      = false
    }
  6. Use alicloud_eip for Elastic IP Address

    master

    alicloud_eip provides an Elastic IP (EIP) resource.

    DEPRECATION WARNING: This resource has been deprecated since version 1.126.0. Users should migrate to the alicloud_eip_address resource.

    International Account Constraints: If you are using an international account, this resource only supports creating PostPaid PayByTraffic or PrePaid PayByBandwidth EIPs. Attempting other combinations will result in the error COMMODITY.INVALID_COMPONENT.

    Key Features:

    • Supports creating "PrePaid" EIPs (since v1.10.1).
    • Supports setting EIP name and description.
    • Supports deletion protection (since v1.124.4+).
    # Create a new EIP.
    resource "alicloud_eip" "example" {
      bandwidth            = "10"
      internet_charge_type = "PayByBandwidth"
    }
  7. Manage Function Compute Async Invoke Config (Legacy)

    master

    The alicloud_fc_function_async_invoke_config resource manages asynchronous invocation configurations for an Alibaba Cloud Function Compute (FC) Function or Alias.

    ⚠️ DEPRECATION NOTICE: This resource uses the legacy Function Compute API. For new deployments and access to the latest FCV3 capabilities, you should use the alicloud_fcv3_async_invoke_config resource instead. The legacy resource only supports basic functionality.

    Permissions Requirement: Ensure the FC Function's RAM Role has the necessary permissions for the configured destination (e.g., mns:SendMessage, mns:PublishMessage, or fc:InvokeFunction). Failure to provide these permissions will result in a generic error from the API.

    # Example Usage
    
    ```terraform
    resource "alicloud_fc_function_async_invoke_config" "default" {
      service_name  = alicloud_fc_service.default.name
      function_name = alicloud_fc_function.default.name
    
      destination_config {
        on_failure {
          destination = "acs:mns:${data.alicloud_regions.default.regions.0.id}:${data.alicloud_account.default.id}:/queues/${alicloud_mns_queue.default.name}/messages"
        }
    
        on_success {
          destination = "acs:mns:${data.alicloud_regions.default.regions.0.id}:${data.alicloud_account.default.id}:/topics/${alicloud_mns_topic.default.name}/messages"
        }
      }
    
      maximum_event_age_in_seconds = 60
      maximum_retry_attempts       = 0
      stateful_invocation          = true
      qualifier                    = "LATEST"
    }
  8. Manage Alicloud Bastion Host Instances with `alicloud_bastionhost_instance`

    master

    The alicloud_bastionhost_instance resource (formerly alicloud_yundun_bastionhost_instance before version 1.132.0) allows you to provision and manage Cloud Bastion Host instances.

    Important Constraints:

    • Destruction: Terraform cannot automatically destroy a bastionhost instance. Removing the resource from your configuration or deleting the subscription resource will only remove it from the Terraform state; it will not destroy the actual instance in Alibaba Cloud. To destroy an instance, you must apply for a whitelist first. After removal from Terraform, you can manage the instance via the AlibabaCloud Console.
    • Endpoint: The bssopenapi endpoint currently only supports business.aliyuncs.com.
    resource "alicloud_bastionhost_instance" "default" {
      description        = "example"
      license_code       = "bhah_ent_50_asset"
      plan_code          = "cloudbastion"
      storage            = "5"
      bandwidth          = "5"
      period             = "1"
      vswitch_id         = "vsw-xxxxxx"
      security_group_ids = ["sg-xxxxxx"]
    }
  9. Manage PolarDB Batch Tasks with alicloud_polardb_batch_task

    master

    The alicloud_polardb_batch_task resource manages batch operations across multiple PolarDB instances simultaneously, such as installing or uninstalling skills (e.g., Polar Claw).

    Important Note: This resource represents an asynchronous operation. Removing the resource from your Terraform configuration will remove it from your statefile, but it will not undo the actions performed by the task (e.g., it will not uninstall skills if the task was an installation). You must verify the status of instances via the PolarDB Console.

    Available since provider version v1.279.0.

    resource "alicloud_polardb_batch_task" "default" {
      task_name    = "terraform-batch-task-example"
      task_type    = "polarclaw_install_skills"
      region_id    = "cn-hangzhou"
      instance_ids = ["pa-xxx", "pa-abc"]
    
      task_params {
        skill_name = "ontology"
        version    = "1.0.4"
      }
    }
  10. Manage Alicloud Eflo Node resources

    master

    The alicloud_eflo_node resource provides access to Eflo Nodes, which are large computing nodes. This resource is available starting from provider version v1.246.0.

    Important Note on Subscription Instances: If you manage a node with payment_type = "Subscription", Terraform cannot destroy it. Deleting the resource from your configuration or running terraform destroy will only remove the node from your Terraform state file; it will not terminate the actual instance in Alibaba Cloud. To manage or terminate subscription instances, you must use the AlibabaCloud Console.

    terraform import alicloud_eflo_node.example <id>
  11. Manage Resource Manager Resource Group Settings

    master

    The alicloud_resource_manager_resource_group_settings resource allows you to configure product feature settings for Resource Groups. This includes managing automatic group transfers, designating resource group administrators, and setting up default resource group transfer notifications.

    Note: This resource is available since provider version v1.287.0.

    resource "alicloud_resource_manager_resource_group_settings" "default" {
      resource_group_admin_setting_status        = true
      resource_group_notification_setting_status = true
    }
  12. Manage Serverless Kubernetes clusters with alicloud_cs_serverless_kubernetes

    master

    The alicloud_cs_serverless_kubernetes resource manages a Container Service for Kubernetes (ACK) Serverless Cluster.

    DEPRECATION NOTICE: This resource has been deprecated since v1.276.0. Users should migrate to alicloud_cs_managed_kubernetes for future-proofing.

    Key Requirements and Behaviors:

    • Network: Supports only VPC networks. The cluster can access the internet during creation.
    • Internet Access: To ensure VPC network access to the internet, a NAT Gateway with SNAT configuration is required. If no NAT Gateway exists in the VPC, you can set new_nat_gateway = true to create one automatically.
    • Provisioning Time: Creating a cluster involves installing several packages and typically takes approximately 5 minutes.
    • Post-Creation: The provider supports downloading the kube config, client certificate, client key, and cluster CA certificate after successful creation. These can be placed in locations like ~/.kube/config.
    • Prerequisites: You must activate several required products and confirm the Authorization Policy used by Container Service via the Alibaba Cloud Document Center before use.
    • Cluster Types:
      • Professional serverless clusters are supported from version 1.162.0.
      • Migration from basic to professional serverless clusters is supported from version 1.229.1.

    To manage the Kubernetes resources within the cluster once created, it is recommended to use the Kubernetes Provider.

    variable "name" {
      default = "ask-example-pro"
    }
    
    data "alicloud_zones" "default" {
      available_resource_creation = "VSwitch"
    }
    
    resource "alicloud_vpc" "default" {
      vpc_name   = var.name
      cidr_block = "10.2.0.0/21"
    }
    
    resource "alicloud_vswitch" "default" {
      vswitch_name = var.name
      vpc_id       = alicloud_vpc.default.id
      cidr_block   = "10.2.1.0/24"
      zone_id      = data.alicloud_zones.default.zones[0].id
    }
    
    resource "alicloud_cs_serverless_kubernetes" "serverless" {
      name_prefix                    = var.name
      cluster_spec                   = "ack.pro.small"
      vpc_id                         = alicloud_vpc.default.id
      vswitch_ids                    = [alicloud_vswitch.default.id]
      new_nat_gateway                = true
      endpoint_public_access_enabled = true
      deletion_protection            = false
      time_zone                      = "Asia/Shanghai"
      service_cidr                   = "172.21.0.0/20"
    
      # tags
      tags = {
        "k-aa" = "v-aa"
        "k-bb" = "v-bb"
      }
    }