タダです.
Terraform で Aurora のインスタンスタイプを変更しようとした時に terraform apply
は成功しているが,Aurora のインスタンスタイプが変更されてなかった場面に遭遇したので対処をまとめておきます.
事象概要
Aurora MySQL 5.7 の環境で db.t4g.medium
で CPU クレジットを使い切り CPU 負荷が高騰する事象が発生してたため,取り急ぎインスタンスタイプを上げるようにしました.その際に db.r6g.large
に terraform apply
で変更したところ処理は成功したが,インスタンスタイプが変わらなかったという状態になりました.Aurora の画面で確認したところ保留中の変更で止まっており,今すぐの反映ができていないことがわかりました.
terraform apply 実行結果抜粋
Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols: ~ update in-place Terraform will perform the following actions: # aws_rds_cluster_instance.aurora_cluster_instance[0] will be updated in-place ~ resource "aws_rds_cluster_instance" "aurora_cluster_instance" { id = "hoge" ~ instance_class = "db.t4g.medium" -> "db.r6g.large" tags = {} # (26 unchanged attributes hidden) } Do you want to perform these actions? Terraform will perform the actions described above. Only 'yes' will be accepted to approve. Enter a value: yes aws_rds_cluster_instance.aurora_cluster_instance[0]: Modifying... [id=hoge aws_rds_cluster_instance.aurora_cluster_instance[0]: Still modifying... [id=hoge, 10s elapsed] aws_rds_cluster_instance.aurora_cluster_instance[0]: Still modifying... [id=hoge, 20s elapsed] aws_rds_cluster_instance.aurora_cluster_instance[0]: Still modifying... [id=hoge, 30s elapsed] aws_rds_cluster_instance.aurora_cluster_instance[0]: Modifications complete after 31s [id=hoge] Releasing state lock. This may take a few moments... Apply complete! Resources: 0 added, 1 changed, 0 destroyed.
保留中の変更画面
本事象の対応まとめ
今すぐ反映したかったので,GUI からもできますが,AWS CLI でインスタンスタイプの変更を行いました.AWS CLI ですと,下記のコマンドになります.実行後,インスタンスタイプの変更は行われ保留中の変更の表示も消えました.
aws rds modify-db-instance \ --db-instance-identifier [変更したい Aurora インスタンス名] \ --db-instance-class db.r6g.large \ --apply-immediately
関連情報
まとめ
簡単にはなりますが,Aurora のインスタンスタイプを変更しようとした時にインスタンスタイプが変更されなかった事象のまとめと対応をまとめました.あとになって調べたら aws_rds_cluster_instance
に apply_immediately
オプションが有るのを知りこれを使えば即時反映いけました.すぐに適用したい場合は明示的に指定すると良さそうです.