Cloudformation generating RDS username and password?

0

I'm using Cloudformation to build out a stack that includes a Postgres RDS instance, defined in the code snippet below. What I have found is that the values I've specified in parameters for DatabaseUser and DatabasePassword are ultimately not the values being used. Browsing to RDS in the AWS console, I can see that the DatabaseUser seems to be a randomly generated string (rather than postgres as I've specified in parameters), and the password is not visible, but my attempts to connect to the RDS instance fail: FATAL: password authentication failed for user "<random string>". I assume the password has also been generated, rather than using the value I've configured in the parameter.

I appreciate there are more secure ways of authenticating (I'm now reading about SecretsManager), but I'm a beginner - one step at a time. Figuring out and adding SecretsManager here is a lot of overhead for me. Right now my RDS instance is on a private subnet and I'm having to connect using SSM Agent and port forwarding, I figure that's secure enough for a start.

Is it not possible to set DB user/pw using parameters in my Cloudformation configs?

This is somewhat important for me since I'm working on some further automation. Even if I do get this working, will the password eventually be rotated anyway? Would SecretsManager be the only reliable way for me to be able to automate connections to my RDS instance?

"Database": {
      "Type": "AWS::RDS::DBInstance",
      "DeletionPolicy": "Delete",
      "Properties": {
        "Engine"             : "postgres",
        "DBName"             : { "Fn::Join": [ "", { "Fn::Split": [ "-", { "Ref": "ApplicationName" } ]} ] },
        "DBInstanceClass"    : { "Ref": "DBInstanceType" },
        "DBSubnetGroupName"  : { "Ref": "DBSubnetGroup" },
        "StorageType"        : { "Ref": "DBStorageType" },
        "AllocatedStorage"   : { "Ref": "DBAllocatedStorage" },
        "MasterUsername"     : { "Ref": "DatabaseUser" },
        "MasterUserPassword" : { "Ref": "DatabasePassword" },
        "VPCSecurityGroups"  : [
          { "Ref": "DBSecurityGroup" }
        ]
      }
    }
1개 답변
1
수락된 답변

Hi,

I would recommend, as you hinted, to secure your password with Secret Managers.

This article contains a Cloudformation example which can inspire you: https://aws.amazon.com/blogs/mt/four-ways-to-retrieve-any-aws-service-property-using-aws-cloudformation-part-3-of-3/

Hope it helps ;)

profile picture
전문가
답변함 일 년 전
profile pictureAWS
전문가
검토됨 일 년 전

로그인하지 않았습니다. 로그인해야 답변을 게시할 수 있습니다.

좋은 답변은 질문에 명확하게 답하고 건설적인 피드백을 제공하며 질문자의 전문적인 성장을 장려합니다.

질문 답변하기에 대한 가이드라인

관련 콘텐츠