1. Packages
  2. Alibaba Cloud
  3. API Docs
  4. mongodb
  5. Account
Alibaba Cloud v3.53.0 published on Wednesday, Apr 17, 2024 by Pulumi

alicloud.mongodb.Account

Explore with Pulumi AI

alicloud logo
Alibaba Cloud v3.53.0 published on Wednesday, Apr 17, 2024 by Pulumi

    Provides a MongoDB Account resource.

    For information about MongoDB Account and how to use it, see What is Account.

    NOTE: Available since v1.148.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") || "terraform-example";
    const defaultZones = alicloud.mongodb.getZones({});
    const index = defaultZones.then(defaultZones => defaultZones.zones).length.then(length => length - 1);
    const zoneId = defaultZones.then(defaultZones => defaultZones.zones[index].id);
    const defaultNetwork = new alicloud.vpc.Network("defaultNetwork", {
        vpcName: name,
        cidrBlock: "172.17.3.0/24",
    });
    const defaultSwitch = new alicloud.vpc.Switch("defaultSwitch", {
        vswitchName: name,
        cidrBlock: "172.17.3.0/24",
        vpcId: defaultNetwork.id,
        zoneId: zoneId,
    });
    const defaultInstance = new alicloud.mongodb.Instance("defaultInstance", {
        engineVersion: "4.2",
        dbInstanceClass: "dds.mongo.mid",
        dbInstanceStorage: 10,
        vswitchId: defaultSwitch.id,
        securityIpLists: [
            "10.168.1.12",
            "100.69.7.112",
        ],
        tags: {
            Created: "TF",
            For: "example",
        },
    });
    const defaultAccount = new alicloud.mongodb.Account("defaultAccount", {
        accountName: "root",
        accountPassword: "Example_123",
        instanceId: defaultInstance.id,
        accountDescription: name,
    });
    
    import pulumi
    import pulumi_alicloud as alicloud
    
    config = pulumi.Config()
    name = config.get("name")
    if name is None:
        name = "terraform-example"
    default_zones = alicloud.mongodb.get_zones()
    index = len(default_zones.zones) - 1
    zone_id = default_zones.zones[index].id
    default_network = alicloud.vpc.Network("defaultNetwork",
        vpc_name=name,
        cidr_block="172.17.3.0/24")
    default_switch = alicloud.vpc.Switch("defaultSwitch",
        vswitch_name=name,
        cidr_block="172.17.3.0/24",
        vpc_id=default_network.id,
        zone_id=zone_id)
    default_instance = alicloud.mongodb.Instance("defaultInstance",
        engine_version="4.2",
        db_instance_class="dds.mongo.mid",
        db_instance_storage=10,
        vswitch_id=default_switch.id,
        security_ip_lists=[
            "10.168.1.12",
            "100.69.7.112",
        ],
        tags={
            "Created": "TF",
            "For": "example",
        })
    default_account = alicloud.mongodb.Account("defaultAccount",
        account_name="root",
        account_password="Example_123",
        instance_id=default_instance.id,
        account_description=name)
    
    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 := "terraform-example"
    		if param := cfg.Get("name"); param != "" {
    			name = param
    		}
    		defaultZones, err := mongodb.GetZones(ctx, nil, nil)
    		if err != nil {
    			return err
    		}
    		index := len(defaultZones.Zones) - 1
    		zoneId := defaultZones.Zones[index].Id
    		defaultNetwork, err := vpc.NewNetwork(ctx, "defaultNetwork", &vpc.NetworkArgs{
    			VpcName:   pulumi.String(name),
    			CidrBlock: pulumi.String("172.17.3.0/24"),
    		})
    		if err != nil {
    			return err
    		}
    		defaultSwitch, err := vpc.NewSwitch(ctx, "defaultSwitch", &vpc.SwitchArgs{
    			VswitchName: pulumi.String(name),
    			CidrBlock:   pulumi.String("172.17.3.0/24"),
    			VpcId:       defaultNetwork.ID(),
    			ZoneId:      pulumi.String(zoneId),
    		})
    		if err != nil {
    			return err
    		}
    		defaultInstance, err := mongodb.NewInstance(ctx, "defaultInstance", &mongodb.InstanceArgs{
    			EngineVersion:     pulumi.String("4.2"),
    			DbInstanceClass:   pulumi.String("dds.mongo.mid"),
    			DbInstanceStorage: pulumi.Int(10),
    			VswitchId:         defaultSwitch.ID(),
    			SecurityIpLists: pulumi.StringArray{
    				pulumi.String("10.168.1.12"),
    				pulumi.String("100.69.7.112"),
    			},
    			Tags: pulumi.Map{
    				"Created": pulumi.Any("TF"),
    				"For":     pulumi.Any("example"),
    			},
    		})
    		if err != nil {
    			return err
    		}
    		_, err = mongodb.NewAccount(ctx, "defaultAccount", &mongodb.AccountArgs{
    			AccountName:        pulumi.String("root"),
    			AccountPassword:    pulumi.String("Example_123"),
    			InstanceId:         defaultInstance.ID(),
    			AccountDescription: pulumi.String(name),
    		})
    		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") ?? "terraform-example";
        var defaultZones = AliCloud.MongoDB.GetZones.Invoke();
    
        var index = defaultZones.Apply(getZonesResult => getZonesResult.Zones).Length.Apply(length => length - 1);
    
        var zoneId = defaultZones.Apply(getZonesResult => getZonesResult.Zones)[index].Id;
    
        var defaultNetwork = new AliCloud.Vpc.Network("defaultNetwork", new()
        {
            VpcName = name,
            CidrBlock = "172.17.3.0/24",
        });
    
        var defaultSwitch = new AliCloud.Vpc.Switch("defaultSwitch", new()
        {
            VswitchName = name,
            CidrBlock = "172.17.3.0/24",
            VpcId = defaultNetwork.Id,
            ZoneId = zoneId,
        });
    
        var defaultInstance = new AliCloud.MongoDB.Instance("defaultInstance", new()
        {
            EngineVersion = "4.2",
            DbInstanceClass = "dds.mongo.mid",
            DbInstanceStorage = 10,
            VswitchId = defaultSwitch.Id,
            SecurityIpLists = new[]
            {
                "10.168.1.12",
                "100.69.7.112",
            },
            Tags = 
            {
                { "Created", "TF" },
                { "For", "example" },
            },
        });
    
        var defaultAccount = new AliCloud.MongoDB.Account("defaultAccount", new()
        {
            AccountName = "root",
            AccountPassword = "Example_123",
            InstanceId = defaultInstance.Id,
            AccountDescription = name,
        });
    
    });
    
    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.Account;
    import com.pulumi.alicloud.mongodb.AccountArgs;
    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("terraform-example");
            final var defaultZones = MongodbFunctions.getZones();
    
            final var index = defaultZones.applyValue(getZonesResult -> getZonesResult.zones()).length() - 1;
    
            final var zoneId = defaultZones.applyValue(getZonesResult -> getZonesResult.zones())[index].id();
    
            var defaultNetwork = new Network("defaultNetwork", NetworkArgs.builder()        
                .vpcName(name)
                .cidrBlock("172.17.3.0/24")
                .build());
    
            var defaultSwitch = new Switch("defaultSwitch", SwitchArgs.builder()        
                .vswitchName(name)
                .cidrBlock("172.17.3.0/24")
                .vpcId(defaultNetwork.id())
                .zoneId(zoneId)
                .build());
    
            var defaultInstance = new Instance("defaultInstance", InstanceArgs.builder()        
                .engineVersion("4.2")
                .dbInstanceClass("dds.mongo.mid")
                .dbInstanceStorage(10)
                .vswitchId(defaultSwitch.id())
                .securityIpLists(            
                    "10.168.1.12",
                    "100.69.7.112")
                .tags(Map.ofEntries(
                    Map.entry("Created", "TF"),
                    Map.entry("For", "example")
                ))
                .build());
    
            var defaultAccount = new Account("defaultAccount", AccountArgs.builder()        
                .accountName("root")
                .accountPassword("Example_123")
                .instanceId(defaultInstance.id())
                .accountDescription(name)
                .build());
    
        }
    }
    
    Coming soon!
    

    Create Account Resource

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

    Constructor syntax

    new Account(name: string, args: AccountArgs, opts?: CustomResourceOptions);
    @overload
    def Account(resource_name: str,
                args: AccountArgs,
                opts: Optional[ResourceOptions] = None)
    
    @overload
    def Account(resource_name: str,
                opts: Optional[ResourceOptions] = None,
                account_name: Optional[str] = None,
                account_password: Optional[str] = None,
                instance_id: Optional[str] = None,
                account_description: Optional[str] = None)
    func NewAccount(ctx *Context, name string, args AccountArgs, opts ...ResourceOption) (*Account, error)
    public Account(string name, AccountArgs args, CustomResourceOptions? opts = null)
    public Account(String name, AccountArgs args)
    public Account(String name, AccountArgs args, CustomResourceOptions options)
    
    type: alicloud:mongodb:Account
    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 AccountArgs
    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 AccountArgs
    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 AccountArgs
    The arguments to resource properties.
    opts ResourceOption
    Bag of options to control resource's behavior.
    name string
    The unique name of the resource.
    args AccountArgs
    The arguments to resource properties.
    opts CustomResourceOptions
    Bag of options to control resource's behavior.
    name String
    The unique name of the resource.
    args AccountArgs
    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 exampleaccountResourceResourceFromMongodbaccount = new AliCloud.MongoDB.Account("exampleaccountResourceResourceFromMongodbaccount", new()
    {
        AccountName = "string",
        AccountPassword = "string",
        InstanceId = "string",
        AccountDescription = "string",
    });
    
    example, err := mongodb.NewAccount(ctx, "exampleaccountResourceResourceFromMongodbaccount", &mongodb.AccountArgs{
    	AccountName:        pulumi.String("string"),
    	AccountPassword:    pulumi.String("string"),
    	InstanceId:         pulumi.String("string"),
    	AccountDescription: pulumi.String("string"),
    })
    
    var exampleaccountResourceResourceFromMongodbaccount = new Account("exampleaccountResourceResourceFromMongodbaccount", AccountArgs.builder()        
        .accountName("string")
        .accountPassword("string")
        .instanceId("string")
        .accountDescription("string")
        .build());
    
    exampleaccount_resource_resource_from_mongodbaccount = alicloud.mongodb.Account("exampleaccountResourceResourceFromMongodbaccount",
        account_name="string",
        account_password="string",
        instance_id="string",
        account_description="string")
    
    const exampleaccountResourceResourceFromMongodbaccount = new alicloud.mongodb.Account("exampleaccountResourceResourceFromMongodbaccount", {
        accountName: "string",
        accountPassword: "string",
        instanceId: "string",
        accountDescription: "string",
    });
    
    type: alicloud:mongodb:Account
    properties:
        accountDescription: string
        accountName: string
        accountPassword: string
        instanceId: string
    

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

    AccountName string
    The name of the account. Valid values: root.
    AccountPassword string
    The Password of the Account.

    • The password must contain at least three of the following character types: uppercase letters, lowercase letters, digits, and special characters. Special characters include !#$%^&*()_+-=.
    • The password must be 8 to 32 characters in length.
    InstanceId string
    The ID of the instance.
    AccountDescription string
    The description of the account.

    • The description must start with a letter, and cannot start with http:// or https://.
    • It must be 2 to 256 characters in length, and can contain letters, digits, underscores (_), and hyphens (-).
    AccountName string
    The name of the account. Valid values: root.
    AccountPassword string
    The Password of the Account.

    • The password must contain at least three of the following character types: uppercase letters, lowercase letters, digits, and special characters. Special characters include !#$%^&*()_+-=.
    • The password must be 8 to 32 characters in length.
    InstanceId string
    The ID of the instance.
    AccountDescription string
    The description of the account.

    • The description must start with a letter, and cannot start with http:// or https://.
    • It must be 2 to 256 characters in length, and can contain letters, digits, underscores (_), and hyphens (-).
    accountName String
    The name of the account. Valid values: root.
    accountPassword String
    The Password of the Account.

    • The password must contain at least three of the following character types: uppercase letters, lowercase letters, digits, and special characters. Special characters include !#$%^&*()_+-=.
    • The password must be 8 to 32 characters in length.
    instanceId String
    The ID of the instance.
    accountDescription String
    The description of the account.

    • The description must start with a letter, and cannot start with http:// or https://.
    • It must be 2 to 256 characters in length, and can contain letters, digits, underscores (_), and hyphens (-).
    accountName string
    The name of the account. Valid values: root.
    accountPassword string
    The Password of the Account.

    • The password must contain at least three of the following character types: uppercase letters, lowercase letters, digits, and special characters. Special characters include !#$%^&*()_+-=.
    • The password must be 8 to 32 characters in length.
    instanceId string
    The ID of the instance.
    accountDescription string
    The description of the account.

    • The description must start with a letter, and cannot start with http:// or https://.
    • It must be 2 to 256 characters in length, and can contain letters, digits, underscores (_), and hyphens (-).
    account_name str
    The name of the account. Valid values: root.
    account_password str
    The Password of the Account.

    • The password must contain at least three of the following character types: uppercase letters, lowercase letters, digits, and special characters. Special characters include !#$%^&*()_+-=.
    • The password must be 8 to 32 characters in length.
    instance_id str
    The ID of the instance.
    account_description str
    The description of the account.

    • The description must start with a letter, and cannot start with http:// or https://.
    • It must be 2 to 256 characters in length, and can contain letters, digits, underscores (_), and hyphens (-).
    accountName String
    The name of the account. Valid values: root.
    accountPassword String
    The Password of the Account.

    • The password must contain at least three of the following character types: uppercase letters, lowercase letters, digits, and special characters. Special characters include !#$%^&*()_+-=.
    • The password must be 8 to 32 characters in length.
    instanceId String
    The ID of the instance.
    accountDescription String
    The description of the account.

    • The description must start with a letter, and cannot start with http:// or https://.
    • It must be 2 to 256 characters in length, and can contain letters, digits, underscores (_), and hyphens (-).

    Outputs

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

    Id string
    The provider-assigned unique ID for this managed resource.
    Status string
    The status of the account. Valid values: Unavailable, Available.
    Id string
    The provider-assigned unique ID for this managed resource.
    Status string
    The status of the account. Valid values: Unavailable, Available.
    id String
    The provider-assigned unique ID for this managed resource.
    status String
    The status of the account. Valid values: Unavailable, Available.
    id string
    The provider-assigned unique ID for this managed resource.
    status string
    The status of the account. Valid values: Unavailable, Available.
    id str
    The provider-assigned unique ID for this managed resource.
    status str
    The status of the account. Valid values: Unavailable, Available.
    id String
    The provider-assigned unique ID for this managed resource.
    status String
    The status of the account. Valid values: Unavailable, Available.

    Look up Existing Account Resource

    Get an existing Account 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?: AccountState, opts?: CustomResourceOptions): Account
    @staticmethod
    def get(resource_name: str,
            id: str,
            opts: Optional[ResourceOptions] = None,
            account_description: Optional[str] = None,
            account_name: Optional[str] = None,
            account_password: Optional[str] = None,
            instance_id: Optional[str] = None,
            status: Optional[str] = None) -> Account
    func GetAccount(ctx *Context, name string, id IDInput, state *AccountState, opts ...ResourceOption) (*Account, error)
    public static Account Get(string name, Input<string> id, AccountState? state, CustomResourceOptions? opts = null)
    public static Account get(String name, Output<String> id, AccountState 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:
    AccountDescription string
    The description of the account.

    • The description must start with a letter, and cannot start with http:// or https://.
    • It must be 2 to 256 characters in length, and can contain letters, digits, underscores (_), and hyphens (-).
    AccountName string
    The name of the account. Valid values: root.
    AccountPassword string
    The Password of the Account.

    • The password must contain at least three of the following character types: uppercase letters, lowercase letters, digits, and special characters. Special characters include !#$%^&*()_+-=.
    • The password must be 8 to 32 characters in length.
    InstanceId string
    The ID of the instance.
    Status string
    The status of the account. Valid values: Unavailable, Available.
    AccountDescription string
    The description of the account.

    • The description must start with a letter, and cannot start with http:// or https://.
    • It must be 2 to 256 characters in length, and can contain letters, digits, underscores (_), and hyphens (-).
    AccountName string
    The name of the account. Valid values: root.
    AccountPassword string
    The Password of the Account.

    • The password must contain at least three of the following character types: uppercase letters, lowercase letters, digits, and special characters. Special characters include !#$%^&*()_+-=.
    • The password must be 8 to 32 characters in length.
    InstanceId string
    The ID of the instance.
    Status string
    The status of the account. Valid values: Unavailable, Available.
    accountDescription String
    The description of the account.

    • The description must start with a letter, and cannot start with http:// or https://.
    • It must be 2 to 256 characters in length, and can contain letters, digits, underscores (_), and hyphens (-).
    accountName String
    The name of the account. Valid values: root.
    accountPassword String
    The Password of the Account.

    • The password must contain at least three of the following character types: uppercase letters, lowercase letters, digits, and special characters. Special characters include !#$%^&*()_+-=.
    • The password must be 8 to 32 characters in length.
    instanceId String
    The ID of the instance.
    status String
    The status of the account. Valid values: Unavailable, Available.
    accountDescription string
    The description of the account.

    • The description must start with a letter, and cannot start with http:// or https://.
    • It must be 2 to 256 characters in length, and can contain letters, digits, underscores (_), and hyphens (-).
    accountName string
    The name of the account. Valid values: root.
    accountPassword string
    The Password of the Account.

    • The password must contain at least three of the following character types: uppercase letters, lowercase letters, digits, and special characters. Special characters include !#$%^&*()_+-=.
    • The password must be 8 to 32 characters in length.
    instanceId string
    The ID of the instance.
    status string
    The status of the account. Valid values: Unavailable, Available.
    account_description str
    The description of the account.

    • The description must start with a letter, and cannot start with http:// or https://.
    • It must be 2 to 256 characters in length, and can contain letters, digits, underscores (_), and hyphens (-).
    account_name str
    The name of the account. Valid values: root.
    account_password str
    The Password of the Account.

    • The password must contain at least three of the following character types: uppercase letters, lowercase letters, digits, and special characters. Special characters include !#$%^&*()_+-=.
    • The password must be 8 to 32 characters in length.
    instance_id str
    The ID of the instance.
    status str
    The status of the account. Valid values: Unavailable, Available.
    accountDescription String
    The description of the account.

    • The description must start with a letter, and cannot start with http:// or https://.
    • It must be 2 to 256 characters in length, and can contain letters, digits, underscores (_), and hyphens (-).
    accountName String
    The name of the account. Valid values: root.
    accountPassword String
    The Password of the Account.

    • The password must contain at least three of the following character types: uppercase letters, lowercase letters, digits, and special characters. Special characters include !#$%^&*()_+-=.
    • The password must be 8 to 32 characters in length.
    instanceId String
    The ID of the instance.
    status String
    The status of the account. Valid values: Unavailable, Available.

    Import

    MongoDB Account can be imported using the id, e.g.

    $ pulumi import alicloud:mongodb/account:Account example <instance_id>:<account_name>
    

    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.53.0 published on Wednesday, Apr 17, 2024 by Pulumi