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

alicloud.kvstore.Connection

Explore with Pulumi AI

Operate the public network ip of the specified resource. How to use it, see What is Connection.

NOTE: Available since v1.101.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") || "tf-example";
const _default = alicloud.kvstore.getZones({});
const defaultGetResourceGroups = alicloud.resourcemanager.getResourceGroups({
    status: "OK",
});
const defaultNetwork = new alicloud.vpc.Network("default", {
    vpcName: name,
    cidrBlock: "10.4.0.0/16",
});
const defaultSwitch = new alicloud.vpc.Switch("default", {
    vswitchName: name,
    cidrBlock: "10.4.0.0/24",
    vpcId: defaultNetwork.id,
    zoneId: _default.then(_default => _default.zones?.[0]?.id),
});
const defaultInstance = new alicloud.kvstore.Instance("default", {
    dbInstanceName: name,
    vswitchId: defaultSwitch.id,
    resourceGroupId: defaultGetResourceGroups.then(defaultGetResourceGroups => defaultGetResourceGroups.ids?.[0]),
    zoneId: _default.then(_default => _default.zones?.[0]?.id),
    instanceClass: "redis.master.large.default",
    instanceType: "Redis",
    engineVersion: "5.0",
    securityIps: ["10.23.12.24"],
    config: {
        appendonly: "yes",
        "lazyfree-lazy-eviction": "yes",
    },
    tags: {
        Created: "TF",
        For: "example",
    },
});
const defaultConnection = new alicloud.kvstore.Connection("default", {
    connectionStringPrefix: "exampleconnection",
    instanceId: defaultInstance.id,
    port: "6370",
});
Copy
import pulumi
import pulumi_alicloud as alicloud

config = pulumi.Config()
name = config.get("name")
if name is None:
    name = "tf-example"
default = alicloud.kvstore.get_zones()
default_get_resource_groups = alicloud.resourcemanager.get_resource_groups(status="OK")
default_network = alicloud.vpc.Network("default",
    vpc_name=name,
    cidr_block="10.4.0.0/16")
default_switch = alicloud.vpc.Switch("default",
    vswitch_name=name,
    cidr_block="10.4.0.0/24",
    vpc_id=default_network.id,
    zone_id=default.zones[0].id)
default_instance = alicloud.kvstore.Instance("default",
    db_instance_name=name,
    vswitch_id=default_switch.id,
    resource_group_id=default_get_resource_groups.ids[0],
    zone_id=default.zones[0].id,
    instance_class="redis.master.large.default",
    instance_type="Redis",
    engine_version="5.0",
    security_ips=["10.23.12.24"],
    config={
        "appendonly": "yes",
        "lazyfree-lazy-eviction": "yes",
    },
    tags={
        "Created": "TF",
        "For": "example",
    })
default_connection = alicloud.kvstore.Connection("default",
    connection_string_prefix="exampleconnection",
    instance_id=default_instance.id,
    port="6370")
Copy
package main

import (
	"github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud/kvstore"
	"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
		}
		_default, err := kvstore.GetZones(ctx, &kvstore.GetZonesArgs{}, nil)
		if err != nil {
			return err
		}
		defaultGetResourceGroups, err := resourcemanager.GetResourceGroups(ctx, &resourcemanager.GetResourceGroupsArgs{
			Status: pulumi.StringRef("OK"),
		}, nil)
		if err != nil {
			return err
		}
		defaultNetwork, err := vpc.NewNetwork(ctx, "default", &vpc.NetworkArgs{
			VpcName:   pulumi.String(name),
			CidrBlock: pulumi.String("10.4.0.0/16"),
		})
		if err != nil {
			return err
		}
		defaultSwitch, err := vpc.NewSwitch(ctx, "default", &vpc.SwitchArgs{
			VswitchName: pulumi.String(name),
			CidrBlock:   pulumi.String("10.4.0.0/24"),
			VpcId:       defaultNetwork.ID(),
			ZoneId:      pulumi.String(_default.Zones[0].Id),
		})
		if err != nil {
			return err
		}
		defaultInstance, err := kvstore.NewInstance(ctx, "default", &kvstore.InstanceArgs{
			DbInstanceName:  pulumi.String(name),
			VswitchId:       defaultSwitch.ID(),
			ResourceGroupId: pulumi.String(defaultGetResourceGroups.Ids[0]),
			ZoneId:          pulumi.String(_default.Zones[0].Id),
			InstanceClass:   pulumi.String("redis.master.large.default"),
			InstanceType:    pulumi.String("Redis"),
			EngineVersion:   pulumi.String("5.0"),
			SecurityIps: pulumi.StringArray{
				pulumi.String("10.23.12.24"),
			},
			Config: pulumi.StringMap{
				"appendonly":             pulumi.String("yes"),
				"lazyfree-lazy-eviction": pulumi.String("yes"),
			},
			Tags: pulumi.StringMap{
				"Created": pulumi.String("TF"),
				"For":     pulumi.String("example"),
			},
		})
		if err != nil {
			return err
		}
		_, err = kvstore.NewConnection(ctx, "default", &kvstore.ConnectionArgs{
			ConnectionStringPrefix: pulumi.String("exampleconnection"),
			InstanceId:             defaultInstance.ID(),
			Port:                   pulumi.String("6370"),
		})
		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") ?? "tf-example";
    var @default = AliCloud.KVStore.GetZones.Invoke();

    var defaultGetResourceGroups = AliCloud.ResourceManager.GetResourceGroups.Invoke(new()
    {
        Status = "OK",
    });

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

    var defaultSwitch = new AliCloud.Vpc.Switch("default", new()
    {
        VswitchName = name,
        CidrBlock = "10.4.0.0/24",
        VpcId = defaultNetwork.Id,
        ZoneId = @default.Apply(@default => @default.Apply(getZonesResult => getZonesResult.Zones[0]?.Id)),
    });

    var defaultInstance = new AliCloud.KVStore.Instance("default", new()
    {
        DbInstanceName = name,
        VswitchId = defaultSwitch.Id,
        ResourceGroupId = defaultGetResourceGroups.Apply(getResourceGroupsResult => getResourceGroupsResult.Ids[0]),
        ZoneId = @default.Apply(@default => @default.Apply(getZonesResult => getZonesResult.Zones[0]?.Id)),
        InstanceClass = "redis.master.large.default",
        InstanceType = "Redis",
        EngineVersion = "5.0",
        SecurityIps = new[]
        {
            "10.23.12.24",
        },
        Config = 
        {
            { "appendonly", "yes" },
            { "lazyfree-lazy-eviction", "yes" },
        },
        Tags = 
        {
            { "Created", "TF" },
            { "For", "example" },
        },
    });

    var defaultConnection = new AliCloud.KVStore.Connection("default", new()
    {
        ConnectionStringPrefix = "exampleconnection",
        InstanceId = defaultInstance.Id,
        Port = "6370",
    });

});
Copy
package generated_program;

import com.pulumi.Context;
import com.pulumi.Pulumi;
import com.pulumi.core.Output;
import com.pulumi.alicloud.kvstore.KvstoreFunctions;
import com.pulumi.alicloud.kvstore.inputs.GetZonesArgs;
import com.pulumi.alicloud.resourcemanager.ResourcemanagerFunctions;
import com.pulumi.alicloud.resourcemanager.inputs.GetResourceGroupsArgs;
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.kvstore.Instance;
import com.pulumi.alicloud.kvstore.InstanceArgs;
import com.pulumi.alicloud.kvstore.Connection;
import com.pulumi.alicloud.kvstore.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 default = KvstoreFunctions.getZones();

        final var defaultGetResourceGroups = ResourcemanagerFunctions.getResourceGroups(GetResourceGroupsArgs.builder()
            .status("OK")
            .build());

        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(default_.zones()[0].id())
            .build());

        var defaultInstance = new Instance("defaultInstance", InstanceArgs.builder()
            .dbInstanceName(name)
            .vswitchId(defaultSwitch.id())
            .resourceGroupId(defaultGetResourceGroups.applyValue(getResourceGroupsResult -> getResourceGroupsResult.ids()[0]))
            .zoneId(default_.zones()[0].id())
            .instanceClass("redis.master.large.default")
            .instanceType("Redis")
            .engineVersion("5.0")
            .securityIps("10.23.12.24")
            .config(Map.ofEntries(
                Map.entry("appendonly", "yes"),
                Map.entry("lazyfree-lazy-eviction", "yes")
            ))
            .tags(Map.ofEntries(
                Map.entry("Created", "TF"),
                Map.entry("For", "example")
            ))
            .build());

        var defaultConnection = new Connection("defaultConnection", ConnectionArgs.builder()
            .connectionStringPrefix("exampleconnection")
            .instanceId(defaultInstance.id())
            .port("6370")
            .build());

    }
}
Copy
configuration:
  name:
    type: string
    default: tf-example
resources:
  defaultNetwork:
    type: alicloud:vpc:Network
    name: default
    properties:
      vpcName: ${name}
      cidrBlock: 10.4.0.0/16
  defaultSwitch:
    type: alicloud:vpc:Switch
    name: default
    properties:
      vswitchName: ${name}
      cidrBlock: 10.4.0.0/24
      vpcId: ${defaultNetwork.id}
      zoneId: ${default.zones[0].id}
  defaultInstance:
    type: alicloud:kvstore:Instance
    name: default
    properties:
      dbInstanceName: ${name}
      vswitchId: ${defaultSwitch.id}
      resourceGroupId: ${defaultGetResourceGroups.ids[0]}
      zoneId: ${default.zones[0].id}
      instanceClass: redis.master.large.default
      instanceType: Redis
      engineVersion: '5.0'
      securityIps:
        - 10.23.12.24
      config:
        appendonly: yes
        lazyfree-lazy-eviction: yes
      tags:
        Created: TF
        For: example
  defaultConnection:
    type: alicloud:kvstore:Connection
    name: default
    properties:
      connectionStringPrefix: exampleconnection
      instanceId: ${defaultInstance.id}
      port: '6370'
variables:
  default:
    fn::invoke:
      function: alicloud:kvstore:getZones
      arguments: {}
  defaultGetResourceGroups:
    fn::invoke:
      function: alicloud:resourcemanager:getResourceGroups
      arguments:
        status: OK
Copy

Create Connection Resource

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

Constructor syntax

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

@overload
def Connection(resource_name: str,
               opts: Optional[ResourceOptions] = None,
               connection_string_prefix: Optional[str] = None,
               instance_id: Optional[str] = None,
               port: Optional[str] = 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:kvstore:Connection
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. ConnectionArgs
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. 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 This property is required. string
The unique name of the resource.
args This property is required. ConnectionArgs
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. ConnectionArgs
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. ConnectionArgs
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 exampleconnectionResourceResourceFromKvstoreconnection = new AliCloud.KVStore.Connection("exampleconnectionResourceResourceFromKvstoreconnection", new()
{
    ConnectionStringPrefix = "string",
    InstanceId = "string",
    Port = "string",
});
Copy
example, err := kvstore.NewConnection(ctx, "exampleconnectionResourceResourceFromKvstoreconnection", &kvstore.ConnectionArgs{
	ConnectionStringPrefix: pulumi.String("string"),
	InstanceId:             pulumi.String("string"),
	Port:                   pulumi.String("string"),
})
Copy
var exampleconnectionResourceResourceFromKvstoreconnection = new Connection("exampleconnectionResourceResourceFromKvstoreconnection", ConnectionArgs.builder()
    .connectionStringPrefix("string")
    .instanceId("string")
    .port("string")
    .build());
Copy
exampleconnection_resource_resource_from_kvstoreconnection = alicloud.kvstore.Connection("exampleconnectionResourceResourceFromKvstoreconnection",
    connection_string_prefix="string",
    instance_id="string",
    port="string")
Copy
const exampleconnectionResourceResourceFromKvstoreconnection = new alicloud.kvstore.Connection("exampleconnectionResourceResourceFromKvstoreconnection", {
    connectionStringPrefix: "string",
    instanceId: "string",
    port: "string",
});
Copy
type: alicloud:kvstore:Connection
properties:
    connectionStringPrefix: string
    instanceId: string
    port: string
Copy

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

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

The Connection resource accepts the following input properties:

ConnectionStringPrefix This property is required. string
The prefix of the public endpoint. The prefix can be 8 to 64 characters in length, and can contain lowercase letters and digits. It must start with a lowercase letter.
InstanceId
This property is required.
Changes to this property will trigger replacement.
string
The ID of the instance.
Port This property is required. string
The service port number of the instance.
ConnectionStringPrefix This property is required. string
The prefix of the public endpoint. The prefix can be 8 to 64 characters in length, and can contain lowercase letters and digits. It must start with a lowercase letter.
InstanceId
This property is required.
Changes to this property will trigger replacement.
string
The ID of the instance.
Port This property is required. string
The service port number of the instance.
connectionStringPrefix This property is required. String
The prefix of the public endpoint. The prefix can be 8 to 64 characters in length, and can contain lowercase letters and digits. It must start with a lowercase letter.
instanceId
This property is required.
Changes to this property will trigger replacement.
String
The ID of the instance.
port This property is required. String
The service port number of the instance.
connectionStringPrefix This property is required. string
The prefix of the public endpoint. The prefix can be 8 to 64 characters in length, and can contain lowercase letters and digits. It must start with a lowercase letter.
instanceId
This property is required.
Changes to this property will trigger replacement.
string
The ID of the instance.
port This property is required. string
The service port number of the instance.
connection_string_prefix This property is required. str
The prefix of the public endpoint. The prefix can be 8 to 64 characters in length, and can contain lowercase letters and digits. It must start with a lowercase letter.
instance_id
This property is required.
Changes to this property will trigger replacement.
str
The ID of the instance.
port This property is required. str
The service port number of the instance.
connectionStringPrefix This property is required. String
The prefix of the public endpoint. The prefix can be 8 to 64 characters in length, and can contain lowercase letters and digits. It must start with a lowercase letter.
instanceId
This property is required.
Changes to this property will trigger replacement.
String
The ID of the instance.
port This property is required. String
The service port number of the instance.

Outputs

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

ConnectionString string
The public connection string of Tair (Redis OSS-Compatible) And Memcache (KVStore) Instance.
Id string
The provider-assigned unique ID for this managed resource.
ConnectionString string
The public connection string of Tair (Redis OSS-Compatible) And Memcache (KVStore) Instance.
Id string
The provider-assigned unique ID for this managed resource.
connectionString String
The public connection string of Tair (Redis OSS-Compatible) And Memcache (KVStore) Instance.
id String
The provider-assigned unique ID for this managed resource.
connectionString string
The public connection string of Tair (Redis OSS-Compatible) And Memcache (KVStore) Instance.
id string
The provider-assigned unique ID for this managed resource.
connection_string str
The public connection string of Tair (Redis OSS-Compatible) And Memcache (KVStore) Instance.
id str
The provider-assigned unique ID for this managed resource.
connectionString String
The public connection string of Tair (Redis OSS-Compatible) And Memcache (KVStore) Instance.
id String
The provider-assigned unique ID for this managed resource.

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_string: Optional[str] = None,
        connection_string_prefix: Optional[str] = None,
        instance_id: 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)
resources:  _:    type: alicloud:kvstore:Connection    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:
ConnectionString string
The public connection string of Tair (Redis OSS-Compatible) And Memcache (KVStore) Instance.
ConnectionStringPrefix string
The prefix of the public endpoint. The prefix can be 8 to 64 characters in length, and can contain lowercase letters and digits. It must start with a lowercase letter.
InstanceId Changes to this property will trigger replacement. string
The ID of the instance.
Port string
The service port number of the instance.
ConnectionString string
The public connection string of Tair (Redis OSS-Compatible) And Memcache (KVStore) Instance.
ConnectionStringPrefix string
The prefix of the public endpoint. The prefix can be 8 to 64 characters in length, and can contain lowercase letters and digits. It must start with a lowercase letter.
InstanceId Changes to this property will trigger replacement. string
The ID of the instance.
Port string
The service port number of the instance.
connectionString String
The public connection string of Tair (Redis OSS-Compatible) And Memcache (KVStore) Instance.
connectionStringPrefix String
The prefix of the public endpoint. The prefix can be 8 to 64 characters in length, and can contain lowercase letters and digits. It must start with a lowercase letter.
instanceId Changes to this property will trigger replacement. String
The ID of the instance.
port String
The service port number of the instance.
connectionString string
The public connection string of Tair (Redis OSS-Compatible) And Memcache (KVStore) Instance.
connectionStringPrefix string
The prefix of the public endpoint. The prefix can be 8 to 64 characters in length, and can contain lowercase letters and digits. It must start with a lowercase letter.
instanceId Changes to this property will trigger replacement. string
The ID of the instance.
port string
The service port number of the instance.
connection_string str
The public connection string of Tair (Redis OSS-Compatible) And Memcache (KVStore) Instance.
connection_string_prefix str
The prefix of the public endpoint. The prefix can be 8 to 64 characters in length, and can contain lowercase letters and digits. It must start with a lowercase letter.
instance_id Changes to this property will trigger replacement. str
The ID of the instance.
port str
The service port number of the instance.
connectionString String
The public connection string of Tair (Redis OSS-Compatible) And Memcache (KVStore) Instance.
connectionStringPrefix String
The prefix of the public endpoint. The prefix can be 8 to 64 characters in length, and can contain lowercase letters and digits. It must start with a lowercase letter.
instanceId Changes to this property will trigger replacement. String
The ID of the instance.
port String
The service port number of the instance.

Import

Tair (Redis OSS-Compatible) And Memcache (KVStore) connection can be imported using the id, e.g.

$ pulumi import alicloud:kvstore/connection:Connection example r-abc12345678
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.