1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Aurora PostgreSQL の「エクスプレス設定」が CloudFormation に来たので、そもそも何なのかから試してみた

1
Posted at

はじめに

Aurora PostgreSQL のエクスプレス設定(express configuration)を、CloudFormation のテンプレートから使えるようになりました。

フル設定とエクスプレス設定の比較

エクスプレス設定は、2026 年 3 月に出た Aurora PostgreSQL の作り方の 1 つで、簡単にいうと最初から決まっている「おまかせコース」のようなものです。Create with express configuration によると、次のようなものが 1 回の呼び出しでそろいます。

  • Aurora Serverless のライターインスタンス(負荷に応じて性能が自動で増減するインスタンス)
  • VPC の外から PostgreSQL で接続できる入口(internet access gateway)
  • 管理ユーザー postgres の IAM 認証(パスワードの代わりに、15 分だけ使えるトークンで入る方式)

今回のアップデートで、次のことができるようになりました。

  • AWS::RDS::DBCluster に WithExpressConfiguration: true を書くだけで、エクスプレス設定のクラスターを作れる
  • ライターインスタンスは RDS が作るので、テンプレートには DBCluster だけ書けばよい
  • スタックを消すと、テンプレートに書いていないライターインスタンスもいっしょに消える

ECS の Express Mode と同じイメージ?

ECS にも、コンテナイメージを渡すだけでロードバランサーまで作ってくれる Express Mode があります。

発想はほぼ似た感じと思っていただければよさそうです。

なお、ECS は VPC の中に作ってインターネット向けの ALB を付けますが、Aurora のエクスプレス設定は既定で VPC の外に作り、IAM 認証だけで入れる入口を付けます。試作のうちは踏み台も VPN もいらず、本番に近づいたら VPC へ移す という使い方を想定しているようです。

何がうれしいのか

  • 試作用の DB を、サブネットグループもセキュリティグループも認証情報の設定も書かずにテンプレートで作って消せる
  • 0 ACU まで下がる設定で作られるので、使っていない間は自動で一時停止し、インスタンスの料金がかからない

やってみた

手順 0: リージョンと psql を用意する

export AWS_REGION=ap-northeast-1

brew install libpq
export PATH="$(brew --prefix libpq)/bin:$PATH"
psql --version

手順 1: テンプレートを書いてスタックを作る

テンプレートは AWS::RDS::DBCluster のリファレンス のサンプルをもとにしています。え、これだけ?とちょっとびっくりしますね。

cat > express.yaml <<'EOF'
AWSTemplateFormatVersion: 2010-09-09
Resources:
  ExpressCluster:
    Type: AWS::RDS::DBCluster
    DeletionPolicy: Delete
    Properties:
      Engine: aurora-postgresql
      DBClusterIdentifier: express-cfn-demo
      WithExpressConfiguration: true
      Tags:
        - Key: CreatedWith
          Value: ExpressConfiguration
Outputs:
  Endpoint:
    Value: !GetAtt ExpressCluster.Endpoint.Address
EOF

time aws cloudformation deploy --stack-name express-cfn-demo --template-file express.yaml
Waiting for changeset to be created..
Waiting for stack create/update to complete
Successfully created/updated stack - express-cfn-demo
aws cloudformation deploy ...  0.26s user 0.09s system 0% cpu 36.269 total

手順 2: スタックの中身とクラスターを見比べる

スタックが管理しているリソースと、実際に RDS にできたものを比べます。

aws cloudformation describe-stack-resources --stack-name express-cfn-demo \
  --query 'StackResources[].[LogicalResourceId,ResourceType]' --output text

aws rds describe-db-clusters --db-cluster-identifier express-cfn-demo \
  --query 'DBClusters[0].{Instances:DBClusterMembers[].DBInstanceIdentifier,Gateway:InternetAccessGatewayEnabled,VPC:VPCNetworkingEnabled,Capacity:ServerlessV2ScalingConfiguration,Version:EngineVersion}'
ExpressCluster	AWS::RDS::DBCluster
{
    "Instances": [
        "express-cfn-demo-instance-1"
    ],
    "Gateway": true,
    "VPC": false,
    "Capacity": {
        "MinCapacity": 0.0,
        "MaxCapacity": 16.0,
        "SecondsUntilAutoPause": 300
    },
    "Version": "17.9"
}

CloudFormation のリソースタブ

RDS のデータベース一覧

CloudFormation のリソースは DBCluster の 1 つだけですが、RDS の一覧ではライターインスタンス express-cfn-demo-instance-1 までできています。

インスタンスクラスやフェイルオーバーの優先順位(PromotionTier)など、インスタンス単位の設定をテンプレートで管理したくなったら、AWS::RDS::DBInstance としてスタックにインポートする必要があります。

手順 3: 手元の psql から接続する

コンソールのクラスター詳細の「接続とセキュリティ」タブに、psql のコードスニペットが出ています。

接続とセキュリティタブ

internet access gateway と IAM 認証が「有効」になっており、接続する IAM ユーザーやロールに rds-db:connect の権限があれば、手元から入れます。

RDSHOST=$(aws cloudformation describe-stacks --stack-name express-cfn-demo \
  --query "Stacks[0].Outputs[?OutputKey=='Endpoint'].OutputValue" --output text)

psql "host=$RDSHOST port=5432 dbname=postgres user=postgres sslmode=require password=$(aws rds generate-db-auth-token --hostname $RDSHOST --port 5432 --username postgres)" \
  -c "select version();"
 PostgreSQL 17.9 on aarch64-unknown-linux-gnu, compiled by aarch64-unknown-linux-gnu-gcc (GCC) 10.5.0, 64-bit
(1 row)

パスワードの代わりに generate-db-auth-token で作ったトークンを渡しています。

VPC もセキュリティグループも用意していないのに、手元の Mac からそのまま入れました。

後片付け

スタックを消すと、管理外のライターインスタンスもいっしょに消えることを確認しましょう。

rm express.yaml

aws cloudformation delete-stack --stack-name express-cfn-demo
time aws cloudformation wait stack-delete-complete --stack-name express-cfn-demo

aws rds describe-db-instances \
  --query 'DBInstances[?DBClusterIdentifier==`express-cfn-demo`].DBInstanceIdentifier'

aws rds describe-db-cluster-snapshots --snapshot-type manual \
  --query 'DBClusterSnapshots[?DBClusterIdentifier==`express-cfn-demo`].DBClusterSnapshotIdentifier'
aws cloudformation wait stack-delete-complete ...  0.34s user 0.21s system 0% cpu 6:02.28 total
[]
[]

注意点

Tags を書かないと、スタック作成が (Service: Rds, Status Code: 500 ...) で失敗しました(2026-11-28、東京で確認)。

CLI の create-db-cluster --with-express-configuration はタグなしでも通るので、CloudFormation 経由のときだけかもしれません。

  • テンプレートでは VPC 内に作れない: VPC 用のプロパティがないので、VPC に入れたいときは作成後に modify-db-cluster で移します
  • 暗号化キーとエンジンバージョンは選べない: カスタマー管理の KMS キーや特定のバージョンが要るなら、フル設定で書きます
  • WithExpressConfiguration は後から変えられない: 変えたり消したりすると作り直しになるので、エクスプレス設定をやめる用途には使えません

まとめ

  • エクスプレス設定は、Aurora PostgreSQL を「おまかせ」の設定で数十秒で作る方法で、ECS Express Mode と同じく、多くの設定はあとから普通のリソースとして変えられます
  • 試作や検証用の DB をテンプレートで作って消すのには向いていそうですが、VPC や暗号化キーを最初から決めたい本番用には、これまでどおりフル設定で書くほうがよさそうです
1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?