A MongoDB Atlas cluster is a schema-less, NoSQL database that is fully managed by MongoDB. Although it is not an AWS-native service, Stacktape seamlessly integrates it into your stacks.
MongoDB Atlas clusters are secure, scalable, and highly available. They have built-in replication and support backups and point-in-time recovery. Each stack that includes a MongoDB Atlas cluster will also create a new MongoDB Atlas project, which ensures isolation between stacks.
Advantages
- Secure: Your data is protected by multiple layers of security.
- Scalable: You can scale your cluster up or down as your needs change.
- Performant: MongoDB Atlas is designed for high performance.
- Backups and point-in-time recovery: You can restore your data to a previous state in case of an accident.
- High availability: Your data is replicated across multiple servers to ensure that it is always available.
- ACID transactions: MongoDB supports multi-document ACID transactions.
Disadvantages
- Separate billing: Although Stacktape integrates with MongoDB Atlas, you will still need to manage your billing separately.
Provider configuration
To use MongoDB Atlas with Stacktape, you will need to:
- Create a MongoDB Atlas account.
- Follow our step-by-step guide to get your
organizationId,publicKey, andprivateKey. - Store your credentials in a secret.
MongoDbAtlasProviderAPI referencepublicKey
Your MongoDB Atlas public API key.
Type: string
Create API keys in the MongoDB Atlas console under Organization Settings > API Keys.
privateKey
Your MongoDB Atlas private API key. Store as $Secret() for security.
Type: string
Create API keys in the MongoDB Atlas console under Organization Settings > API Keys.
organizationId
Your MongoDB Atlas Organization ID.
Type: string
Found in the MongoDB Atlas console under Organization Settings.
accessibility
Network connectivity settings for all MongoDB Atlas clusters in this stack.
Type: MongoDbAtlasAccessibility
Stacktape auto-creates a MongoDB Atlas Project for your clusters. These accessibility settings apply at the project level — all clusters in the stack share the same network config.
Basic usage
Cluster tier
The cluster tier determines the resources (memory, storage, IOPS) for each data-bearing node in your cluster. To learn more, see the MongoDB Atlas documentation.
Disk size
Each cluster tier comes with a default amount of storage. All M10+ clusters automatically scale their storage, but you can disable this behavior. You can also customize the storage capacity for all M10+ clusters.
Auto-scaling
Scales up when CPU or memory exceeds 75% for 1 hour. Scales down when both are below 50% for 24 hours.
MongoDbAutoScalingAPI referenceParent:MongoDbAtlasClusterminClusterTier
Lowest tier the cluster can scale down to. Prevents unexpected cost increases from always scaling up.
Type: string ENUM
Possible values: M10M100M140M20M200M200 Low-CPU (R200)M200_NVMEM30M300M300 Low-CPU (R300)M40M40 Low-CPU (R40)M400 Low-CPU (R400)M400_NVMEM40_NVMEM50M50 Low-CPU (R50)M50_NVMEM60M60 Low-CPU (R60)M60_NVMEM700 Low-CPU (R700)M80M80 Low-CPU (R80)M80_NVME
maxClusterTier
Highest tier the cluster can scale up to. Set a ceiling to control maximum costs.
Type: string ENUM
Possible values: M10M100M140M20M200M200 Low-CPU (R200)M200_NVMEM30M300M300 Low-CPU (R300)M40M40 Low-CPU (R40)M400 Low-CPU (R400)M400_NVMEM40_NVMEM50M50 Low-CPU (R50)M50_NVMEM60M60 Low-CPU (R60)M60_NVMEM700 Low-CPU (R700)M80M80 Low-CPU (R80)M80_NVME
disableDiskScaling
Prevent automatic disk expansion. By default, storage grows when usage hits 90%. Storage never scales down.
Type: boolean
disableScaleDown
Prevent automatic scale-down. The cluster can only scale up, never back down to a smaller tier.
Type: boolean
Sharding
Number of shards. More than 1 enables sharded mode for horizontal scaling. Requires M30+.
Backups
Enable daily snapshots (18:00 UTC). M10+ only — M2/M5 get automatic snapshots with different rules.
There are different types of snapshots with different retention periods and frequencies:
- Hourly: Every 6 hours, retained for 2 days.
- Daily: Every day, retained for 7 days.
- Weekly: Every Saturday, retained for 4 weeks.
- Monthly: Last day of the month, retained for 12 months.
Point-in-time recovery
Restore to any second within the last 7 days. Requires enableBackups: true and M10+.
Accessing clusters from workloads
You can grant a compute resource permission to access a cluster by listing it in the resource's connectTo property. This will inject the necessary credentials into the resource.
Accessibility
You can restrict access to your cluster to specific resources or IP addresses. Unlike other database resources, accessibility is set globally in the provider configuration, not on the resource itself. This means that all clusters in a given stack will have the same accessibility mode.
Shared cluster tiers (M2 and M5) only support internet accessibility mode.
MongoDbAtlasAccessibilityAPI referenceParent:MongoDbAtlasProvideraccessibilityModeDefault: internetRequired
Network access mode.
Type: string ENUM
Possible values: internetscoping-workloads-in-vpcvpcwhitelisted-ips-only
internet: Accessible from anywhere (credentials still required).vpc: Only from resources in your VPC + anywhitelistedIps.scoping-workloads-in-vpc: Likevpc, but also requires security-group access viaconnectTo.whitelisted-ips-only: Only from IP addresses listed inwhitelistedIps.
whitelistedIps
IP addresses or CIDR ranges allowed to access the cluster (e.g., your office IP).
Type: Array of string
No effect in internet mode. In vpc/scoping-workloads-in-vpc, adds access for IPs outside the VPC.
In whitelisted-ips-only, these are the only IPs that can connect.
Internet mode
This is the default and least restrictive mode. The cluster can be accessed from anywhere on the internet. However, your cluster is still protected by IAM permissions.
VPC mode
In addition to IAM permissions, the cluster is also protected at the network level. This means that only resources within your stack's default VPC can access the cluster. Any IP addresses in the whitelistedIps list can also access the cluster. Traffic between your stack's resources and the cluster never leaves the AWS network, which is more secure and can be cheaper.
Scoped VPC mode
This mode is similar to VPC mode, but even more restrictive. In this mode, the connectTo property not only grants IAM permissions, but also grants access at the network level.
Whitelisted IPs only mode
The cluster can only be accessed from the IP addresses and CIDR blocks in the whitelistedIps list.
Admin user
Not required for app-to-database access via connectTo — that's handled automatically.
MongoDbAdminUserCredentialsAPI referenceParent:MongoDbAtlasClusteruserNameRequired
Name of the admin user
Type: string
passwordRequired
Password for the admin user
Type: string
Business Intelligence Connector for SQL
The MongoDB Connector for BI allows you to use SQL to query your MongoDB data with tools like Tableau, Power BI, and Excel.
MongoDbBiConnectorAPI referenceParent:MongoDbAtlasClusterenabledRequired
Enable the BI Connector for SQL-based access.
Type: boolean
readPreference
Which node type the BI Connector reads from. Use analytics to avoid impacting production queries.
Type: string ENUM
Possible values: analyticsprimarysecondary
Referenceable parameters
The following parameters can be easily referenced using $ResourceParam directive directive.
To learn more about referencing parameters, refer to referencing parameters.
Connection string (URL) that allows connecting to the cluster.
- Usage:
$ResourceParam('<<resource-name>>', 'connectionString')
Pricing
You are charged for:
- Cluster tier: Starting at $8.60/month for an M2 shared cluster.
- Data transfer: For most customers, data transfer fees are less than 10% of their bill. There are no data transfer fees for M0, M2, and M5 clusters.
For a more detailed overview, see the MongoDB documentation.
API reference
MongoDbReplicationAPI referenceParent:MongoDbAtlasClusternumAnalyticsNodes
Read-only nodes for long-running analytics queries. Prevents impact on primary workload performance.
Type: number
numElectableNodesDefault: 3
Nodes that can become primary. More = better redundancy. Must be odd.
Type: number ENUM
Possible values: 357
numReadOnlyNodes
Read-only replica nodes for scaling read throughput.
Type: number
MongoDbAtlasClusterAPI referencetypeRequired
Type: string "mongo-db-atlas-cluster"
properties.clusterTierRequired
Instance size. M2/M5 = shared (cheapest). M10+ = dedicated (more features, auto-scaling, backups).
Type: string ENUM
Possible values: M10M100M140M2M20M200M200 Low-CPU (R200)M200_NVMEM30M300M300 Low-CPU (R300)M40M40 Low-CPU (R40)M400M400 Low-CPU (R400)M400_NVMEM40_NVMEM5M50M50 Low-CPU (R50)M50_NVMEM60M60 Low-CPU (R60)M60_NVMEM700M700 Low-CPU (R700)M80M80 Low-CPU (R80)M80_NVME
properties.diskSizeGB
Disk size in GB. Not available for shared tiers (M2/M5). M10+ auto-scales storage by default.
Type: number
properties.versionDefault: 7.0
MongoDB engine version.
Type: string ENUM
Possible values: 5.06.07.0
properties.numShardsDefault: 1
Number of shards. More than 1 enables sharded mode for horizontal scaling. Requires M30+.
Type: number
properties.replication
Node count configuration: electable, read-only, and analytics nodes. Default: 3 electable nodes.
Type: MongoDbReplication
properties.enableBackups
Enable daily snapshots (18:00 UTC). M10+ only — M2/M5 get automatic snapshots with different rules.
Type: boolean
properties.enablePointInTimeRecovery
Restore to any second within the last 7 days. Requires enableBackups: true and M10+.
Type: boolean
properties.biConnector
BI Connector for SQL-based access to MongoDB data. CPU-intensive — may degrade M10/M20 performance.
Type: MongoDbBiConnector
properties.autoScaling
Auto-scale tier and/or storage based on CPU/memory usage. Set min/max tier to control costs.
Type: MongoDbAutoScaling
Scales up when CPU or memory exceeds 75% for 1 hour. Scales down when both are below 50% for 24 hours.
properties.adminUserCredentials
Admin user for direct database access (e.g., from your local machine or admin tools).
Type: MongoDbAdminUserCredentials
Not required for app-to-database access via connectTo — that's handled automatically.