1. Packages
  2. Alibaba Cloud
  3. API Docs
  4. polardb
  5. GlobalDatabaseNetwork
Alibaba Cloud v3.54.0 published on Wednesday, Apr 24, 2024 by Pulumi

alicloud.polardb.GlobalDatabaseNetwork

Explore with Pulumi AI

alicloud logo
Alibaba Cloud v3.54.0 published on Wednesday, Apr 24, 2024 by Pulumi

    Provides a PolarDB Global Database Network resource.

    For information about PolarDB Global Database Network and how to use it, see What is Global Database Network.

    NOTE: Available since v1.181.0+.

    Example Usage

    Basic Usage

    import * as pulumi from "@pulumi/pulumi";
    import * as alicloud from "@pulumi/alicloud";
    
    const default = alicloud.polardb.getNodeClasses({
        dbType: "MySQL",
        dbVersion: "8.0",
        category: "Normal",
        payType: "PostPaid",
    });
    const defaultNetwork = new alicloud.vpc.Network("default", {
        vpcName: "terraform-example",
        cidrBlock: "172.16.0.0/16",
    });
    const defaultSwitch = new alicloud.vpc.Switch("default", {
        vpcId: defaultNetwork.id,
        cidrBlock: "172.16.0.0/24",
        zoneId: _default.then(_default => _default.classes?.[0]?.zoneId),
        vswitchName: "terraform-example",
    });
    const defaultCluster = new alicloud.polardb.Cluster("default", {
        dbType: "MySQL",
        dbVersion: "8.0",
        dbNodeClass: _default.then(_default => _default.classes?.[0]?.supportedEngines?.[0]?.availableResources?.[0]?.dbNodeClass),
        payType: "PostPaid",
        vswitchId: defaultSwitch.id,
        description: "terraform-example",
    });
    const defaultGlobalDatabaseNetwork = new alicloud.polardb.GlobalDatabaseNetwork("default", {
        dbClusterId: defaultCluster.id,
        description: "terraform-example",
    });
    
    import pulumi
    import pulumi_alicloud as alicloud
    
    default = alicloud.polardb.get_node_classes(db_type="MySQL",
        db_version="8.0",
        category="Normal",
        pay_type="PostPaid")
    default_network = alicloud.vpc.Network("default",
        vpc_name="terraform-example",
        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.classes[0].zone_id,
        vswitch_name="terraform-example")
    default_cluster = alicloud.polardb.Cluster("default",
        db_type="MySQL",
        db_version="8.0",
        db_node_class=default.classes[0].supported_engines[0].available_resources[0].db_node_class,
        pay_type="PostPaid",
        vswitch_id=default_switch.id,
        description="terraform-example")
    default_global_database_network = alicloud.polardb.GlobalDatabaseNetwork("default",
        db_cluster_id=default_cluster.id,
        description="terraform-example")
    
    package main
    
    import (
    	"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"
    )
    
    func main() {
    	pulumi.Run(func(ctx *pulumi.Context) error {
    		_default, err := polardb.GetNodeClasses(ctx, &polardb.GetNodeClassesArgs{
    			DbType:    pulumi.StringRef("MySQL"),
    			DbVersion: pulumi.StringRef("8.0"),
    			Category:  pulumi.StringRef("Normal"),
    			PayType:   "PostPaid",
    		}, nil)
    		if err != nil {
    			return err
    		}
    		defaultNetwork, err := vpc.NewNetwork(ctx, "default", &vpc.NetworkArgs{
    			VpcName:   pulumi.String("terraform-example"),
    			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(_default.Classes[0].ZoneId),
    			VswitchName: pulumi.String("terraform-example"),
    		})
    		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(_default.Classes[0].SupportedEngines[0].AvailableResources[0].DbNodeClass),
    			PayType:     pulumi.String("PostPaid"),
    			VswitchId:   defaultSwitch.ID(),
    			Description: pulumi.String("terraform-example"),
    		})
    		if err != nil {
    			return err
    		}
    		_, err = polardb.NewGlobalDatabaseNetwork(ctx, "default", &polardb.GlobalDatabaseNetworkArgs{
    			DbClusterId: defaultCluster.ID(),
    			Description: pulumi.String("terraform-example"),
    		})
    		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 @default = AliCloud.PolarDB.GetNodeClasses.Invoke(new()
        {
            DbType = "MySQL",
            DbVersion = "8.0",
            Category = "Normal",
            PayType = "PostPaid",
        });
    
        var defaultNetwork = new AliCloud.Vpc.Network("default", new()
        {
            VpcName = "terraform-example",
            CidrBlock = "172.16.0.0/16",
        });
    
        var defaultSwitch = new AliCloud.Vpc.Switch("default", new()
        {
            VpcId = defaultNetwork.Id,
            CidrBlock = "172.16.0.0/24",
            ZoneId = @default.Apply(@default => @default.Apply(getNodeClassesResult => getNodeClassesResult.Classes[0]?.ZoneId)),
            VswitchName = "terraform-example",
        });
    
        var defaultCluster = new AliCloud.PolarDB.Cluster("default", new()
        {
            DbType = "MySQL",
            DbVersion = "8.0",
            DbNodeClass = @default.Apply(@default => @default.Apply(getNodeClassesResult => getNodeClassesResult.Classes[0]?.SupportedEngines[0]?.AvailableResources[0]?.DbNodeClass)),
            PayType = "PostPaid",
            VswitchId = defaultSwitch.Id,
            Description = "terraform-example",
        });
    
        var defaultGlobalDatabaseNetwork = new AliCloud.PolarDB.GlobalDatabaseNetwork("default", new()
        {
            DbClusterId = defaultCluster.Id,
            Description = "terraform-example",
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    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.GlobalDatabaseNetwork;
    import com.pulumi.alicloud.polardb.GlobalDatabaseNetworkArgs;
    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 default = PolardbFunctions.getNodeClasses(GetNodeClassesArgs.builder()
                .dbType("MySQL")
                .dbVersion("8.0")
                .category("Normal")
                .payType("PostPaid")
                .build());
    
            var defaultNetwork = new Network("defaultNetwork", NetworkArgs.builder()        
                .vpcName("terraform-example")
                .cidrBlock("172.16.0.0/16")
                .build());
    
            var defaultSwitch = new Switch("defaultSwitch", SwitchArgs.builder()        
                .vpcId(defaultNetwork.id())
                .cidrBlock("172.16.0.0/24")
                .zoneId(default_.classes()[0].zoneId())
                .vswitchName("terraform-example")
                .build());
    
            var defaultCluster = new Cluster("defaultCluster", ClusterArgs.builder()        
                .dbType("MySQL")
                .dbVersion("8.0")
                .dbNodeClass(default_.classes()[0].supportedEngines()[0].availableResources()[0].dbNodeClass())
                .payType("PostPaid")
                .vswitchId(defaultSwitch.id())
                .description("terraform-example")
                .build());
    
            var defaultGlobalDatabaseNetwork = new GlobalDatabaseNetwork("defaultGlobalDatabaseNetwork", GlobalDatabaseNetworkArgs.builder()        
                .dbClusterId(defaultCluster.id())
                .description("terraform-example")
                .build());
    
        }
    }
    
    resources:
      defaultNetwork:
        type: alicloud:vpc:Network
        name: default
        properties:
          vpcName: terraform-example
          cidrBlock: 172.16.0.0/16
      defaultSwitch:
        type: alicloud:vpc:Switch
        name: default
        properties:
          vpcId: ${defaultNetwork.id}
          cidrBlock: 172.16.0.0/24
          zoneId: ${default.classes[0].zoneId}
          vswitchName: terraform-example
      defaultCluster:
        type: alicloud:polardb:Cluster
        name: default
        properties:
          dbType: MySQL
          dbVersion: '8.0'
          dbNodeClass: ${default.classes[0].supportedEngines[0].availableResources[0].dbNodeClass}
          payType: PostPaid
          vswitchId: ${defaultSwitch.id}
          description: terraform-example
      defaultGlobalDatabaseNetwork:
        type: alicloud:polardb:GlobalDatabaseNetwork
        name: default
        properties:
          dbClusterId: ${defaultCluster.id}
          description: terraform-example
    variables:
      default:
        fn::invoke:
          Function: alicloud:polardb:getNodeClasses
          Arguments:
            dbType: MySQL
            dbVersion: '8.0'
            category: Normal
            payType: PostPaid
    

    Create GlobalDatabaseNetwork Resource

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

    Constructor syntax

    new GlobalDatabaseNetwork(name: string, args: GlobalDatabaseNetworkArgs, opts?: CustomResourceOptions);
    @overload
    def GlobalDatabaseNetwork(resource_name: str,
                              args: GlobalDatabaseNetworkArgs,
                              opts: Optional[ResourceOptions] = None)
    
    @overload
    def GlobalDatabaseNetwork(resource_name: str,
                              opts: Optional[ResourceOptions] = None,
                              db_cluster_id: Optional[str] = None,
                              description: Optional[str] = None)
    func NewGlobalDatabaseNetwork(ctx *Context, name string, args GlobalDatabaseNetworkArgs, opts ...ResourceOption) (*GlobalDatabaseNetwork, error)
    public GlobalDatabaseNetwork(string name, GlobalDatabaseNetworkArgs args, CustomResourceOptions? opts = null)
    public GlobalDatabaseNetwork(String name, GlobalDatabaseNetworkArgs args)
    public GlobalDatabaseNetwork(String name, GlobalDatabaseNetworkArgs args, CustomResourceOptions options)
    
    type: alicloud:polardb:GlobalDatabaseNetwork
    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 GlobalDatabaseNetworkArgs
    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 GlobalDatabaseNetworkArgs
    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 GlobalDatabaseNetworkArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args GlobalDatabaseNetworkArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args GlobalDatabaseNetworkArgs
    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 globalDatabaseNetworkResource = new AliCloud.PolarDB.GlobalDatabaseNetwork("globalDatabaseNetworkResource", new()
    {
        DbClusterId = "string",
        Description = "string",
    });
    
    example, err := polardb.NewGlobalDatabaseNetwork(ctx, "globalDatabaseNetworkResource", &polardb.GlobalDatabaseNetworkArgs{
    	DbClusterId: pulumi.String("string"),
    	Description: pulumi.String("string"),
    })
    
    var globalDatabaseNetworkResource = new GlobalDatabaseNetwork("globalDatabaseNetworkResource", GlobalDatabaseNetworkArgs.builder()        
        .dbClusterId("string")
        .description("string")
        .build());
    
    global_database_network_resource = alicloud.polardb.GlobalDatabaseNetwork("globalDatabaseNetworkResource",
        db_cluster_id="string",
        description="string")
    
    const globalDatabaseNetworkResource = new alicloud.polardb.GlobalDatabaseNetwork("globalDatabaseNetworkResource", {
        dbClusterId: "string",
        description: "string",
    });
    
    type: alicloud:polardb:GlobalDatabaseNetwork
    properties:
        dbClusterId: string
        description: string
    

    GlobalDatabaseNetwork 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 GlobalDatabaseNetwork resource accepts the following input properties:

    DbClusterId string
    The ID of the primary cluster.
    Description string
    The description of the Global Database Network.
    DbClusterId string
    The ID of the primary cluster.
    Description string
    The description of the Global Database Network.
    dbClusterId String
    The ID of the primary cluster.
    description String
    The description of the Global Database Network.
    dbClusterId string
    The ID of the primary cluster.
    description string
    The description of the Global Database Network.
    db_cluster_id str
    The ID of the primary cluster.
    description str
    The description of the Global Database Network.
    dbClusterId String
    The ID of the primary cluster.
    description String
    The description of the Global Database Network.

    Outputs

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

    Id string
    The provider-assigned unique ID for this managed resource.
    Status string
    The status of the Global Database Network.
    Id string
    The provider-assigned unique ID for this managed resource.
    Status string
    The status of the Global Database Network.
    id String
    The provider-assigned unique ID for this managed resource.
    status String
    The status of the Global Database Network.
    id string
    The provider-assigned unique ID for this managed resource.
    status string
    The status of the Global Database Network.
    id str
    The provider-assigned unique ID for this managed resource.
    status str
    The status of the Global Database Network.
    id String
    The provider-assigned unique ID for this managed resource.
    status String
    The status of the Global Database Network.

    Look up Existing GlobalDatabaseNetwork Resource

    Get an existing GlobalDatabaseNetwork 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?: GlobalDatabaseNetworkState, opts?: CustomResourceOptions): GlobalDatabaseNetwork
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            db_cluster_id: Optional[str] = None,
            description: Optional[str] = None,
            status: Optional[str] = None) -> GlobalDatabaseNetwork
    func GetGlobalDatabaseNetwork(ctx *Context, name string, id IDInput, state *GlobalDatabaseNetworkState, opts ...ResourceOption) (*GlobalDatabaseNetwork, error)
    public static GlobalDatabaseNetwork Get(string name, Input<string> id, GlobalDatabaseNetworkState? state, CustomResourceOptions? opts = null)
    public static GlobalDatabaseNetwork get(String name, Output<String> id, GlobalDatabaseNetworkState 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:
    DbClusterId string
    The ID of the primary cluster.
    Description string
    The description of the Global Database Network.
    Status string
    The status of the Global Database Network.
    DbClusterId string
    The ID of the primary cluster.
    Description string
    The description of the Global Database Network.
    Status string
    The status of the Global Database Network.
    dbClusterId String
    The ID of the primary cluster.
    description String
    The description of the Global Database Network.
    status String
    The status of the Global Database Network.
    dbClusterId string
    The ID of the primary cluster.
    description string
    The description of the Global Database Network.
    status string
    The status of the Global Database Network.
    db_cluster_id str
    The ID of the primary cluster.
    description str
    The description of the Global Database Network.
    status str
    The status of the Global Database Network.
    dbClusterId String
    The ID of the primary cluster.
    description String
    The description of the Global Database Network.
    status String
    The status of the Global Database Network.

    Import

    PolarDB Global Database Network can be imported using the id, e.g.

    $ pulumi import alicloud:polardb/globalDatabaseNetwork:GlobalDatabaseNetwork 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.54.0 published on Wednesday, Apr 24, 2024 by Pulumi