1. Packages
  2. Alibaba Cloud
  3. API Docs
  4. das
  5. SwitchDasPro
Alibaba Cloud v3.52.1 published on Thursday, Apr 4, 2024 by Pulumi

alicloud.das.SwitchDasPro

Explore with Pulumi AI

alicloud logo
Alibaba Cloud v3.52.1 published on Thursday, Apr 4, 2024 by Pulumi

    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 defaultAccount = alicloud.getAccount({});
    const defaultNodeClasses = alicloud.polardb.getNodeClasses({
        dbType: "MySQL",
        dbVersion: "8.0",
        payType: "PostPaid",
    });
    const defaultNetwork = new alicloud.vpc.Network("defaultNetwork", {
        vpcName: name,
        cidrBlock: "172.16.0.0/16",
    });
    const defaultSwitch = new alicloud.vpc.Switch("defaultSwitch", {
        vpcId: defaultNetwork.id,
        cidrBlock: "172.16.0.0/24",
        zoneId: defaultNodeClasses.then(defaultNodeClasses => defaultNodeClasses.classes?.[0]?.zoneId),
        vswitchName: name,
    });
    const defaultCluster = new alicloud.polardb.Cluster("defaultCluster", {
        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("defaultSwitchDasPro", {
        instanceId: defaultCluster.id,
        sqlRetention: 30,
        userId: defaultAccount.then(defaultAccount => defaultAccount.id),
    });
    
    import pulumi
    import pulumi_alicloud as alicloud
    
    config = pulumi.Config()
    name = config.get("name")
    if name is None:
        name = "tfexample"
    default_account = alicloud.get_account()
    default_node_classes = alicloud.polardb.get_node_classes(db_type="MySQL",
        db_version="8.0",
        pay_type="PostPaid")
    default_network = alicloud.vpc.Network("defaultNetwork",
        vpc_name=name,
        cidr_block="172.16.0.0/16")
    default_switch = alicloud.vpc.Switch("defaultSwitch",
        vpc_id=default_network.id,
        cidr_block="172.16.0.0/24",
        zone_id=default_node_classes.classes[0].zone_id,
        vswitch_name=name)
    default_cluster = alicloud.polardb.Cluster("defaultCluster",
        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=[alicloud.polardb.ClusterDbClusterIpArrayArgs(
            db_cluster_ip_array_name="default",
            security_ips=[
                "1.2.3.4",
                "1.2.3.5",
            ],
        )])
    default_switch_das_pro = alicloud.das.SwitchDasPro("defaultSwitchDasPro",
        instance_id=default_cluster.id,
        sql_retention=30,
        user_id=default_account.id)
    
    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
    		}
    		defaultAccount, err := alicloud.GetAccount(ctx, nil, nil)
    		if err != nil {
    			return err
    		}
    		defaultNodeClasses, 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, "defaultNetwork", &vpc.NetworkArgs{
    			VpcName:   pulumi.String(name),
    			CidrBlock: pulumi.String("172.16.0.0/16"),
    		})
    		if err != nil {
    			return err
    		}
    		defaultSwitch, err := vpc.NewSwitch(ctx, "defaultSwitch", &vpc.SwitchArgs{
    			VpcId:       defaultNetwork.ID(),
    			CidrBlock:   pulumi.String("172.16.0.0/24"),
    			ZoneId:      pulumi.String(defaultNodeClasses.Classes[0].ZoneId),
    			VswitchName: pulumi.String(name),
    		})
    		if err != nil {
    			return err
    		}
    		defaultCluster, err := polardb.NewCluster(ctx, "defaultCluster", &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, "defaultSwitchDasPro", &das.SwitchDasProArgs{
    			InstanceId:   defaultCluster.ID(),
    			SqlRetention: pulumi.Int(30),
    			UserId:       pulumi.String(defaultAccount.Id),
    		})
    		if err != nil {
    			return err
    		}
    		return nil
    	})
    }
    
    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 defaultAccount = AliCloud.GetAccount.Invoke();
    
        var defaultNodeClasses = AliCloud.PolarDB.GetNodeClasses.Invoke(new()
        {
            DbType = "MySQL",
            DbVersion = "8.0",
            PayType = "PostPaid",
        });
    
        var defaultNetwork = new AliCloud.Vpc.Network("defaultNetwork", new()
        {
            VpcName = name,
            CidrBlock = "172.16.0.0/16",
        });
    
        var defaultSwitch = new AliCloud.Vpc.Switch("defaultSwitch", new()
        {
            VpcId = defaultNetwork.Id,
            CidrBlock = "172.16.0.0/24",
            ZoneId = defaultNodeClasses.Apply(getNodeClassesResult => getNodeClassesResult.Classes[0]?.ZoneId),
            VswitchName = name,
        });
    
        var defaultCluster = new AliCloud.PolarDB.Cluster("defaultCluster", 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("defaultSwitchDasPro", new()
        {
            InstanceId = defaultCluster.Id,
            SqlRetention = 30,
            UserId = defaultAccount.Apply(getAccountResult => getAccountResult.Id),
        });
    
    });
    
    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 defaultAccount = AlicloudFunctions.getAccount();
    
            final var defaultNodeClasses = 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(defaultNodeClasses.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(defaultAccount.applyValue(getAccountResult -> getAccountResult.id()))
                .build());
    
        }
    }
    
    configuration:
      name:
        type: string
        default: tfexample
    resources:
      defaultNetwork:
        type: alicloud:vpc:Network
        properties:
          vpcName: ${name}
          cidrBlock: 172.16.0.0/16
      defaultSwitch:
        type: alicloud:vpc:Switch
        properties:
          vpcId: ${defaultNetwork.id}
          cidrBlock: 172.16.0.0/24
          zoneId: ${defaultNodeClasses.classes[0].zoneId}
          vswitchName: ${name}
      defaultCluster:
        type: alicloud:polardb:Cluster
        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
        properties:
          instanceId: ${defaultCluster.id}
          sqlRetention: 30
          userId: ${defaultAccount.id}
    variables:
      defaultAccount:
        fn::invoke:
          Function: alicloud:getAccount
          Arguments: {}
      defaultNodeClasses:
        fn::invoke:
          Function: alicloud:polardb:getNodeClasses
          Arguments:
            dbType: MySQL
            dbVersion: '8.0'
            payType: PostPaid
    

    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 string
    The unique name of the resource.
    args SwitchDasProArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    resource_name str
    The unique name of the resource.
    args 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 string
    The unique name of the resource.
    args SwitchDasProArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args SwitchDasProArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args SwitchDasProArgs
    The arguments to resource properties.
    options CustomResourceOptions
    Bag of options to control resource's behavior.

    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",
    });
    
    example, err := das.NewSwitchDasPro(ctx, "switchDasProResource", &das.SwitchDasProArgs{
    	InstanceId:   pulumi.String("string"),
    	SqlRetention: pulumi.Int(0),
    	UserId:       pulumi.String("string"),
    })
    
    var switchDasProResource = new SwitchDasPro("switchDasProResource", SwitchDasProArgs.builder()        
        .instanceId("string")
        .sqlRetention(0)
        .userId("string")
        .build());
    
    switch_das_pro_resource = alicloud.das.SwitchDasPro("switchDasProResource",
        instance_id="string",
        sql_retention=0,
        user_id="string")
    
    const switchDasProResource = new alicloud.das.SwitchDasPro("switchDasProResource", {
        instanceId: "string",
        sqlRetention: 0,
        userId: "string",
    });
    
    type: alicloud:das:SwitchDasPro
    properties:
        instanceId: string
        sqlRetention: 0
        userId: string
    

    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

    The SwitchDasPro resource accepts the following input properties:

    InstanceId string
    The ID of the database instance.
    SqlRetention int
    The storage duration of SQL Explorer data. Valid values: 30, 180, 365, 1095, 1825. Unit: days. Default value: 30.
    UserId string
    The ID of the Alibaba Cloud account that is used to create the database instance.
    InstanceId string
    The ID of the database instance.
    SqlRetention int
    The storage duration of SQL Explorer data. Valid values: 30, 180, 365, 1095, 1825. Unit: days. Default value: 30.
    UserId string
    The ID of the Alibaba Cloud account that is used to create the database instance.
    instanceId String
    The ID of the database instance.
    sqlRetention Integer
    The storage duration of SQL Explorer data. Valid values: 30, 180, 365, 1095, 1825. Unit: days. Default value: 30.
    userId String
    The ID of the Alibaba Cloud account that is used to create the database instance.
    instanceId string
    The ID of the database instance.
    sqlRetention number
    The storage duration of SQL Explorer data. Valid values: 30, 180, 365, 1095, 1825. Unit: days. Default value: 30.
    userId string
    The ID of the Alibaba Cloud account that is used to create the database instance.
    instance_id str
    The ID of the database instance.
    sql_retention int
    The storage duration of SQL Explorer data. Valid values: 30, 180, 365, 1095, 1825. Unit: days. Default value: 30.
    user_id str
    The ID of the Alibaba Cloud account that is used to create the database instance.
    instanceId String
    The ID of the database instance.
    sqlRetention Number
    The storage duration of SQL Explorer data. Valid values: 30, 180, 365, 1095, 1825. Unit: days. Default value: 30.
    userId 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)
    Resource lookup is not supported in YAML
    name
    The unique name of the resulting resource.
    id
    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
    The unique name of the resulting resource.
    id
    The unique provider ID of the resource to lookup.
    name
    The unique name of the resulting resource.
    id
    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
    The unique name of the resulting resource.
    id
    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
    The unique name of the resulting resource.
    id
    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 string
    The ID of the database instance.
    SqlRetention 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 string
    The ID of the Alibaba Cloud account that is used to create the database instance.
    InstanceId string
    The ID of the database instance.
    SqlRetention 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 string
    The ID of the Alibaba Cloud account that is used to create the database instance.
    instanceId String
    The ID of the database instance.
    sqlRetention 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 String
    The ID of the Alibaba Cloud account that is used to create the database instance.
    instanceId string
    The ID of the database instance.
    sqlRetention 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 string
    The ID of the Alibaba Cloud account that is used to create the database instance.
    instance_id str
    The ID of the database instance.
    sql_retention 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 str
    The ID of the Alibaba Cloud account that is used to create the database instance.
    instanceId String
    The ID of the database instance.
    sqlRetention 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 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>
    

    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.
    alicloud logo
    Alibaba Cloud v3.52.1 published on Thursday, Apr 4, 2024 by Pulumi