mongodb / awscdk-resources-mongodbatlas

MongoDB Atlas AWS CDK Resources
Apache License 2.0
33 stars 15 forks source link

Need ability to create the default CfnCloudBackupSchedule when creating a cluster #285

Open lockenj opened 4 weeks ago

lockenj commented 4 weeks ago

Is your feature request related to a problem? Please describe.

I am loving this CDK but am constantly having the problem of trying to understand what the possible values of properties are. This tells me I am not looking in the right place.

The latest example is I am trying to setup a Backup Policy with a single Item like below:

this.#_cloudBackupSchedule = new CfnCloudBackupSchedule(this, 'CloudBackupSchedule', {
      profile: this.#_secretName,
      projectId: this.#_atlasProjectId,
      clusterName: this.#_clusterName,

      autoExportEnabled: false,

      policies: [
        {
          policyItems: [
            {
              retentionUnit: 'Days',
              retentionValue: 7,
              frequencyType: 'Daily',
              frequencyInterval: undefined,
            }
          ]
        }
      ]
    });

Error I am seeing with this:

error: All values from PolicyItem should be set when `PolicyItems` is set"

Describe the solution you'd like I'd love to know where to look to find what are the possible values of each prop and any properties that depend on each other (in the cases where if you set propX to blah then you also must set props Y and Z).

Describe alternatives you've considered Thoroughly explored:

  1. https://constructs.dev/packages/awscdk-resources-mongodbatlas/v/3.5.2?lang=typescript
  2. https://github.com/mongodb/awscdk-resources-mongodbatlas
  3. https://github.com/mongodb/mongodbatlas-cloudformation-resources

Could not find anything in the examples or code that show possible prop values or description of prop dependencies.

github-actions[bot] commented 4 weeks ago

Thanks for opening this issue! Please make sure to provide the following information to help us reproduce the issue:

Thanks for opening this issue. The ticket CLOUDP-251736 was created for internal tracking.

lockenj commented 4 weeks ago

After adding a id property of value 1 to the policy item...

The CDK under the covers appears to be doing a PATCH, which makes me believe the policies are already created... How do I set the backup policy to do just a once a day backup that is retained for 7 days?

PATCH error:

Resource handler returned message: "https://cloud.mongodb.com/api/atlas/v2/groups/65c7a364ba5030155d686ffa/clusters/core-environment-manual-test/backup/schedule PATCH: HTTP 400 Bad Request (Error code
: "INVALID_JSON_ATTRIBUTE") Detail: Received JSON for the policies.java.util.ArrayList[0].id attribute does not match expected format. Reason: Bad Request. Params: [policies.java.util.ArrayList[0].id]
lockenj commented 4 weeks ago

Looks like I am not the only one stumbling through this....

For others take a look at this

https://www.mongodb.com/community/forums/t/policy-id-wrongly-described-in-docs/211687/5

lockenj commented 4 weeks ago

Without the ability to retrieve the default PolicyIDs via the CDK I dont see how we can handle defining the backup policy upon creation this has to be some manual process after creation are some programatic change outside of the CDK.

maastha commented 3 weeks ago

Hi @lockenj

Thanks a lot for creating this issue!

Below are some examples in our repository for using this construct:

Additionally, to unblock you for now, please refer below API to fetch the policy ID: https://www.mongodb.com/docs/atlas/reference/api-resources-spec/v2/#tag/Cloud-Backups/operation/getBackupSchedule

Please let us know if you come across any issues.

In the meantime, we are looking into a fix for this issue.