- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我尝试使用 CloudFormation 模板在不同环境中创建 Amazon RDS 实例。 Prod 中有 Multi-AZ 要求,但其他环境不需要 Multi-AZ。这需要 CloudFormation 中的条件函数。
基于RDS CloudFormation docs并使用 if condition in CloudFormation ,以下内容应该在模板中起作用:
Conditions:
IsProd: !Equals [ !Ref EnvironmentType, prod ]
...
Resources:
MyRDSInstance:
Properties:
...
AvailabilityZone:
!If [ IsProd, AWS::NoValue, af-south-1a ]
...
MultiAZ: !If [ IsProd, true, false ]
当IsProd
计算结果为:
AvailabilityZone:af-south-1a
和 MultiAZ:false
AvailabilityZone
is removed和 MultiAZ: true
,满足 docs 中指定的要求:You can't set the AvailabilityZone parameter if the MultiAZ parameter is set to true.
但是,当尝试部署 prod RDS 实例时,在创建堆栈时,我仍然在 CloudFormation 中收到以下错误,从而根本无法创建资源:
Requesting a specific availability zone is not valid for Multi-AZ instances. (Service: AmazonRDS; Status Code: 400; Error Code: InvalidParameterCombination; Request ID: e6177fe4-4a4b-4db3-ba66-5f0e0f7218eb; Proxy: null)
我怀疑这是 AWS 中的一个错误,因为最近在源代码中应用了更改,即使它与 CDK 而不是 CloudFormation 相关:
CloudFormation 现在是否未提供 AWS::NoValue
伪参数?如果这是源代码中的错误,有什么方法可以解决这个问题,以便我仍然可以仅在生产环境中实现多可用区?
最佳答案
因此,我尝试在最后复制相同的内容,但就我而言,我能够成功创建 RDS 资源。我附上我使用的模板供您引用。
AWSTemplateFormatVersion: 2010-09-09
Description: >-
Description": "AWS CloudFormation Sample Template for creating an Amazon RDS DB instance:
Sample template showing how to create a DB instance with Enhanced Monitoring enabled.
**WARNING** This template creates an RDS DB instance. You will be billed for the AWS
resources used if you create a stack from this template.
Parameters:
IsMultiAZ:
Type: String
Default: false
AllowedValues: [true,false]
Description: Please enter either "true" or "false"
DBInstanceID:
Default: mydbinstance
Description: My database instance
Type: String
MinLength: '1'
MaxLength: '63'
AllowedPattern: '[a-zA-Z][a-zA-Z0-9]*'
ConstraintDescription: >-
Must begin with a letter and must not end with a hyphen or contain two
consecutive hyphens.
DBName:
Default: mydb
Description: My database
Type: String
MinLength: '1'
MaxLength: '64'
AllowedPattern: '[a-zA-Z][a-zA-Z0-9]*'
ConstraintDescription: Must begin with a letter and contain only alphanumeric characters.
DBInstanceClass:
Default: db.m5.large
Description: DB instance class
Type: String
ConstraintDescription: Must select a valid DB instance type.
DBAllocatedStorage:
Default: '50'
Description: The size of the database (GiB)
Type: Number
MinValue: '20'
MaxValue: '65536'
ConstraintDescription: must be between 20 and 65536 GiB.
DBUsername:
NoEcho: 'true'
Description: Username for MySQL database access
Type: String
MinLength: '1'
MaxLength: '16'
AllowedPattern: '[a-zA-Z][a-zA-Z0-9]*'
ConstraintDescription: must begin with a letter and contain only alphanumeric characters.
DBPassword:
NoEcho: 'true'
Description: Password MySQL database access
Type: String
MinLength: '8'
MaxLength: '41'
AllowedPattern: '[a-zA-Z0-9]*'
ConstraintDescription: must contain only alphanumeric characters.
Conditions:
CheckIsMultiZone:
!Equals [!Ref IsMultiAZ, true]
Resources:
MyDB:
Type: 'AWS::RDS::DBInstance'
Properties:
DBInstanceIdentifier: !Ref DBInstanceID
DBName: !Ref DBName
DBInstanceClass: !Ref DBInstanceClass
AllocatedStorage: !Ref DBAllocatedStorage
Engine: MySQL
EngineVersion: "8.0.16"
MasterUsername: !Ref DBUsername
MasterUserPassword: !Ref DBPassword
MultiAZ: !Ref IsMultiAZ
AvailabilityZone: !If [CheckIsMultiZone, !Ref AWS::NoValue, "us-east-1a"]
正如你所看到的,我使用了与你相同的概念。您可以在最后测试一下这个模板,看看它是否有效。我在您的模板中发现的一个问题是您正在使用 AWS::NoValue,而正确的格式是 !Ref AWS::NoValue(如我的模板中所示)。我相信这就是您的情况的问题。您可以查看示例here .
关于aws-cloudformation - Amazon CloudFormation 是否规定将 RDS 实例部署到多可用区配置中的不同环境?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72286019/
我需要在每个vagrant up上运行vagrant,这可能吗?例如,此规定仅在第一个 vagrant up 上运行: config.vm.provision "shell", privileged:
我正在将一些 XML 传递给 RESTful Web 服务: Web 服务将解码该 XML,并且我想确保该 XML 有效。 我使用架构来创建 Java 对象,
我有一个 Django 小网站,用户可以在评论中链接到其他网站上的图片。这绝不是核心功能。 我刚刚将整个站点移至 SSL。这在大多数情况下都运行良好,但远程图像显然并不总是可以通过 SSL 获得。只有
如果我要创建一个所有 HTML 内容均由 ReactJS 组件生成的网站,它是否符合 WCAG AA 级标准? IE。屏幕阅读器能够浏览通过 JavaScript 代码呈现的内容吗? 如果答案是肯定的
我使用的是 ubuntu 13.04 机器,我已经正确安装了 vagrant。 以下是版本 Vagrant : Vagrant 1.5.1 虚拟盒子:4.2.10_Ubuntu84101 我正在运行一
我正在为 Vagrant 编写一个配置脚本,以安装部署使用 Meteor 1.6 开发的应用程序所需的所有软件包。到目前为止,脚本运行良好,但在执行过程中的三个点上,我在终端窗口中得到以下红色输出:
我需要简单地从我的 iPhone 应用程序向用户帐户发送一条推文,但是我所看到的内容对于我需要做的事情来说似乎有点繁重,而且我发现的所有内容似乎都有点旧并且我担心我添加的内容可能不符合新的 Twitt
背景 通过 union 讨论类型双关的大多数未定义或实现定义的性质通常引用以下位,这里通过@ecatmur ( https://stackoverflow.com/a/31557852/2757035
我是一名优秀的程序员,十分优秀!