无法使用CloudFormation创建PostgreSQL,但在Web界面上可以正常运行。

huangapple go评论51阅读模式
英文:

Cannot create PostgreSQL with CloudFormation but works with web interface

问题

我正在尝试使用CloudFormation创建一个Serverless V2 Aurora PostgreSQL集群和一个实例。

在使用AWS Web界面时,一切正常,但当使用CloudFormation(通过Serverless)时,我遇到了以下错误:

错误:CREATE_FAILED:auroraCluster(AWS :: RDS :: DBCluster)资源处理程序返回消息:“您请求的引擎模式Serverless目前不可用”。

CloudFormation模板如下:

# 数据库
auroraCluster:
  Type: AWS::RDS::DBCluster
  Properties: 
    AutoMinorVersionUpgrade: 'true'
    AvailabilityZones:
      - eu-north-1a
      - eu-north-1b
      - eu-north-1c
    DatabaseName: publisher
    DeletionProtection: !If [isProd, 'true', 'false']
    Engine: aurora-postgresql
    EngineMode: serverless
    EngineVersion: '14.6'

auroraInstance:
  Type: AWS::RDS::DBInstance
  Properties: 
    AllowMajorVersionUpgrade: !If [isProd, 'true', 'false']
    AutoMinorVersionUpgrade: 'true'
    AvailabilityZone: !Sub ${AWS::Region}a
    DBClusterIdentifier: !Ref auroraCluster
    DBInstanceIdentifier: ${self:service}-rds-${sls:stage}
    DeleteAutomatedBackups: !If [isProd, 'false', 'true']
    DeletionProtection: !If [isProd, 'true', 'false']
    Engine: aurora-postgresql
    ManageMasterUserPassword: 'true'
    MasterUsername: postgres
    MasterUserSecret:
      SecretArn: !Ref secretRds

注意:这段代码是关于创建AWS Aurora PostgreSQL数据库集群和实例的CloudFormation模板,其中使用了Serverless引擎模式。请检查是否已启用Serverless引擎模式以及是否有其他配置问题。

英文:

I'm trying to create a Serverless V2 Aurora PostgreSQL cluster and an instance with CloudFormation.

It works fine when using the AWS web interface but when using CloudFormation (trough Serverless) I get

> Error: CREATE_FAILED: auroraCluster (AWS::RDS::DBCluster) Resource
> handler returned message: "The engine mode serverless you requested is
> currently unavailable
.

CF Template:

# Database
auroraCluster:
  Type: AWS::RDS::DBCluster
  Properties: 
    AutoMinorVersionUpgrade: 'true'
    AvailabilityZones:
      - eu-north-1a
      - eu-north-1b
      - eu-north-1c
    DatabaseName:
      publisher
    DeletionProtection: !If [isProd, 'true', 'false']
    Engine: aurora-postgresql
    EngineMode: serverless
    EngineVersion: '14.6'

auroraInstance:
  Type: AWS::RDS::DBInstance
  Properties: 
    AllowMajorVersionUpgrade: !If [isProd, 'true', 'false']
    AutoMinorVersionUpgrade: 'true'
    AvailabilityZone: !Sub ${AWS::Region}a
    DBClusterIdentifier: !Ref auroraCluster
    DBInstanceIdentifier: ${self:service}-rds-${sls:stage}
    DeleteAutomatedBackups: !If [isProd, 'false', 'true']
    DeletionProtection: !If [isProd, 'true', 'false']
    Engine: aurora-postgresql
    ManageMasterUserPassword: 'true'
    MasterUsername: postgres
    MasterUserSecret:
      SecretArn: !Ref secretRds

答案1

得分: 3

Serverless aurora for PostgreSQL 14.6 仅支持 serverless v2。这需要不同的设置,与您目前的设置不同。例如,您需要提供 ServerlessV2ScalingConfiguration,删除 EngineMode 并将 DBInstanceClass 设置为 db.serverless。例如:

Resources:

    auroraCluster:
        Type: AWS::RDS::DBCluster
        Properties:
            #AutoMinorVersionUpgrade: 'true'
            DatabaseName:
                publisher
            Engine: aurora-postgresql
            EngineVersion: '14.6'
            MasterUsername: "trdyd"
            MasterUserPassword: "gfsdg344231"
            ServerlessV2ScalingConfiguration:
                MinCapacity: 1
                MaxCapacity: 4


    auroraInstance:
        Type: 'AWS::RDS::DBInstance'
        Properties:
            Engine: aurora-postgresql
            DBInstanceClass: db.serverless
            DBClusterIdentifier: !Ref auroraCluster

显然,您需要根据您的实际需求调整上述示例,考虑到 serverless v2 的功能。

英文:

Serverless aurora for postgress 14.6 is only supported for serverless v2. This requires different setup then you have. For example, you have to provide ServerlessV2ScalingConfiguration, delete EngineMode and use DBInstanceClass set to db.serverless. For example:

Resources:

    auroraCluster:
        Type: AWS::RDS::DBCluster
        Properties:
            #AutoMinorVersionUpgrade: 'true'
            DatabaseName:
                publisher
            Engine: aurora-postgresql
            EngineVersion: '14.6'
            MasterUsername: "trdyd"
            MasterUserPassword: "gfsdg344231"
            ServerlessV2ScalingConfiguration:
                MinCapacity: 1
                MaxCapacity: 4


    auroraInstance:
        Type: 'AWS::RDS::DBInstance'
        Properties:
            Engine: aurora-postgresql
            DBInstanceClass: db.serverless
            DBClusterIdentifier: !Ref auroraCluster

Obviously you have to adjust the above example, which works, to what exactly you need, taking into account serverless v2 capabilities.

huangapple
  • 本文由 发表于 2023年2月6日 17:42:29
  • 转载请务必保留本文链接:https://go.coder-hub.com/75359606.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定