pulumi / pulumi-mongodbatlas

A MongoDB Atlas Pulumi resource package, providing multi-language access to MongoDB Atlas
Apache License 2.0
16 stars 5 forks source link

400 (request "INVALID_ENUM_VALUE") An invalid enumeration value M0 was specified #227

Closed alejo-novolabs closed 1 year ago

alejo-novolabs commented 1 year ago

What happened?

Hi, Im trying to create a Cluster through @pulumi/mongodbatlas but I'm facing the INVALID_ENUM_VALUE. The value i'm trying to use is "M0"

Expected Behavior

It should create a cluster within a given Organization and Project

Steps to reproduce

Running the following code:

index.ts

import { LocalWorkspace } from "@pulumi/pulumi/automation";
import { createMongoCluster } from "./create_mongo_cluster";

export async function setUpStack() {
    const pulumiProgram = async () => {
        createMongoCluster("my-project")

        return
    }

    const stack = await LocalWorkspace.createOrSelectStack({
        stackName: "mongodb-test-stack",
        projectName: "mongodb-test-project",
        program: pulumiProgram
    })

    await stack.up(({ onOutput: console.info }))
}

setUpStack()

create_mongo_cluster.ts

import * as pulumi from "@pulumi/pulumi";
import * as mongodb from "@pulumi/mongodbatlas";

export async function createMongoCluster(projectName: string) {
    const atlasProvider = new mongodb.Provider("mongodbProvider", {
        privateKey: "XXXX-XXXX",
        publicKey: "YYYY-YYYY"
    });
    const atlasProject = new mongodb.Project("test", { orgId: "my-org-id" }, { provider: atlasProvider })
    const atlasUsername = "admin"
    const atlasPassword = "Pass1234"

    const atlasCluster = new mongodb.Cluster("my-atlas-cluster", {
        projectId: atlasProject.id,
        providerName: "AWS",
        providerRegionName: "EU_WEST_3",
        providerInstanceSizeName: "M0",
        mongoDbMajorVersion: "4.2",
        numShards: 1,
        cloudBackup: false,
        autoScalingDiskGbEnabled: false,
        clusterType: "REPLICASET"

  }, { provider: atlasProvider, dependsOn: atlasProject });

    }
### Enviroment

- Node version: 14.18.1
- OS: Ubutu 20.04

Output of pulumi about

CLI
Version 3.68.0 Go Version go1.20.4 Go Compiler gc

Host
OS ubuntu Version 20.04 Arch x86_64

Backend
Name pulumi.com

Additional context

No response

Contributing

Vote on this issue by adding a 👍 reaction. To contribute a fix for this issue, leave a comment (and link to your pull request, if you've opened one already).

guineveresaenger commented 1 year ago

Hi @alejo-novolabs - thank you for filing this issue.

Is it possible that you are misconfiguring some of the capabilities of an M0 cluster? https://www.mongodb.com/docs/atlas/reference/free-shared-limitations/#std-label-atlas-free-tier You may also need to use the providerName: "TENANT" and backing_provider_name fields: https://github.com/mongodb/terraform-provider-mongodbatlas/issues/675

alejo-novolabs commented 1 year ago

Hi @guineveresaenger !

In deed, I was misconfiguring the metioned capabilities of an M0 Cluster. I also changed the providerName: TENANT and added the backingProviderName

Here is my final configuration:

{
        projectId: atlasProject.id,
        providerName: "TENANT",
        backingProviderName: "AWS",
        providerRegionName: "EU_WEST_3",
        clusterType: "REPLICASET",
        providerInstanceSizeName: "M0",
}

Thanks a lot!

guineveresaenger commented 1 year ago

Yay! I'm glad it's working for you now.

Closing this issue as resolved.