mongodb / mongodbatlas-cloudformation-resources

MongoDB Atlas CloudFormation Resources: Deploy, update, and manage MongoDB Atlas infrastructure as code through AWS CloudFormation
https://www.mongodb.com/atlas/aws-cloudformation
Apache License 2.0
61 stars 37 forks source link

[Bug]: MongoDB::Atlas::DatabaseUser - drift detection not working - read handler does not return "AWSIAMType" and "Scopes" properties #1233

Open StefanWachter1507 opened 3 days ago

StefanWachter1507 commented 3 days ago

Is there an existing issue for this?

CFN Resource version

v2.1.0

CFN Resource Region

eu-central-1

Current Behavior

CFN drift detection detects a drift:

Screenshot from 2024-11-27 13-20-55

The "AWSIAMType" and "Scopes" properties are missing.

The Read handler of the MongoDB::Atlas::DatabaseUser resource does not process the "Scopes" property. In addition, the condition for copying the "AWSIAMType" property seems to be erronous. Why should that property only be copied, if some default value has been set???

    if currentModel.AWSIAMType != nil {
        currentModel.AWSIAMType = databaseUser.AwsIAMType
    }

CFN template to reproduce the issue

{
      "Type": "MongoDB::Atlas::DatabaseUser",
      "Properties": {
        "AWSIAMType": "ROLE",
        "DatabaseName": "$external",
        "ProjectId": "...",
        "Roles": [
          {
            "DatabaseName": "...",
            "RoleName": "read"
          }
        ],
        "Scopes": [
          {
            "Name": "...",
            "Type": "CLUSTER"
          }
        ],
        "Username": "..."
      }

Steps To Reproduce

Deploy DatabaseUser resource in a stack and execute drift detection on that stack.

Code of Conduct

github-actions[bot] commented 3 days ago

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

The ticket CLOUDP-287006 was created for internal tracking.