Welcome to Pulumi Registry, your window into the cloud. Read the announcement.

Alibaba Cloud

v3.8.0 published on Monday, Oct 4, 2021 by Pulumi

Connection

Provides a connection resource to allocate an Internet connection string for instance.

NOTE: Available in 1.48.0+

NOTE: Each instance will allocate a intranet connection string automatically and its prefix is instance ID. To avoid unnecessary conflict, please specified a internet connection prefix before applying the resource.

Example Usage

using Pulumi;
using AliCloud = Pulumi.AliCloud;

class MyStack : Stack
{
    public MyStack()
    {
        var config = new Config();
        var creation = config.Get("creation") ?? "Gpdb";
        var name = config.Get("name") ?? "gpdbConnectionBasic";
        var defaultZones = Output.Create(AliCloud.GetZones.InvokeAsync(new AliCloud.GetZonesArgs
        {
            AvailableResourceCreation = creation,
        }));
        var defaultNetwork = new AliCloud.Vpc.Network("defaultNetwork", new AliCloud.Vpc.NetworkArgs
        {
            CidrBlock = "172.16.0.0/16",
        });
        var defaultSwitch = new AliCloud.Vpc.Switch("defaultSwitch", new AliCloud.Vpc.SwitchArgs
        {
            VpcId = defaultNetwork.Id,
            CidrBlock = "172.16.0.0/24",
            ZoneId = defaultZones.Apply(defaultZones => defaultZones.Zones[0].Id),
        });
        var defaultInstance = new AliCloud.Gpdb.Instance("defaultInstance", new AliCloud.Gpdb.InstanceArgs
        {
            VswitchId = defaultSwitch.Id,
            Engine = "gpdb",
            EngineVersion = "4.3",
            InstanceClass = "gpdb.group.segsdx2",
            InstanceGroupCount = "2",
            Description = name,
        });
        var defaultConnection = new AliCloud.Gpdb.Connection("defaultConnection", new AliCloud.Gpdb.ConnectionArgs
        {
            InstanceId = defaultInstance.Id,
            ConnectionPrefix = "testAbc",
        });
    }

}
package main

import (
	"github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud"
	"github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud/gpdb"
	"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, "")
		creation := "Gpdb"
		if param := cfg.Get("creation"); param != "" {
			creation = param
		}
		name := "gpdbConnectionBasic"
		if param := cfg.Get("name"); param != "" {
			name = param
		}
		opt0 := creation
		defaultZones, err := alicloud.GetZones(ctx, &alicloud.GetZonesArgs{
			AvailableResourceCreation: &opt0,
		}, nil)
		if err != nil {
			return err
		}
		defaultNetwork, err := vpc.NewNetwork(ctx, "defaultNetwork", &vpc.NetworkArgs{
			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(defaultZones.Zones[0].Id),
		})
		if err != nil {
			return err
		}
		defaultInstance, err := gpdb.NewInstance(ctx, "defaultInstance", &gpdb.InstanceArgs{
			VswitchId:          defaultSwitch.ID(),
			Engine:             pulumi.String("gpdb"),
			EngineVersion:      pulumi.String("4.3"),
			InstanceClass:      pulumi.String("gpdb.group.segsdx2"),
			InstanceGroupCount: pulumi.String("2"),
			Description:        pulumi.String(name),
		})
		if err != nil {
			return err
		}
		_, err = gpdb.NewConnection(ctx, "defaultConnection", &gpdb.ConnectionArgs{
			InstanceId:       defaultInstance.ID(),
			ConnectionPrefix: pulumi.String("testAbc"),
		})
		if err != nil {
			return err
		}
		return nil
	})
}
import pulumi
import pulumi_alicloud as alicloud

config = pulumi.Config()
creation = config.get("creation")
if creation is None:
    creation = "Gpdb"
name = config.get("name")
if name is None:
    name = "gpdbConnectionBasic"
default_zones = alicloud.get_zones(available_resource_creation=creation)
default_network = alicloud.vpc.Network("defaultNetwork", 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_zones.zones[0].id)
default_instance = alicloud.gpdb.Instance("defaultInstance",
    vswitch_id=default_switch.id,
    engine="gpdb",
    engine_version="4.3",
    instance_class="gpdb.group.segsdx2",
    instance_group_count="2",
    description=name)
default_connection = alicloud.gpdb.Connection("defaultConnection",
    instance_id=default_instance.id,
    connection_prefix="testAbc")
import * as pulumi from "@pulumi/pulumi";
import * as alicloud from "@pulumi/alicloud";

const config = new pulumi.Config();
const creation = config.get("creation") || "Gpdb";
const name = config.get("name") || "gpdbConnectionBasic";
const defaultZones = alicloud.getZones({
    availableResourceCreation: creation,
});
const defaultNetwork = new alicloud.vpc.Network("defaultNetwork", {cidrBlock: "172.16.0.0/16"});
const defaultSwitch = new alicloud.vpc.Switch("defaultSwitch", {
    vpcId: defaultNetwork.id,
    cidrBlock: "172.16.0.0/24",
    zoneId: defaultZones.then(defaultZones => defaultZones.zones[0].id),
});
const defaultInstance = new alicloud.gpdb.Instance("defaultInstance", {
    vswitchId: defaultSwitch.id,
    engine: "gpdb",
    engineVersion: "4.3",
    instanceClass: "gpdb.group.segsdx2",
    instanceGroupCount: "2",
    description: name,
});
const defaultConnection = new alicloud.gpdb.Connection("defaultConnection", {
    instanceId: defaultInstance.id,
    connectionPrefix: "testAbc",
});

Create a Connection Resource

new Connection(name: string, args: ConnectionArgs, opts?: CustomResourceOptions);
@overload
def Connection(resource_name: str,
               opts: Optional[ResourceOptions] = None,
               connection_prefix: Optional[str] = None,
               instance_id: Optional[str] = None,
               port: Optional[str] = None)
@overload
def Connection(resource_name: str,
               args: ConnectionArgs,
               opts: Optional[ResourceOptions] = None)
func NewConnection(ctx *Context, name string, args ConnectionArgs, opts ...ResourceOption) (*Connection, error)
public Connection(string name, ConnectionArgs args, CustomResourceOptions? opts = null)
name string
The unique name of the resource.
args ConnectionArgs
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 ConnectionArgs
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 ConnectionArgs
The arguments to resource properties.
opts ResourceOption
Bag of options to control resource's behavior.
name string
The unique name of the resource.
args ConnectionArgs
The arguments to resource properties.
opts CustomResourceOptions
Bag of options to control resource's behavior.

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

InstanceId string
The Id of instance that can run database.
ConnectionPrefix string
Prefix of an Internet connection string. It must be checked for uniqueness. It may consist of lowercase letters, numbers, and underlines, and must start with a letter and have no more than 30 characters. Default to <instance_id> + ‘-tf’.
Port string
Internet connection port. Valid value: [3200-3999]. Default to 3306.
InstanceId string
The Id of instance that can run database.
ConnectionPrefix string
Prefix of an Internet connection string. It must be checked for uniqueness. It may consist of lowercase letters, numbers, and underlines, and must start with a letter and have no more than 30 characters. Default to <instance_id> + ‘-tf’.
Port string
Internet connection port. Valid value: [3200-3999]. Default to 3306.
instanceId string
The Id of instance that can run database.
connectionPrefix string
Prefix of an Internet connection string. It must be checked for uniqueness. It may consist of lowercase letters, numbers, and underlines, and must start with a letter and have no more than 30 characters. Default to <instance_id> + ‘-tf’.
port string
Internet connection port. Valid value: [3200-3999]. Default to 3306.
instance_id str
The Id of instance that can run database.
connection_prefix str
Prefix of an Internet connection string. It must be checked for uniqueness. It may consist of lowercase letters, numbers, and underlines, and must start with a letter and have no more than 30 characters. Default to <instance_id> + ‘-tf’.
port str
Internet connection port. Valid value: [3200-3999]. Default to 3306.

Outputs

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

ConnectionString string
Connection instance string.
Id string
The provider-assigned unique ID for this managed resource.
IpAddress string
The ip address of connection string.
ConnectionString string
Connection instance string.
Id string
The provider-assigned unique ID for this managed resource.
IpAddress string
The ip address of connection string.
connectionString string
Connection instance string.
id string
The provider-assigned unique ID for this managed resource.
ipAddress string
The ip address of connection string.
connection_string str
Connection instance string.
id str
The provider-assigned unique ID for this managed resource.
ip_address str
The ip address of connection string.

Look up an Existing Connection Resource

Get an existing Connection 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?: ConnectionState, opts?: CustomResourceOptions): Connection
@staticmethod
def get(resource_name: str,
        id: str,
        opts: Optional[ResourceOptions] = None,
        connection_prefix: Optional[str] = None,
        connection_string: Optional[str] = None,
        instance_id: Optional[str] = None,
        ip_address: Optional[str] = None,
        port: Optional[str] = None) -> Connection
func GetConnection(ctx *Context, name string, id IDInput, state *ConnectionState, opts ...ResourceOption) (*Connection, error)
public static Connection Get(string name, Input<string> id, ConnectionState? state, CustomResourceOptions? opts = null)
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.

The following state arguments are supported:

ConnectionPrefix string
Prefix of an Internet connection string. It must be checked for uniqueness. It may consist of lowercase letters, numbers, and underlines, and must start with a letter and have no more than 30 characters. Default to <instance_id> + ‘-tf’.
ConnectionString string
Connection instance string.
InstanceId string
The Id of instance that can run database.
IpAddress string
The ip address of connection string.
Port string
Internet connection port. Valid value: [3200-3999]. Default to 3306.
ConnectionPrefix string
Prefix of an Internet connection string. It must be checked for uniqueness. It may consist of lowercase letters, numbers, and underlines, and must start with a letter and have no more than 30 characters. Default to <instance_id> + ‘-tf’.
ConnectionString string
Connection instance string.
InstanceId string
The Id of instance that can run database.
IpAddress string
The ip address of connection string.
Port string
Internet connection port. Valid value: [3200-3999]. Default to 3306.
connectionPrefix string
Prefix of an Internet connection string. It must be checked for uniqueness. It may consist of lowercase letters, numbers, and underlines, and must start with a letter and have no more than 30 characters. Default to <instance_id> + ‘-tf’.
connectionString string
Connection instance string.
instanceId string
The Id of instance that can run database.
ipAddress string
The ip address of connection string.
port string
Internet connection port. Valid value: [3200-3999]. Default to 3306.
connection_prefix str
Prefix of an Internet connection string. It must be checked for uniqueness. It may consist of lowercase letters, numbers, and underlines, and must start with a letter and have no more than 30 characters. Default to <instance_id> + ‘-tf’.
connection_string str
Connection instance string.
instance_id str
The Id of instance that can run database.
ip_address str
The ip address of connection string.
port str
Internet connection port. Valid value: [3200-3999]. Default to 3306.

Import

AnalyticDB for PostgreSQL’s connection can be imported using the id, e.g.

 $ pulumi import alicloud:gpdb/connection:Connection example abc12345678

Package Details

Repository
https://github.com/pulumi/pulumi-alicloud
License
Apache-2.0
Notes
This Pulumi package is based on the alicloud Terraform Provider.