【问题标题】:RDS Proxy Target groups UnavailableRDS 代理目标组不可用
【发布时间】:2021-02-19 03:18:16
【问题描述】:

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

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

这是我的 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

【问题讨论】:

  • IAM 角色呢?它们没有显示出来。
  • 对于 rds 代理?它也可以访问所有秘密管理器值。先生,我正在打电话

标签: amazon-web-services amazon-cloudformation amazon-rds amazon-rds-proxy


【解决方案1】:

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

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

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

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

【讨论】:

    【解决方案2】:

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

    您的数据库使用:

        MasterUsername: postgres
        MasterUserPassword: Fighting001
    

    但是你的DBSecretsManager 是:

    SecretString: 
         'password'
    

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

    【讨论】:

    • 我刚刚看到了。看起来是为什么。谢谢你。我稍后会更新
    • @ThanhLongLê 没问题。如果您以后发现答案有帮助,我们将不胜感激。
    • 第二次更新,sr 我忘了写我需要将 SecretString 转换为 JSON 类型字符串 SecretString: '{"username":"yourdbusername","password":"password"}' 记住这是 JSON 类型字符串
    猜你喜欢
    • 2021-09-18
    • 1970-01-01
    • 2021-03-12
    • 1970-01-01
    • 2014-03-21
    • 2021-10-05
    • 1970-01-01
    • 2021-08-05
    • 1970-01-01
    相关资源
    最近更新 更多