この記事は公開されてから1年以上経過しています。情報が古い可能性がありますので、ご注意ください。
困っていた内容
Aurora MySQL のクラスタを作成するために、CloudFormation のテンプレートを作成し、スタックのデプロイを実行しましたが、下記のエラーにより失敗してしまいます。
The parameter AllocatedStorage must be provided and must not be null.
エラーメッセージを見ると、クラスタの Aurora インスタンスに AllocatedStorage が指定されていないためにエラーとなっているようなのですが、 ドキュメントによると Aurora では AllocatedStorage は not applicable と記載されています。 この項目を追加してスタックをデプロイしてみたのですが、別の箇所でエラーが発生してしまいます。
テンプレートをどのように修正すればよいでしょうか?
Resources:
AuroraDBCluster:
Type: AWS::RDS::DBCluster
Properties:
DBClusterIdentifier: "aurora-cluster"
PreferredBackupWindow: "17:00-17:30"
PreferredMaintenanceWindow: "sun:18:00-sun:18:30"
EngineVersion: "8.0.mysql_aurora.3.02.0"
MasterUsername: "mymasteruser"
MasterUserPassword: "xxxxx"
DBSubnetGroupName: "rds-subnet-xxx"
VpcSecurityGroupIds:
- "sg-xxxxx"
...
AuroraDBInstance:
Type: AWS::RDS::DBInstance
Properties:
PreferredBackupWindow: "17:00-17:30"
PreferredMaintenanceWindow: "sun:18:00-sun:18:30"
EngineVersion: "8.0.mysql_aurora.3.02.0"
MasterUsername: "mymasteruser"
MasterUserPassword: "xxxxx"
DBSubnetGroupName: "rds-subnet-xxx"
VpcSecurityGroupIds:
- "sg-xxxxx"
...
どう対応すればいいの?
上記テンプレートの AuroraDBInstance に「DBClusterIdentifier」の項目を追加してください。
AuroraDBInstance:
Type: AWS::RDS::DBInstance
Properties:
DBClusterIdentifier: !Ref 'AuroraDBCluster'
下記の項目は、AuroraDBCluster 側の値が使用されますので、重複している AuroraDBInstance 側の項目は削除してください。
PreferredBackupWindow
AvailabilityZone
PreferredMaintenanceWindow
EngineVersion
MasterUsername
MasterUserPassword
DBSubnetGroupName
VPCSecurityGroups
以上の内容で、テンプレートを修正して、エラーが解消されるかご確認ください。
参考資料
[1] AWS CloudFormation での Amazon Aurora リソースの作成 - Amazon Aurora
[2] Amazon Relational Database Service resource type reference - AWS CloudFormation
[3] AWS での Amazon Aurora MySQL データベース – クイックスタート
[4] Best practices to deploy Amazon Aurora databases with AWS CloudFormation | AWS Database Blog