1. Packages
  2. Alibaba Cloud Provider
  3. API Docs
  4. mongodb
  5. PublicNetworkAddress
Alibaba Cloud v3.78.0 published on Friday, May 16, 2025 by Pulumi

alicloud.mongodb.PublicNetworkAddress

Explore with Pulumi AI

alicloud logo
Alibaba Cloud v3.78.0 published on Friday, May 16, 2025 by Pulumi

    Provides an Alicloud MongoDB public network address resource.

    For information about MongoDB public network address and how to use it, see Allocate Public Network Address for MongoDB.

    NOTE: Available since v1.248.0.

    Example 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.mongodb.getZones({});
    const index = _default.then(_default => _default.zones).length.apply(length => length - 1);
    const zoneId = _default.then(_default => _default.zones[index].id);
    const defaultNetwork = new alicloud.vpc.Network("default", {
        cidrBlock: "10.0.0.0/8",
        vpcName: name,
    });
    const defaultSwitch = new alicloud.vpc.Switch("default", {
        vpcId: defaultNetwork.id,
        zoneId: zoneId,
        cidrBlock: "10.0.0.0/24",
    });
    const defaultInstance = new alicloud.mongodb.Instance("default", {
        engineVersion: "4.4",
        storageType: "cloud_essd1",
        vswitchId: defaultSwitch.id,
        dbInstanceStorage: 20,
        vpcId: defaultNetwork.id,
        dbInstanceClass: "mdb.shard.4x.large.d",
        storageEngine: "WiredTiger",
        networkType: "VPC",
        zoneId: zoneId,
    });
    const defaultPublicNetworkAddress = new alicloud.mongodb.PublicNetworkAddress("default", {dbInstanceId: defaultInstance.id});
    
    import pulumi
    import pulumi_alicloud as alicloud
    
    config = pulumi.Config()
    name = config.get("name")
    if name is None:
        name = "tf-example"
    default = alicloud.mongodb.get_zones()
    index = len(default.zones).apply(lambda length: length - 1)
    zone_id = default.zones[index].id
    default_network = alicloud.vpc.Network("default",
        cidr_block="10.0.0.0/8",
        vpc_name=name)
    default_switch = alicloud.vpc.Switch("default",
        vpc_id=default_network.id,
        zone_id=zone_id,
        cidr_block="10.0.0.0/24")
    default_instance = alicloud.mongodb.Instance("default",
        engine_version="4.4",
        storage_type="cloud_essd1",
        vswitch_id=default_switch.id,
        db_instance_storage=20,
        vpc_id=default_network.id,
        db_instance_class="mdb.shard.4x.large.d",
        storage_engine="WiredTiger",
        network_type="VPC",
        zone_id=zone_id)
    default_public_network_address = alicloud.mongodb.PublicNetworkAddress("default", db_instance_id=default_instance.id)
    
    package main
    
    import (
    	"github.com/pulumi/pulumi-alicloud/sdk/v3/go/alicloud/mongodb"
    	"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 := mongodb.GetZones(ctx, &mongodb.GetZonesArgs{}, nil)
    		if err != nil {
    			return err
    		}
    		index := len(_default.Zones).ApplyT(func(length int) (float64, error) {
    			return length - 1, nil
    		}).(pulumi.Float64Output)
    		zoneId := _default.Zones[index].Id
    		defaultNetwork, err := vpc.NewNetwork(ctx, "default", &vpc.NetworkArgs{
    			CidrBlock: pulumi.String("10.0.0.0/8"),
    			VpcName:   pulumi.String(name),
    		})
    		if err != nil {
    			return err
    		}
    		defaultSwitch, err := vpc.NewSwitch(ctx, "default", &vpc.SwitchArgs{
    			VpcId:     defaultNetwork.ID(),
    			ZoneId:    pulumi.String(zoneId),
    			CidrBlock: pulumi.String("10.0.0.0/24"),
    		})
    		if err != nil {
    			return err
    		}
    		defaultInstance, err := mongodb.NewInstance(ctx, "default", &mongodb.InstanceArgs{
    			EngineVersion:     pulumi.String("4.4"),
    			StorageType:       pulumi.String("cloud_essd1"),
    			VswitchId:         defaultSwitch.ID(),
    			DbInstanceStorage: pulumi.Int(20),
    			VpcId:             defaultNetwork.ID(),
    			DbInstanceClass:   pulumi.String("mdb.shard.4x.large.d"),
    			StorageEngine:     pulumi.String("WiredTiger"),
    			NetworkType:       pulumi.String("VPC"),
    			ZoneId:            pulumi.String(zoneId),
    		})
    		if err != nil {
    			return err
    		}
    		_, err = mongodb.NewPublicNetworkAddress(ctx, "default", &mongodb.PublicNetworkAddressArgs{
    			DbInstanceId: defaultInstance.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") ?? "tf-example";
        var @default = AliCloud.MongoDB.GetZones.Invoke();
    
        var index = @default.Apply(@default => @default.Apply(getZonesResult => getZonesResult.Zones)).Length.Apply(length => length - 1);
    
        var zoneId = @default.Apply(@default => @default.Apply(getZonesResult => getZonesResult.Zones)[index].Id);
    
        var defaultNetwork = new AliCloud.Vpc.Network("default", new()
        {
            CidrBlock = "10.0.0.0/8",
            VpcName = name,
        });
    
        var defaultSwitch = new AliCloud.Vpc.Switch("default", new()
        {
            VpcId = defaultNetwork.Id,
            ZoneId = zoneId,
            CidrBlock = "10.0.0.0/24",
        });
    
        var defaultInstance = new AliCloud.MongoDB.Instance("default", new()
        {
            EngineVersion = "4.4",
            StorageType = "cloud_essd1",
            VswitchId = defaultSwitch.Id,
            DbInstanceStorage = 20,
            VpcId = defaultNetwork.Id,
            DbInstanceClass = "mdb.shard.4x.large.d",
            StorageEngine = "WiredTiger",
            NetworkType = "VPC",
            ZoneId = zoneId,
        });
    
        var defaultPublicNetworkAddress = new AliCloud.MongoDB.PublicNetworkAddress("default", new()
        {
            DbInstanceId = defaultInstance.Id,
        });
    
    });
    
    package generated_program;
    
    import com.pulumi.Context;
    import com.pulumi.Pulumi;
    import com.pulumi.core.Output;
    import com.pulumi.alicloud.mongodb.MongodbFunctions;
    import com.pulumi.alicloud.mongodb.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.mongodb.Instance;
    import com.pulumi.alicloud.mongodb.InstanceArgs;
    import com.pulumi.alicloud.mongodb.PublicNetworkAddress;
    import com.pulumi.alicloud.mongodb.PublicNetworkAddressArgs;
    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 = MongodbFunctions.getZones(GetZonesArgs.builder()
                .build());
    
            final var index = default_.zones().length().applyValue(_length -> _length - 1);
    
            final var zoneId = default_.zones()[index].id();
    
            var defaultNetwork = new Network("defaultNetwork", NetworkArgs.builder()
                .cidrBlock("10.0.0.0/8")
                .vpcName(name)
                .build());
    
            var defaultSwitch = new Switch("defaultSwitch", SwitchArgs.builder()
                .vpcId(defaultNetwork.id())
                .zoneId(zoneId)
                .cidrBlock("10.0.0.0/24")
                .build());
    
            var defaultInstance = new Instance("defaultInstance", InstanceArgs.builder()
                .engineVersion("4.4")
                .storageType("cloud_essd1")
                .vswitchId(defaultSwitch.id())
                .dbInstanceStorage(20)
                .vpcId(defaultNetwork.id())
                .dbInstanceClass("mdb.shard.4x.large.d")
                .storageEngine("WiredTiger")
                .networkType("VPC")
                .zoneId(zoneId)
                .build());
    
            var defaultPublicNetworkAddress = new PublicNetworkAddress("defaultPublicNetworkAddress", PublicNetworkAddressArgs.builder()
                .dbInstanceId(defaultInstance.id())
                .build());
    
        }
    }
    
    Coming soon!
    

    Create PublicNetworkAddress Resource

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

    Constructor syntax

    new PublicNetworkAddress(name: string, args: PublicNetworkAddressArgs, opts?: CustomResourceOptions);
    @overload
    def PublicNetworkAddress(resource_name: str,
                             args: PublicNetworkAddressArgs,
                             opts: Optional[ResourceOptions] = None)
    
    @overload
    def PublicNetworkAddress(resource_name: str,
                             opts: Optional[ResourceOptions] = None,
                             db_instance_id: Optional[str] = None)
    func NewPublicNetworkAddress(ctx *Context, name string, args PublicNetworkAddressArgs, opts ...ResourceOption) (*PublicNetworkAddress, error)
    public PublicNetworkAddress(string name, PublicNetworkAddressArgs args, CustomResourceOptions? opts = null)
    public PublicNetworkAddress(String name, PublicNetworkAddressArgs args)
    public PublicNetworkAddress(String name, PublicNetworkAddressArgs args, CustomResourceOptions options)
    
    type: alicloud:mongodb:PublicNetworkAddress
    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 PublicNetworkAddressArgs
    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 PublicNetworkAddressArgs
    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 PublicNetworkAddressArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args PublicNetworkAddressArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args PublicNetworkAddressArgs
    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 publicNetworkAddressResource = new AliCloud.MongoDB.PublicNetworkAddress("publicNetworkAddressResource", new()
    {
        DbInstanceId = "string",
    });
    
    example, err := mongodb.NewPublicNetworkAddress(ctx, "publicNetworkAddressResource", &mongodb.PublicNetworkAddressArgs{
    	DbInstanceId: pulumi.String("string"),
    })
    
    var publicNetworkAddressResource = new PublicNetworkAddress("publicNetworkAddressResource", PublicNetworkAddressArgs.builder()
        .dbInstanceId("string")
        .build());
    
    public_network_address_resource = alicloud.mongodb.PublicNetworkAddress("publicNetworkAddressResource", db_instance_id="string")
    
    const publicNetworkAddressResource = new alicloud.mongodb.PublicNetworkAddress("publicNetworkAddressResource", {dbInstanceId: "string"});
    
    type: alicloud:mongodb:PublicNetworkAddress
    properties:
        dbInstanceId: string
    

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

    DbInstanceId string
    The instance ID.
    DbInstanceId string
    The instance ID.
    dbInstanceId String
    The instance ID.
    dbInstanceId string
    The instance ID.
    db_instance_id str
    The instance ID.
    dbInstanceId String
    The instance ID.

    Outputs

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

    Id string
    The provider-assigned unique ID for this managed resource.
    ReplicaSets List<Pulumi.AliCloud.MongoDB.Outputs.PublicNetworkAddressReplicaSet>
    Replica set instance information.
    Id string
    The provider-assigned unique ID for this managed resource.
    ReplicaSets []PublicNetworkAddressReplicaSet
    Replica set instance information.
    id String
    The provider-assigned unique ID for this managed resource.
    replicaSets List<PublicNetworkAddressReplicaSet>
    Replica set instance information.
    id string
    The provider-assigned unique ID for this managed resource.
    replicaSets PublicNetworkAddressReplicaSet[]
    Replica set instance information.
    id str
    The provider-assigned unique ID for this managed resource.
    replica_sets Sequence[PublicNetworkAddressReplicaSet]
    Replica set instance information.
    id String
    The provider-assigned unique ID for this managed resource.
    replicaSets List<Property Map>
    Replica set instance information.

    Look up Existing PublicNetworkAddress Resource

    Get an existing PublicNetworkAddress 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?: PublicNetworkAddressState, opts?: CustomResourceOptions): PublicNetworkAddress
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            db_instance_id: Optional[str] = None,
            replica_sets: Optional[Sequence[PublicNetworkAddressReplicaSetArgs]] = None) -> PublicNetworkAddress
    func GetPublicNetworkAddress(ctx *Context, name string, id IDInput, state *PublicNetworkAddressState, opts ...ResourceOption) (*PublicNetworkAddress, error)
    public static PublicNetworkAddress Get(string name, Input<string> id, PublicNetworkAddressState? state, CustomResourceOptions? opts = null)
    public static PublicNetworkAddress get(String name, Output<String> id, PublicNetworkAddressState state, CustomResourceOptions options)
    resources:  _:    type: alicloud:mongodb:PublicNetworkAddress    get:      id: ${id}
    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:
    DbInstanceId string
    The instance ID.
    ReplicaSets []PublicNetworkAddressReplicaSetArgs
    Replica set instance information.
    dbInstanceId String
    The instance ID.
    replicaSets List<PublicNetworkAddressReplicaSet>
    Replica set instance information.
    dbInstanceId string
    The instance ID.
    replicaSets PublicNetworkAddressReplicaSet[]
    Replica set instance information.
    db_instance_id str
    The instance ID.
    replica_sets Sequence[PublicNetworkAddressReplicaSetArgs]
    Replica set instance information.
    dbInstanceId String
    The instance ID.
    replicaSets List<Property Map>
    Replica set instance information.

    Supporting Types

    PublicNetworkAddressReplicaSet, PublicNetworkAddressReplicaSetArgs

    ConnectionDomain string
    The connection address of the node.
    ConnectionPort string
    The connection port of the node.
    ConnectionType string
    The connection type.
    NetworkType string
    The network type, should be always "Public".
    ReplicaSetRole string
    The role of the node.
    RoleId string
    The id of the role.
    ConnectionDomain string
    The connection address of the node.
    ConnectionPort string
    The connection port of the node.
    ConnectionType string
    The connection type.
    NetworkType string
    The network type, should be always "Public".
    ReplicaSetRole string
    The role of the node.
    RoleId string
    The id of the role.
    connectionDomain String
    The connection address of the node.
    connectionPort String
    The connection port of the node.
    connectionType String
    The connection type.
    networkType String
    The network type, should be always "Public".
    replicaSetRole String
    The role of the node.
    roleId String
    The id of the role.
    connectionDomain string
    The connection address of the node.
    connectionPort string
    The connection port of the node.
    connectionType string
    The connection type.
    networkType string
    The network type, should be always "Public".
    replicaSetRole string
    The role of the node.
    roleId string
    The id of the role.
    connection_domain str
    The connection address of the node.
    connection_port str
    The connection port of the node.
    connection_type str
    The connection type.
    network_type str
    The network type, should be always "Public".
    replica_set_role str
    The role of the node.
    role_id str
    The id of the role.
    connectionDomain String
    The connection address of the node.
    connectionPort String
    The connection port of the node.
    connectionType String
    The connection type.
    networkType String
    The network type, should be always "Public".
    replicaSetRole String
    The role of the node.
    roleId String
    The id of the role.

    Import

    MongoDB public network address can be imported using the id, e.g.

    $ pulumi import alicloud:mongodb/publicNetworkAddress:PublicNetworkAddress 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.78.0 published on Friday, May 16, 2025 by Pulumi