alicloud.gpdb.Connection
Explore with Pulumi AI
Provides a connection resource to allocate an Internet connection string for instance.
NOTE: Available since v1.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 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") ?? "tf-example";
var defaultResourceGroups = AliCloud.ResourceManager.GetResourceGroups.Invoke();
var defaultZones = AliCloud.Gpdb.GetZones.Invoke();
var defaultNetwork = new AliCloud.Vpc.Network("defaultNetwork", new()
{
VpcName = name,
CidrBlock = "10.4.0.0/16",
});
var defaultSwitch = new AliCloud.Vpc.Switch("defaultSwitch", new()
{
VswitchName = name,
CidrBlock = "10.4.0.0/24",
VpcId = defaultNetwork.Id,
ZoneId = defaultZones.Apply(getZonesResult => getZonesResult.Ids[0]),
});
var defaultInstance = new AliCloud.Gpdb.Instance("defaultInstance", new()
{
DbInstanceCategory = "HighAvailability",
DbInstanceClass = "gpdb.group.segsdx1",
DbInstanceMode = "StorageElastic",
Description = name,
Engine = "gpdb",
EngineVersion = "6.0",
ZoneId = defaultZones.Apply(getZonesResult => getZonesResult.Ids[0]),
InstanceNetworkType = "VPC",
InstanceSpec = "2C16G",
MasterNodeNum = 1,
PaymentType = "PayAsYouGo",
PrivateIpAddress = "1.1.1.1",
SegStorageType = "cloud_essd",
SegNodeNum = 4,
StorageSize = 50,
VpcId = defaultNetwork.Id,
VswitchId = defaultSwitch.Id,
IpWhitelists = new[]
{
new AliCloud.Gpdb.Inputs.InstanceIpWhitelistArgs
{
SecurityIpList = "127.0.0.1",
},
},
});
var defaultConnection = new AliCloud.Gpdb.Connection("defaultConnection", new()
{
InstanceId = defaultInstance.Id,
ConnectionPrefix = "exampelcon",
});
});
package main
import (
"github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud/gpdb"
"github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud/resourcemanager"
"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 := "tf-example"
if param := cfg.Get("name"); param != "" {
name = param
}
_, err := resourcemanager.GetResourceGroups(ctx, nil, nil)
if err != nil {
return err
}
defaultZones, err := gpdb.GetZones(ctx, nil, nil)
if err != nil {
return err
}
defaultNetwork, err := vpc.NewNetwork(ctx, "defaultNetwork", &vpc.NetworkArgs{
VpcName: pulumi.String(name),
CidrBlock: pulumi.String("10.4.0.0/16"),
})
if err != nil {
return err
}
defaultSwitch, err := vpc.NewSwitch(ctx, "defaultSwitch", &vpc.SwitchArgs{
VswitchName: pulumi.String(name),
CidrBlock: pulumi.String("10.4.0.0/24"),
VpcId: defaultNetwork.ID(),
ZoneId: *pulumi.String(defaultZones.Ids[0]),
})
if err != nil {
return err
}
defaultInstance, err := gpdb.NewInstance(ctx, "defaultInstance", &gpdb.InstanceArgs{
DbInstanceCategory: pulumi.String("HighAvailability"),
DbInstanceClass: pulumi.String("gpdb.group.segsdx1"),
DbInstanceMode: pulumi.String("StorageElastic"),
Description: pulumi.String(name),
Engine: pulumi.String("gpdb"),
EngineVersion: pulumi.String("6.0"),
ZoneId: *pulumi.String(defaultZones.Ids[0]),
InstanceNetworkType: pulumi.String("VPC"),
InstanceSpec: pulumi.String("2C16G"),
MasterNodeNum: pulumi.Int(1),
PaymentType: pulumi.String("PayAsYouGo"),
PrivateIpAddress: pulumi.String("1.1.1.1"),
SegStorageType: pulumi.String("cloud_essd"),
SegNodeNum: pulumi.Int(4),
StorageSize: pulumi.Int(50),
VpcId: defaultNetwork.ID(),
VswitchId: defaultSwitch.ID(),
IpWhitelists: gpdb.InstanceIpWhitelistArray{
&gpdb.InstanceIpWhitelistArgs{
SecurityIpList: pulumi.String("127.0.0.1"),
},
},
})
if err != nil {
return err
}
_, err = gpdb.NewConnection(ctx, "defaultConnection", &gpdb.ConnectionArgs{
InstanceId: defaultInstance.ID(),
ConnectionPrefix: pulumi.String("exampelcon"),
})
if err != nil {
return err
}
return nil
})
}
package generated_program;
import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.alicloud.resourcemanager.ResourcemanagerFunctions;
import com.pulumi.alicloud.resourcemanager.inputs.GetResourceGroupsArgs;
import com.pulumi.alicloud.gpdb.GpdbFunctions;
import com.pulumi.alicloud.gpdb.inputs.GetZonesArgs;
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.gpdb.Instance;
import com.pulumi.alicloud.gpdb.InstanceArgs;
import com.pulumi.alicloud.gpdb.inputs.InstanceIpWhitelistArgs;
import com.pulumi.alicloud.gpdb.Connection;
import com.pulumi.alicloud.gpdb.ConnectionArgs;
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("tf-example");
final var defaultResourceGroups = ResourcemanagerFunctions.getResourceGroups();
final var defaultZones = GpdbFunctions.getZones();
var defaultNetwork = new Network("defaultNetwork", NetworkArgs.builder()
.vpcName(name)
.cidrBlock("10.4.0.0/16")
.build());
var defaultSwitch = new Switch("defaultSwitch", SwitchArgs.builder()
.vswitchName(name)
.cidrBlock("10.4.0.0/24")
.vpcId(defaultNetwork.id())
.zoneId(defaultZones.applyValue(getZonesResult -> getZonesResult.ids()[0]))
.build());
var defaultInstance = new Instance("defaultInstance", InstanceArgs.builder()
.dbInstanceCategory("HighAvailability")
.dbInstanceClass("gpdb.group.segsdx1")
.dbInstanceMode("StorageElastic")
.description(name)
.engine("gpdb")
.engineVersion("6.0")
.zoneId(defaultZones.applyValue(getZonesResult -> getZonesResult.ids()[0]))
.instanceNetworkType("VPC")
.instanceSpec("2C16G")
.masterNodeNum(1)
.paymentType("PayAsYouGo")
.privateIpAddress("1.1.1.1")
.segStorageType("cloud_essd")
.segNodeNum(4)
.storageSize(50)
.vpcId(defaultNetwork.id())
.vswitchId(defaultSwitch.id())
.ipWhitelists(InstanceIpWhitelistArgs.builder()
.securityIpList("127.0.0.1")
.build())
.build());
var defaultConnection = new Connection("defaultConnection", ConnectionArgs.builder()
.instanceId(defaultInstance.id())
.connectionPrefix("exampelcon")
.build());
}
}
import pulumi
import pulumi_alicloud as alicloud
config = pulumi.Config()
name = config.get("name")
if name is None:
name = "tf-example"
default_resource_groups = alicloud.resourcemanager.get_resource_groups()
default_zones = alicloud.gpdb.get_zones()
default_network = alicloud.vpc.Network("defaultNetwork",
vpc_name=name,
cidr_block="10.4.0.0/16")
default_switch = alicloud.vpc.Switch("defaultSwitch",
vswitch_name=name,
cidr_block="10.4.0.0/24",
vpc_id=default_network.id,
zone_id=default_zones.ids[0])
default_instance = alicloud.gpdb.Instance("defaultInstance",
db_instance_category="HighAvailability",
db_instance_class="gpdb.group.segsdx1",
db_instance_mode="StorageElastic",
description=name,
engine="gpdb",
engine_version="6.0",
zone_id=default_zones.ids[0],
instance_network_type="VPC",
instance_spec="2C16G",
master_node_num=1,
payment_type="PayAsYouGo",
private_ip_address="1.1.1.1",
seg_storage_type="cloud_essd",
seg_node_num=4,
storage_size=50,
vpc_id=default_network.id,
vswitch_id=default_switch.id,
ip_whitelists=[alicloud.gpdb.InstanceIpWhitelistArgs(
security_ip_list="127.0.0.1",
)])
default_connection = alicloud.gpdb.Connection("defaultConnection",
instance_id=default_instance.id,
connection_prefix="exampelcon")
import * as pulumi from "@pulumi/pulumi";
import * as alicloud from "@pulumi/alicloud";
const config = new pulumi.Config();
const name = config.get("name") || "tf-example";
const defaultResourceGroups = alicloud.resourcemanager.getResourceGroups({});
const defaultZones = alicloud.gpdb.getZones({});
const defaultNetwork = new alicloud.vpc.Network("defaultNetwork", {
vpcName: name,
cidrBlock: "10.4.0.0/16",
});
const defaultSwitch = new alicloud.vpc.Switch("defaultSwitch", {
vswitchName: name,
cidrBlock: "10.4.0.0/24",
vpcId: defaultNetwork.id,
zoneId: defaultZones.then(defaultZones => defaultZones.ids?.[0]),
});
const defaultInstance = new alicloud.gpdb.Instance("defaultInstance", {
dbInstanceCategory: "HighAvailability",
dbInstanceClass: "gpdb.group.segsdx1",
dbInstanceMode: "StorageElastic",
description: name,
engine: "gpdb",
engineVersion: "6.0",
zoneId: defaultZones.then(defaultZones => defaultZones.ids?.[0]),
instanceNetworkType: "VPC",
instanceSpec: "2C16G",
masterNodeNum: 1,
paymentType: "PayAsYouGo",
privateIpAddress: "1.1.1.1",
segStorageType: "cloud_essd",
segNodeNum: 4,
storageSize: 50,
vpcId: defaultNetwork.id,
vswitchId: defaultSwitch.id,
ipWhitelists: [{
securityIpList: "127.0.0.1",
}],
});
const defaultConnection = new alicloud.gpdb.Connection("defaultConnection", {
instanceId: defaultInstance.id,
connectionPrefix: "exampelcon",
});
configuration:
name:
type: string
default: tf-example
resources:
defaultNetwork:
type: alicloud:vpc:Network
properties:
vpcName: ${name}
cidrBlock: 10.4.0.0/16
defaultSwitch:
type: alicloud:vpc:Switch
properties:
vswitchName: ${name}
cidrBlock: 10.4.0.0/24
vpcId: ${defaultNetwork.id}
zoneId: ${defaultZones.ids[0]}
defaultInstance:
type: alicloud:gpdb:Instance
properties:
dbInstanceCategory: HighAvailability
dbInstanceClass: gpdb.group.segsdx1
dbInstanceMode: StorageElastic
description: ${name}
engine: gpdb
engineVersion: '6.0'
zoneId: ${defaultZones.ids[0]}
instanceNetworkType: VPC
instanceSpec: 2C16G
masterNodeNum: 1
paymentType: PayAsYouGo
privateIpAddress: 1.1.1.1
segStorageType: cloud_essd
segNodeNum: 4
storageSize: 50
vpcId: ${defaultNetwork.id}
vswitchId: ${defaultSwitch.id}
ipWhitelists:
- securityIpList: 127.0.0.1
defaultConnection:
type: alicloud:gpdb:Connection
properties:
instanceId: ${defaultInstance.id}
connectionPrefix: exampelcon
variables:
defaultResourceGroups:
fn::invoke:
Function: alicloud:resourcemanager:getResourceGroups
Arguments: {}
defaultZones:
fn::invoke:
Function: alicloud:gpdb:getZones
Arguments: {}
Create 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)
public Connection(String name, ConnectionArgs args)
public Connection(String name, ConnectionArgs args, CustomResourceOptions options)
type: alicloud:gpdb:Connection
properties: # The arguments to resource properties.
options: # 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.
- 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.
- name String
- The unique name of the resource.
- args ConnectionArgs
- The arguments to resource properties.
- options 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:
- Instance
Id string The Id of instance that can run database.
- Connection
Prefix 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 string The Id of instance that can run database.
- Connection
Prefix 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 String The Id of instance that can run database.
- connection
Prefix 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 string The Id of instance that can run database.
- connection
Prefix 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.
- instance
Id String The Id of instance that can run database.
- connection
Prefix 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.
Outputs
All input properties are implicitly available as output properties. Additionally, the Connection resource produces the following output properties:
- Connection
String string Connection instance string.
- Id string
The provider-assigned unique ID for this managed resource.
- Ip
Address string The ip address of connection string.
- Connection
String string Connection instance string.
- Id string
The provider-assigned unique ID for this managed resource.
- Ip
Address string The ip address of connection string.
- connection
String String Connection instance string.
- id String
The provider-assigned unique ID for this managed resource.
- ip
Address String The ip address of connection string.
- connection
String string Connection instance string.
- id string
The provider-assigned unique ID for this managed resource.
- ip
Address 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.
- connection
String String Connection instance string.
- id String
The provider-assigned unique ID for this managed resource.
- ip
Address String The ip address of connection string.
Look up 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)
public static Connection get(String name, Output<String> id, ConnectionState 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.
- Connection
Prefix 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'.
- Connection
String string Connection instance string.
- Instance
Id string The Id of instance that can run database.
- Ip
Address string The ip address of connection string.
- Port string
Internet connection port. Valid value: [3200-3999]. Default to 3306.
- Connection
Prefix 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'.
- Connection
String string Connection instance string.
- Instance
Id string The Id of instance that can run database.
- Ip
Address string The ip address of connection string.
- Port string
Internet connection port. Valid value: [3200-3999]. Default to 3306.
- connection
Prefix 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'.
- connection
String String Connection instance string.
- instance
Id String The Id of instance that can run database.
- ip
Address String The ip address of connection string.
- port String
Internet connection port. Valid value: [3200-3999]. Default to 3306.
- connection
Prefix 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'.
- connection
String string Connection instance string.
- instance
Id string The Id of instance that can run database.
- ip
Address 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.
- connection
Prefix 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'.
- connection
String String Connection instance string.
- instance
Id String The Id of instance that can run database.
- ip
Address String The ip address of connection string.
- port String
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
- Alibaba Cloud pulumi/pulumi-alicloud
- License
- Apache-2.0
- Notes
This Pulumi package is based on the
alicloud
Terraform Provider.