使用Troposphere创建Aurora PostgreSQL时IOPS比例错误排查
问题:Troposphere创建Aurora PostgreSQL实例时出现IOPS比例错误
尝试使用Troposphere创建Aurora PostgreSQL实例,代码如下:
self.add_resource( rds.DBInstance( identifier, AllocatedStorage="50", Engine="aurora-postgresql", MasterUsername="myName", DBSubnetGroupName=Ref(subnet_group), MasterUserPassword="myPassword", DBInstanceClass="db.t4g.medium", SourceRegion="eu-west-1" ) )
执行后触发错误:
Invalid iops to storage (GB) ratio for engine name aurora-postgresql and storage type aurora: 0.0000
根据AWS官方文档说明,Amazon Aurora无需配置IOPS,请问为何出现该问题?如何解决?
原因
Troposphere的rds.DBInstance资源默认逻辑中,当指定AllocatedStorage参数时,会自动为非Aurora引擎填充IOPS相关配置,但对于Aurora这类采用自动存储扩容的引擎,手动指定AllocatedStorage会触发底层传入Iops=0的默认值,而AWS API会校验IOPS与存储容量的比例,0值不符合校验规则,因此报错。
解决办法
直接移除代码中的AllocatedStorage="50"参数即可。Aurora采用自动存储扩容机制,不需要手动指定固定存储容量,Troposphere创建Aurora实例时也不需要该参数。
修改后的代码:
self.add_resource( rds.DBInstance( identifier, Engine="aurora-postgresql", MasterUsername="myName", DBSubnetGroupName=Ref(subnet_group), MasterUserPassword="myPassword", DBInstanceClass="db.t4g.medium", SourceRegion="eu-west-1" ) )
补充:AWS官方文档明确说明,Amazon Aurora的存储会根据实际使用量自动扩展,无需手动配置存储容量和IOPS参数,因此创建Aurora实例时不应指定AllocatedStorage和Iops。
内容的提问来源于stack exchange,提问作者prime
相关产品推荐
相关产品推荐

