alicloud.mongodb.Account
Explore with Pulumi AI
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 default = alicloud.mongodb.getZones({});
const index = _default.then(_default => _default.zones).length.then(length => length - 1);
const zoneId = _default.then(_default => _default.zones[index].id);
const defaultNetwork = new alicloud.vpc.Network("default", {
vpcName: name,
cidrBlock: "172.17.3.0/24",
});
const defaultSwitch = new alicloud.vpc.Switch("default", {
vswitchName: name,
cidrBlock: "172.17.3.0/24",
vpcId: defaultNetwork.id,
zoneId: zoneId,
});
const defaultInstance = new alicloud.mongodb.Instance("default", {
engineVersion: "4.2",
dbInstanceClass: "dds.mongo.mid",
dbInstanceStorage: 10,
vswitchId: defaultSwitch.id,
securityIpLists: [
"10.168.1.12",
"100.69.7.112",
],
name: name,
tags: {
Created: "TF",
For: "example",
},
});
const defaultAccount = new alicloud.mongodb.Account("default", {
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 = alicloud.mongodb.get_zones()
index = len(default.zones) - 1
zone_id = default.zones[index].id
default_network = alicloud.vpc.Network("default",
vpc_name=name,
cidr_block="172.17.3.0/24")
default_switch = alicloud.vpc.Switch("default",
vswitch_name=name,
cidr_block="172.17.3.0/24",
vpc_id=default_network.id,
zone_id=zone_id)
default_instance = alicloud.mongodb.Instance("default",
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",
],
name=name,
tags={
"Created": "TF",
"For": "example",
})
default_account = alicloud.mongodb.Account("default",
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
}
_default, err := mongodb.GetZones(ctx, nil, nil)
if err != nil {
return err
}
index := pulumi.Float64(len(_default.Zones)) - 1
zoneId := _default.Zones[index].Id
defaultNetwork, err := vpc.NewNetwork(ctx, "default", &vpc.NetworkArgs{
VpcName: pulumi.String(name),
CidrBlock: pulumi.String("172.17.3.0/24"),
})
if err != nil {
return err
}
defaultSwitch, err := vpc.NewSwitch(ctx, "default", &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, "default", &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"),
},
Name: pulumi.String(name),
Tags: pulumi.StringMap{
"Created": pulumi.String("TF"),
"For": pulumi.String("example"),
},
})
if err != nil {
return err
}
_, err = mongodb.NewAccount(ctx, "default", &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 @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()
{
VpcName = name,
CidrBlock = "172.17.3.0/24",
});
var defaultSwitch = new AliCloud.Vpc.Switch("default", new()
{
VswitchName = name,
CidrBlock = "172.17.3.0/24",
VpcId = defaultNetwork.Id,
ZoneId = zoneId,
});
var defaultInstance = new AliCloud.MongoDB.Instance("default", new()
{
EngineVersion = "4.2",
DbInstanceClass = "dds.mongo.mid",
DbInstanceStorage = 10,
VswitchId = defaultSwitch.Id,
SecurityIpLists = new[]
{
"10.168.1.12",
"100.69.7.112",
},
Name = name,
Tags =
{
{ "Created", "TF" },
{ "For", "example" },
},
});
var defaultAccount = new AliCloud.MongoDB.Account("default", 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 default = MongodbFunctions.getZones();
final var index = default_.zones().length() - 1;
final var zoneId = default_.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")
.name(name)
.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.
Constructor 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:
- Account
Name string - The name of the account. Valid values:
root
. - Account
Password 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
to32
characters in length.
- The password must contain at least three of the following character types: uppercase letters, lowercase letters, digits, and special characters. Special characters include
- Instance
Id string - The ID of the instance.
- Account
Description string - The description of the account.
- The description must start with a letter, and cannot start with
http://
orhttps://
. - It must be
2
to256
characters in length, and can contain letters, digits, underscores (_), and hyphens (-).
- The description must start with a letter, and cannot start with
- Account
Name string - The name of the account. Valid values:
root
. - Account
Password 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
to32
characters in length.
- The password must contain at least three of the following character types: uppercase letters, lowercase letters, digits, and special characters. Special characters include
- Instance
Id string - The ID of the instance.
- Account
Description string - The description of the account.
- The description must start with a letter, and cannot start with
http://
orhttps://
. - It must be
2
to256
characters in length, and can contain letters, digits, underscores (_), and hyphens (-).
- The description must start with a letter, and cannot start with
- account
Name String - The name of the account. Valid values:
root
. - account
Password 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
to32
characters in length.
- The password must contain at least three of the following character types: uppercase letters, lowercase letters, digits, and special characters. Special characters include
- instance
Id String - The ID of the instance.
- account
Description String - The description of the account.
- The description must start with a letter, and cannot start with
http://
orhttps://
. - It must be
2
to256
characters in length, and can contain letters, digits, underscores (_), and hyphens (-).
- The description must start with a letter, and cannot start with
- account
Name string - The name of the account. Valid values:
root
. - account
Password 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
to32
characters in length.
- The password must contain at least three of the following character types: uppercase letters, lowercase letters, digits, and special characters. Special characters include
- instance
Id string - The ID of the instance.
- account
Description string - The description of the account.
- The description must start with a letter, and cannot start with
http://
orhttps://
. - It must be
2
to256
characters in length, and can contain letters, digits, underscores (_), and hyphens (-).
- The description must start with a letter, and cannot start with
- 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
to32
characters in length.
- The password must contain at least three of the following character types: uppercase letters, lowercase letters, digits, and special characters. Special characters include
- 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://
orhttps://
. - It must be
2
to256
characters in length, and can contain letters, digits, underscores (_), and hyphens (-).
- The description must start with a letter, and cannot start with
- account
Name String - The name of the account. Valid values:
root
. - account
Password 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
to32
characters in length.
- The password must contain at least three of the following character types: uppercase letters, lowercase letters, digits, and special characters. Special characters include
- instance
Id String - The ID of the instance.
- account
Description String - The description of the account.
- The description must start with a letter, and cannot start with
http://
orhttps://
. - It must be
2
to256
characters in length, and can contain letters, digits, underscores (_), and hyphens (-).
- The description must start with a letter, and cannot start with
Outputs
All input properties are implicitly available as output properties. Additionally, the Account resource produces the following output properties:
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.
- Account
Description string - The description of the account.
- The description must start with a letter, and cannot start with
http://
orhttps://
. - It must be
2
to256
characters in length, and can contain letters, digits, underscores (_), and hyphens (-).
- The description must start with a letter, and cannot start with
- Account
Name string - The name of the account. Valid values:
root
. - Account
Password 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
to32
characters in length.
- The password must contain at least three of the following character types: uppercase letters, lowercase letters, digits, and special characters. Special characters include
- Instance
Id string - The ID of the instance.
- Status string
- The status of the account. Valid values:
Unavailable
,Available
.
- Account
Description string - The description of the account.
- The description must start with a letter, and cannot start with
http://
orhttps://
. - It must be
2
to256
characters in length, and can contain letters, digits, underscores (_), and hyphens (-).
- The description must start with a letter, and cannot start with
- Account
Name string - The name of the account. Valid values:
root
. - Account
Password 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
to32
characters in length.
- The password must contain at least three of the following character types: uppercase letters, lowercase letters, digits, and special characters. Special characters include
- Instance
Id string - The ID of the instance.
- Status string
- The status of the account. Valid values:
Unavailable
,Available
.
- account
Description String - The description of the account.
- The description must start with a letter, and cannot start with
http://
orhttps://
. - It must be
2
to256
characters in length, and can contain letters, digits, underscores (_), and hyphens (-).
- The description must start with a letter, and cannot start with
- account
Name String - The name of the account. Valid values:
root
. - account
Password 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
to32
characters in length.
- The password must contain at least three of the following character types: uppercase letters, lowercase letters, digits, and special characters. Special characters include
- instance
Id String - The ID of the instance.
- status String
- The status of the account. Valid values:
Unavailable
,Available
.
- account
Description string - The description of the account.
- The description must start with a letter, and cannot start with
http://
orhttps://
. - It must be
2
to256
characters in length, and can contain letters, digits, underscores (_), and hyphens (-).
- The description must start with a letter, and cannot start with
- account
Name string - The name of the account. Valid values:
root
. - account
Password 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
to32
characters in length.
- The password must contain at least three of the following character types: uppercase letters, lowercase letters, digits, and special characters. Special characters include
- instance
Id 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://
orhttps://
. - It must be
2
to256
characters in length, and can contain letters, digits, underscores (_), and hyphens (-).
- The description must start with a letter, and cannot start with
- 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
to32
characters in length.
- The password must contain at least three of the following character types: uppercase letters, lowercase letters, digits, and special characters. Special characters include
- instance_
id str - The ID of the instance.
- status str
- The status of the account. Valid values:
Unavailable
,Available
.
- account
Description String - The description of the account.
- The description must start with a letter, and cannot start with
http://
orhttps://
. - It must be
2
to256
characters in length, and can contain letters, digits, underscores (_), and hyphens (-).
- The description must start with a letter, and cannot start with
- account
Name String - The name of the account. Valid values:
root
. - account
Password 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
to32
characters in length.
- The password must contain at least three of the following character types: uppercase letters, lowercase letters, digits, and special characters. Special characters include
- instance
Id 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.