1

我刚刚通过 Cloud Formation 创建了 RDS 代理

在代理仪表板中,它显示 RDS 代理可用,但目标组不可用,我无法调试并陷入 Cloud Formation 更新状态

这是我的云形成配置,

我为 rds 代理和 rds 实例使用了所有入站流量安全组,但它似乎不起作用......

那我有什么错误的配置吗?我整天都在坚持这个

RDSInstance:
  DependsOn: DBSecurityGroup
  Type: AWS::RDS::DBInstance
  Properties: 
    AllocatedStorage: '20'
    AllowMajorVersionUpgrade: false
    AutoMinorVersionUpgrade: true
    AvailabilityZone: ${self:provider.region}a
    DBInstanceClass: db.t2.micro
    DBName: mydb
    VPCSecurityGroups: 
      - "Fn::GetAtt": [ DBSecurityGroup, GroupId ]
    Engine: postgres
    EngineVersion: '11.9'
    MasterUsername: postgres
    MasterUserPassword: Fighting001
    PubliclyAccessible: true
    DBSubnetGroupName: 
      Ref: DBSubnetGroup
    # VPCSecurityGroups: 
    #   Ref: VPC
DBSecretsManager:
  Type: AWS::SecretsManager::Secret
  Properties: 
    Description: 'Secret Store for database connection'
    Name: postgres
    SecretString: 
      'password'
RDSProxy:
  DependsOn: DBSecurityGroup
  Type: AWS::RDS::DBProxy
  Properties: 
    Auth: 
      - AuthScheme: SECRETS
        SecretArn: 
          Ref: DBSecretsManager
        IAMAuth: DISABLED
    DBProxyName: ${self:provider.stackName}-db-proxy
    DebugLogging: true
    EngineFamily: 'POSTGRESQL'
    RoleArn: 'my role arn'
    VpcSecurityGroupIds: 
    - "Fn::GetAtt": [ DBSecurityGroup, GroupId ]
    VpcSubnetIds: 
      - Ref: PublicSubnetA
      - Ref: PublicSubnetB
RDSProxyTargetGroup:
  Type: AWS::RDS::DBProxyTargetGroup
  Properties:
    DBProxyName: 
      Ref: RDSProxy
    DBInstanceIdentifiers: [Ref: RDSInstance]
    TargetGroupName: "default"
    ConnectionPoolConfigurationInfo:
        MaxConnectionsPercent: 45
        MaxIdleConnectionsPercent: 40
        ConnectionBorrowTimeout: 120
4

2 回答 2

4

您的模板失败的一个可能原因是您的模板AWS::SecretsManager::Secret未被使用且值不正确。

您的数据库使用:

    MasterUsername: postgres
    MasterUserPassword: Fighting001

但你的DBSecretsManager是:

SecretString: 
     'password'

这是不正确的。我建议首先在 AWS 控制台中手动设置所有内容。然后,您可以检查您的用例的正确形式是什么SecretString

于 2020-11-06T11:55:36.927 回答
0

虽然这不是上述原始问题的原因,但它可能会帮助将来到达此帖子的人。

确保您的 RDS 实例和与之关联的安全组使用相同的端口。

我遇到了同样的结果,因为我的 RDS 安全组是使用与 RDS 实例不同的端口配置的。

默认情况下,Aurora Postgres 将使用 port 3306,但是我的安全组正在使用5432(因为它是从旧的 Postgres 非 Aurora RDS 实例复制的)。5432我通过指定Port解决此问题的属性更新了我的 RDS 实例以使用端口。

于 2021-05-18T11:00:13.563 回答