1. Packages
  2. Alibaba Cloud Provider
  3. API Docs
  4. das
  5. SwitchDasPro
Alibaba Cloud v3.76.0 published on Tuesday, Apr 8, 2025 by Pulumi

alicloud.das.SwitchDasPro

Explore with Pulumi AI

Provides a DAS Switch Das Pro resource.

For information about DAS Switch Das Pro and how to use it, see What is Switch Das Pro.

NOTE: Available since v1.193.0.

Example Usage

Basic Usage

import * as pulumi from "@pulumi/pulumi";
import * as alicloud from "@pulumi/alicloud";

const config = new pulumi.Config();
const name = config.get("name") || "tfexample";
const _default = alicloud.getAccount({});
const defaultGetNodeClasses = alicloud.polardb.getNodeClasses({
    dbType: "MySQL",
    dbVersion: "8.0",
    payType: "PostPaid",
});
const defaultNetwork = new alicloud.vpc.Network("default", {
    vpcName: name,
    cidrBlock: "172.16.0.0/16",
});
const defaultSwitch = new alicloud.vpc.Switch("default", {
    vpcId: defaultNetwork.id,
    cidrBlock: "172.16.0.0/24",
    zoneId: defaultGetNodeClasses.then(defaultGetNodeClasses => defaultGetNodeClasses.classes?.[0]?.zoneId),
    vswitchName: name,
});
const defaultCluster = new alicloud.polardb.Cluster("default", {
    dbType: "MySQL",
    dbVersion: "8.0",
    dbNodeClass: "polar.mysql.x4.large",
    payType: "PostPaid",
    vswitchId: defaultSwitch.id,
    description: name,
    dbClusterIpArrays: [{
        dbClusterIpArrayName: "default",
        securityIps: [
            "1.2.3.4",
            "1.2.3.5",
        ],
    }],
});
const defaultSwitchDasPro = new alicloud.das.SwitchDasPro("default", {
    instanceId: defaultCluster.id,
    sqlRetention: 30,
    userId: _default.then(_default => _default.id),
});
Copy
import pulumi
import pulumi_alicloud as alicloud

config = pulumi.Config()
name = config.get("name")
if name is None:
    name = "tfexample"
default = alicloud.get_account()
default_get_node_classes = alicloud.polardb.get_node_classes(db_type="MySQL",
    db_version="8.0",
    pay_type="PostPaid")
default_network = alicloud.vpc.Network("default",
    vpc_name=name,
    cidr_block="172.16.0.0/16")
default_switch = alicloud.vpc.Switch("default",
    vpc_id=default_network.id,
    cidr_block="172.16.0.0/24",
    zone_id=default_get_node_classes.classes[0].zone_id,
    vswitch_name=name)
default_cluster = alicloud.polardb.Cluster("default",
    db_type="MySQL",
    db_version="8.0",
    db_node_class="polar.mysql.x4.large",
    pay_type="PostPaid",
    vswitch_id=default_switch.id,
    description=name,
    db_cluster_ip_arrays=[{
        "db_cluster_ip_array_name": "default",
        "security_ips": [
            "1.2.3.4",
            "1.2.3.5",
        ],
    }])
default_switch_das_pro = alicloud.das.SwitchDasPro("default",
    instance_id=default_cluster.id,
    sql_retention=30,
    user_id=default.id)
Copy
package main

import (
	"github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud"
	"github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud/das"
	"github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud/polardb"
	"github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud/vpc"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi"
	"github.com/pulumi/pulumi/sdk/v3/go/pulumi/config"
)

func main() {
	pulumi.Run(func(ctx *pulumi.Context) error {
		cfg := config.New(ctx, "")
		name := "tfexample"
		if param := cfg.Get("name"); param != "" {
			name = param
		}
		_default, err := alicloud.GetAccount(ctx, map[string]interface{}{}, nil)
		if err != nil {
			return err
		}
		defaultGetNodeClasses, err := polardb.GetNodeClasses(ctx, &polardb.GetNodeClassesArgs{
			DbType:    pulumi.StringRef("MySQL"),
			DbVersion: pulumi.StringRef("8.0"),
			PayType:   "PostPaid",
		}, nil)
		if err != nil {
			return err
		}
		defaultNetwork, err := vpc.NewNetwork(ctx, "default", &vpc.NetworkArgs{
			VpcName:   pulumi.String(name),
			CidrBlock: pulumi.String("172.16.0.0/16"),
		})
		if err != nil {
			return err
		}
		defaultSwitch, err := vpc.NewSwitch(ctx, "default", &vpc.SwitchArgs{
			VpcId:       defaultNetwork.ID(),
			CidrBlock:   pulumi.String("172.16.0.0/24"),
			ZoneId:      pulumi.String(defaultGetNodeClasses.Classes[0].ZoneId),
			VswitchName: pulumi.String(name),
		})
		if err != nil {
			return err
		}
		defaultCluster, err := polardb.NewCluster(ctx, "default", &polardb.ClusterArgs{
			DbType:      pulumi.String("MySQL"),
			DbVersion:   pulumi.String("8.0"),
			DbNodeClass: pulumi.String("polar.mysql.x4.large"),
			PayType:     pulumi.String("PostPaid"),
			VswitchId:   defaultSwitch.ID(),
			Description: pulumi.String(name),
			DbClusterIpArrays: polardb.ClusterDbClusterIpArrayArray{
				&polardb.ClusterDbClusterIpArrayArgs{
					DbClusterIpArrayName: pulumi.String("default"),
					SecurityIps: pulumi.StringArray{
						pulumi.String("1.2.3.4"),
						pulumi.String("1.2.3.5"),
					},
				},
			},
		})
		if err != nil {
			return err
		}
		_, err = das.NewSwitchDasPro(ctx, "default", &das.SwitchDasProArgs{
			InstanceId:   defaultCluster.ID(),
			SqlRetention: pulumi.Int(30),
			UserId:       pulumi.String(_default.Id),
		})
		if err != nil {
			return err
		}
		return nil
	})
}
Copy
using System.Collections.Generic;
using System.Linq;
using Pulumi;
using AliCloud = Pulumi.AliCloud;

return await Deployment.RunAsync(() => 
{
    var config = new Config();
    var name = config.Get("name") ?? "tfexample";
    var @default = AliCloud.GetAccount.Invoke();

    var defaultGetNodeClasses = AliCloud.PolarDB.GetNodeClasses.Invoke(new()
    {
        DbType = "MySQL",
        DbVersion = "8.0",
        PayType = "PostPaid",
    });

    var defaultNetwork = new AliCloud.Vpc.Network("default", new()
    {
        VpcName = name,
        CidrBlock = "172.16.0.0/16",
    });

    var defaultSwitch = new AliCloud.Vpc.Switch("default", new()
    {
        VpcId = defaultNetwork.Id,
        CidrBlock = "172.16.0.0/24",
        ZoneId = defaultGetNodeClasses.Apply(getNodeClassesResult => getNodeClassesResult.Classes[0]?.ZoneId),
        VswitchName = name,
    });

    var defaultCluster = new AliCloud.PolarDB.Cluster("default", new()
    {
        DbType = "MySQL",
        DbVersion = "8.0",
        DbNodeClass = "polar.mysql.x4.large",
        PayType = "PostPaid",
        VswitchId = defaultSwitch.Id,
        Description = name,
        DbClusterIpArrays = new[]
        {
            new AliCloud.PolarDB.Inputs.ClusterDbClusterIpArrayArgs
            {
                DbClusterIpArrayName = "default",
                SecurityIps = new[]
                {
                    "1.2.3.4",
                    "1.2.3.5",
                },
            },
        },
    });

    var defaultSwitchDasPro = new AliCloud.Das.SwitchDasPro("default", new()
    {
        InstanceId = defaultCluster.Id,
        SqlRetention = 30,
        UserId = @default.Apply(@default => @default.Apply(getAccountResult => getAccountResult.Id)),
    });

});
Copy
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.alicloud.AlicloudFunctions;
import com.pulumi.alicloud.polardb.PolardbFunctions;
import com.pulumi.alicloud.polardb.inputs.GetNodeClassesArgs;
import com.pulumi.alicloud.vpc.Network;
import com.pulumi.alicloud.vpc.NetworkArgs;
import com.pulumi.alicloud.vpc.Switch;
import com.pulumi.alicloud.vpc.SwitchArgs;
import com.pulumi.alicloud.polardb.Cluster;
import com.pulumi.alicloud.polardb.ClusterArgs;
import com.pulumi.alicloud.polardb.inputs.ClusterDbClusterIpArrayArgs;
import com.pulumi.alicloud.das.SwitchDasPro;
import com.pulumi.alicloud.das.SwitchDasProArgs;
import java.util.List;
import java.util.ArrayList;
import java.util.Map;
import java.io.File;
import java.nio.file.Files;
import java.nio.file.Paths;

public class App {
    public static void main(String[] args) {
        Pulumi.run(App::stack);
    }

    public static void stack(Context ctx) {
        final var config = ctx.config();
        final var name = config.get("name").orElse("tfexample");
        final var default = AlicloudFunctions.getAccount();

        final var defaultGetNodeClasses = PolardbFunctions.getNodeClasses(GetNodeClassesArgs.builder()
            .dbType("MySQL")
            .dbVersion("8.0")
            .payType("PostPaid")
            .build());

        var defaultNetwork = new Network("defaultNetwork", NetworkArgs.builder()
            .vpcName(name)
            .cidrBlock("172.16.0.0/16")
            .build());

        var defaultSwitch = new Switch("defaultSwitch", SwitchArgs.builder()
            .vpcId(defaultNetwork.id())
            .cidrBlock("172.16.0.0/24")
            .zoneId(defaultGetNodeClasses.applyValue(getNodeClassesResult -> getNodeClassesResult.classes()[0].zoneId()))
            .vswitchName(name)
            .build());

        var defaultCluster = new Cluster("defaultCluster", ClusterArgs.builder()
            .dbType("MySQL")
            .dbVersion("8.0")
            .dbNodeClass("polar.mysql.x4.large")
            .payType("PostPaid")
            .vswitchId(defaultSwitch.id())
            .description(name)
            .dbClusterIpArrays(ClusterDbClusterIpArrayArgs.builder()
                .dbClusterIpArrayName("default")
                .securityIps(                
                    "1.2.3.4",
                    "1.2.3.5")
                .build())
            .build());

        var defaultSwitchDasPro = new SwitchDasPro("defaultSwitchDasPro", SwitchDasProArgs.builder()
            .instanceId(defaultCluster.id())
            .sqlRetention(30)
            .userId(default_.id())
            .build());

    }
}
Copy
configuration:
  name:
    type: string
    default: tfexample
resources:
  defaultNetwork:
    type: alicloud:vpc:Network
    name: default
    properties:
      vpcName: ${name}
      cidrBlock: 172.16.0.0/16
  defaultSwitch:
    type: alicloud:vpc:Switch
    name: default
    properties:
      vpcId: ${defaultNetwork.id}
      cidrBlock: 172.16.0.0/24
      zoneId: ${defaultGetNodeClasses.classes[0].zoneId}
      vswitchName: ${name}
  defaultCluster:
    type: alicloud:polardb:Cluster
    name: default
    properties:
      dbType: MySQL
      dbVersion: '8.0'
      dbNodeClass: polar.mysql.x4.large
      payType: PostPaid
      vswitchId: ${defaultSwitch.id}
      description: ${name}
      dbClusterIpArrays:
        - dbClusterIpArrayName: default
          securityIps:
            - 1.2.3.4
            - 1.2.3.5
  defaultSwitchDasPro:
    type: alicloud:das:SwitchDasPro
    name: default
    properties:
      instanceId: ${defaultCluster.id}
      sqlRetention: 30
      userId: ${default.id}
variables:
  default:
    fn::invoke:
      function: alicloud:getAccount
      arguments: {}
  defaultGetNodeClasses:
    fn::invoke:
      function: alicloud:polardb:getNodeClasses
      arguments:
        dbType: MySQL
        dbVersion: '8.0'
        payType: PostPaid
Copy

Create SwitchDasPro Resource

Resources are created with functions called constructors. To learn more about declaring and configuring resources, see Resources.

Constructor syntax

new SwitchDasPro(name: string, args: SwitchDasProArgs, opts?: CustomResourceOptions);
@overload
def SwitchDasPro(resource_name: str,
                 args: SwitchDasProArgs,
                 opts: Optional[ResourceOptions] = None)

@overload
def SwitchDasPro(resource_name: str,
                 opts: Optional[ResourceOptions] = None,
                 instance_id: Optional[str] = None,
                 sql_retention: Optional[int] = None,
                 user_id: Optional[str] = None)
func NewSwitchDasPro(ctx *Context, name string, args SwitchDasProArgs, opts ...ResourceOption) (*SwitchDasPro, error)
public SwitchDasPro(string name, SwitchDasProArgs args, CustomResourceOptions? opts = null)
public SwitchDasPro(String name, SwitchDasProArgs args)
public SwitchDasPro(String name, SwitchDasProArgs args, CustomResourceOptions options)
type: alicloud:das:SwitchDasPro
properties: # The arguments to resource properties.
options: # Bag of options to control resource's behavior.

Parameters

name This property is required. string
The unique name of the resource.
args This property is required. SwitchDasProArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
resource_name This property is required. str
The unique name of the resource.
args This property is required. SwitchDasProArgs
The arguments to resource properties.
opts ResourceOptions
Bag of options to control resource's behavior.
ctx Context
Context object for the current deployment.
name This property is required. string
The unique name of the resource.
args This property is required. SwitchDasProArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name This property is required. string
The unique name of the resource.
args This property is required. SwitchDasProArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.
name This property is required. String
The unique name of the resource.
args This property is required. SwitchDasProArgs
The arguments to resource properties.
options CustomResourceOptions
Bag of options to control resource's behavior.

Constructor example

The following reference example uses placeholder values for all input properties.

var switchDasProResource = new AliCloud.Das.SwitchDasPro("switchDasProResource", new()
{
    InstanceId = "string",
    SqlRetention = 0,
    UserId = "string",
});
Copy
example, err := das.NewSwitchDasPro(ctx, "switchDasProResource", &das.SwitchDasProArgs{
	InstanceId:   pulumi.String("string"),
	SqlRetention: pulumi.Int(0),
	UserId:       pulumi.String("string"),
})
Copy
var switchDasProResource = new SwitchDasPro("switchDasProResource", SwitchDasProArgs.builder()
    .instanceId("string")
    .sqlRetention(0)
    .userId("string")
    .build());
Copy
switch_das_pro_resource = alicloud.das.SwitchDasPro("switchDasProResource",
    instance_id="string",
    sql_retention=0,
    user_id="string")
Copy
const switchDasProResource = new alicloud.das.SwitchDasPro("switchDasProResource", {
    instanceId: "string",
    sqlRetention: 0,
    userId: "string",
});
Copy
type: alicloud:das:SwitchDasPro
properties:
    instanceId: string
    sqlRetention: 0
    userId: string
Copy

SwitchDasPro Resource Properties

To learn more about resource properties and how to use them, see Inputs and Outputs in the Architecture and Concepts docs.

Inputs

In Python, inputs that are objects can be passed either as argument classes or as dictionary literals.

The SwitchDasPro resource accepts the following input properties:

InstanceId
This property is required.
Changes to this property will trigger replacement.
string
The ID of the database instance.
SqlRetention Changes to this property will trigger replacement. int
The storage duration of SQL Explorer data. Valid values: 30, 180, 365, 1095, 1825. Unit: days. Default value: 30.
UserId Changes to this property will trigger replacement. string
The ID of the Alibaba Cloud account that is used to create the database instance.
InstanceId
This property is required.
Changes to this property will trigger replacement.
string
The ID of the database instance.
SqlRetention Changes to this property will trigger replacement. int
The storage duration of SQL Explorer data. Valid values: 30, 180, 365, 1095, 1825. Unit: days. Default value: 30.
UserId Changes to this property will trigger replacement. string
The ID of the Alibaba Cloud account that is used to create the database instance.
instanceId
This property is required.
Changes to this property will trigger replacement.
String
The ID of the database instance.
sqlRetention Changes to this property will trigger replacement. Integer
The storage duration of SQL Explorer data. Valid values: 30, 180, 365, 1095, 1825. Unit: days. Default value: 30.
userId Changes to this property will trigger replacement. String
The ID of the Alibaba Cloud account that is used to create the database instance.
instanceId
This property is required.
Changes to this property will trigger replacement.
string
The ID of the database instance.
sqlRetention Changes to this property will trigger replacement. number
The storage duration of SQL Explorer data. Valid values: 30, 180, 365, 1095, 1825. Unit: days. Default value: 30.
userId Changes to this property will trigger replacement. string
The ID of the Alibaba Cloud account that is used to create the database instance.
instance_id
This property is required.
Changes to this property will trigger replacement.
str
The ID of the database instance.
sql_retention Changes to this property will trigger replacement. int
The storage duration of SQL Explorer data. Valid values: 30, 180, 365, 1095, 1825. Unit: days. Default value: 30.
user_id Changes to this property will trigger replacement. str
The ID of the Alibaba Cloud account that is used to create the database instance.
instanceId
This property is required.
Changes to this property will trigger replacement.
String
The ID of the database instance.
sqlRetention Changes to this property will trigger replacement. Number
The storage duration of SQL Explorer data. Valid values: 30, 180, 365, 1095, 1825. Unit: days. Default value: 30.
userId Changes to this property will trigger replacement. String
The ID of the Alibaba Cloud account that is used to create the database instance.

Outputs

All input properties are implicitly available as output properties. Additionally, the SwitchDasPro resource produces the following output properties:

Id string
The provider-assigned unique ID for this managed resource.
Status bool
Whether the database instance has DAS professional.
Id string
The provider-assigned unique ID for this managed resource.
Status bool
Whether the database instance has DAS professional.
id String
The provider-assigned unique ID for this managed resource.
status Boolean
Whether the database instance has DAS professional.
id string
The provider-assigned unique ID for this managed resource.
status boolean
Whether the database instance has DAS professional.
id str
The provider-assigned unique ID for this managed resource.
status bool
Whether the database instance has DAS professional.
id String
The provider-assigned unique ID for this managed resource.
status Boolean
Whether the database instance has DAS professional.

Look up Existing SwitchDasPro Resource

Get an existing SwitchDasPro resource’s state with the given name, ID, and optional extra properties used to qualify the lookup.

public static get(name: string, id: Input<ID>, state?: SwitchDasProState, opts?: CustomResourceOptions): SwitchDasPro
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        instance_id: Optional[str] = None,
        sql_retention: Optional[int] = None,
        status: Optional[bool] = None,
        user_id: Optional[str] = None) -> SwitchDasPro
func GetSwitchDasPro(ctx *Context, name string, id IDInput, state *SwitchDasProState, opts ...ResourceOption) (*SwitchDasPro, error)
public static SwitchDasPro Get(string name, Input<string> id, SwitchDasProState? state, CustomResourceOptions? opts = null)
public static SwitchDasPro get(String name, Output<String> id, SwitchDasProState state, CustomResourceOptions options)
resources:  _:    type: alicloud:das:SwitchDasPro    get:      id: ${id}
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
resource_name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
name This property is required.
The unique name of the resulting resource.
id This property is required.
The unique provider ID of the resource to lookup.
state
Any extra arguments used during the lookup.
opts
A bag of options that control this resource's behavior.
The following state arguments are supported:
InstanceId Changes to this property will trigger replacement. string
The ID of the database instance.
SqlRetention Changes to this property will trigger replacement. int
The storage duration of SQL Explorer data. Valid values: 30, 180, 365, 1095, 1825. Unit: days. Default value: 30.
Status bool
Whether the database instance has DAS professional.
UserId Changes to this property will trigger replacement. string
The ID of the Alibaba Cloud account that is used to create the database instance.
InstanceId Changes to this property will trigger replacement. string
The ID of the database instance.
SqlRetention Changes to this property will trigger replacement. int
The storage duration of SQL Explorer data. Valid values: 30, 180, 365, 1095, 1825. Unit: days. Default value: 30.
Status bool
Whether the database instance has DAS professional.
UserId Changes to this property will trigger replacement. string
The ID of the Alibaba Cloud account that is used to create the database instance.
instanceId Changes to this property will trigger replacement. String
The ID of the database instance.
sqlRetention Changes to this property will trigger replacement. Integer
The storage duration of SQL Explorer data. Valid values: 30, 180, 365, 1095, 1825. Unit: days. Default value: 30.
status Boolean
Whether the database instance has DAS professional.
userId Changes to this property will trigger replacement. String
The ID of the Alibaba Cloud account that is used to create the database instance.
instanceId Changes to this property will trigger replacement. string
The ID of the database instance.
sqlRetention Changes to this property will trigger replacement. number
The storage duration of SQL Explorer data. Valid values: 30, 180, 365, 1095, 1825. Unit: days. Default value: 30.
status boolean
Whether the database instance has DAS professional.
userId Changes to this property will trigger replacement. string
The ID of the Alibaba Cloud account that is used to create the database instance.
instance_id Changes to this property will trigger replacement. str
The ID of the database instance.
sql_retention Changes to this property will trigger replacement. int
The storage duration of SQL Explorer data. Valid values: 30, 180, 365, 1095, 1825. Unit: days. Default value: 30.
status bool
Whether the database instance has DAS professional.
user_id Changes to this property will trigger replacement. str
The ID of the Alibaba Cloud account that is used to create the database instance.
instanceId Changes to this property will trigger replacement. String
The ID of the database instance.
sqlRetention Changes to this property will trigger replacement. Number
The storage duration of SQL Explorer data. Valid values: 30, 180, 365, 1095, 1825. Unit: days. Default value: 30.
status Boolean
Whether the database instance has DAS professional.
userId Changes to this property will trigger replacement. String
The ID of the Alibaba Cloud account that is used to create the database instance.

Import

DAS Switch Das Pro can be imported using the id, e.g.

$ pulumi import alicloud:das/switchDasPro:SwitchDasPro example <id>
Copy

To learn more about importing existing cloud resources, see Importing resources.

Package Details

Repository
Alibaba Cloud pulumi/pulumi-alicloud
License
Apache-2.0
Notes
This Pulumi package is based on the alicloud Terraform Provider.