【AWS CLI】RDS関連の情報取得編

記事タイトルとURLをコピーする

こんにちは。AWS CLIが好きな福島です。

今回は、AWS CLIを使ってRDS関連の情報を取得するコマンドを記載いたします。

過去にEC2編も記載しているため、ご興味がある方は、以下をご参照ください。

blog.serverworks.co.jp

実行環境

今回、コマンドを実行した環境は、以下の通りとなります。
(本記事でご紹介しているコマンドの中には、Linuxのコマンドを利用している箇所があります。)

# uname -a
Linux LAPTOP-CNM26HN6 4.4.0-18362-Microsoft #1049-Microsoft Thu Aug 14 12:01:00 PST 2020 x86_64 x86_64 x86_64 GNU/Linux
#

エンジンとインスタンスクラス情報

コマンド(ヘッダー無し)

aws rds describe-db-instances --query "DBInstances[].[DBInstanceIdentifier,DBInstanceClass,Engine,EngineVersion]" --output text | column -t
  • 実行結果
fk-jira                               db.t2.small  postgres           11.5
fk-test-aurora-dev-instance-1         db.t3.small  aurora             5.6.mysql_aurora.1.19.5
fk-test-aurora-postgresql-instance-1  db.r5.large  aurora-postgresql  9.6.11
fk-test-aurora-prod-instance-1        db.t3.small  aurora             5.6.mysql_aurora.1.19.5

コマンド(ヘッダー有り)

echo "DBInstanceIdentifier DBInstanceClass Engine EngineVersion" > /tmp/awscli.tmp;\
aws rds describe-db-instances --query "DBInstances[].[DBInstanceIdentifier,DBInstanceClass,Engine,EngineVersion]" --output text >> /tmp/awscli.tmp;\
column -t /tmp/awscli.tmp;\
rm /tmp/awscli.tmp
  • 実行結果
DBInstanceIdentifier                  DBInstanceClass  Engine             EngineVersion
fk-jira                               db.t2.small      postgres           11.5
fk-test-aurora-dev-instance-1         db.t3.small      aurora             5.6.mysql_aurora.1.19.5
fk-test-aurora-postgresql-instance-1  db.r5.large      aurora-postgresql  9.6.11
fk-test-aurora-prod-instance-1        db.t3.small      aurora             5.6.mysql_aurora.1.19.5

DBサブネット情報

コマンド(ヘッダー無し)

aws rds describe-db-instances --query "DBInstances[].[DBInstanceIdentifier,AvailabilityZone,DBSubnetGroup.DBSubnetGroupName]" --output text | column -t
  • 実行結果
fk-jira                               ap-northeast-1a  default-vpc-xxxxxxxxxxxxxxxxx
fk-test-aurora-dev-instance-1         ap-northeast-1a  fk-test-dbsubnet
fk-test-aurora-postgresql-instance-1  ap-northeast-1a  default-vpc-xxxxxxxxxxxxxxxxx
fk-test-aurora-prod-instance-1        ap-northeast-1a  fk-test-dbsubnet

コマンド(ヘッダー有り)

echo "DBInstanceIdentifier AvailabilityZone DBSubnetGroupName" > /tmp/awscli.tmp;\
aws rds describe-db-instances --query "DBInstances[].[DBInstanceIdentifier,AvailabilityZone,DBSubnetGroup.DBSubnetGroupName]" --output text  >> /tmp/awscli.tmp;\
column -t /tmp/awscli.tmp;\
rm /tmp/awscli.tmp
  • 実行結果
DBInstanceIdentifier                  AvailabilityZone  DBSubnetGroupName
fk-jira                               ap-northeast-1a   default-vpc-xxxxxxxxxxxxxxxxx
fk-test-aurora-dev-instance-1         ap-northeast-1a   fk-test-dbsubnet
fk-test-aurora-postgresql-instance-1  ap-northeast-1a   default-vpc-xxxxxxxxxxxxxxxxx
fk-test-aurora-prod-instance-1        ap-northeast-1a   fk-test-dbsubnet

エンドポイント情報

Auroraの場合はインスタンスごとのエンドポイントが表示されます。
AuroraのWriter、Readerノードのエンドポイントを表示するためには、「aws rds describe-db-clusters」コマンドを利用します。

コマンド(ヘッダー無し)

aws rds describe-db-instances --query "DBInstances[].[DBInstanceIdentifier,Endpoint.Address,Endpoint.Port,MasterUsername]" --output text | column -t
  • 実行結果
fk-jira                               fk-jira.xxxxxxxxxxxx.ap-northeast-1.rds.amazonaws.com                               5432  postgres
fk-test-aurora-dev-instance-1         fk-test-aurora-dev-instance-1.xxxxxxxxxxxx.ap-northeast-1.rds.amazonaws.com         3306  admin
fk-test-aurora-postgresql-instance-1  fk-test-aurora-postgresql-instance-1.xxxxxxxxxxxx.ap-northeast-1.rds.amazonaws.com  5432  master
fk-test-aurora-prod-instance-1        fk-test-aurora-prod-instance-1.xxxxxxxxxxxx.ap-northeast-1.rds.amazonaws.com        3306  admin

コマンド(ヘッダー有り)

echo "DBInstanceIdentifier Endpoint Port MasterUsername" > /tmp/awscli.tmp;\
aws rds describe-db-instances --query "DBInstances[].[DBInstanceIdentifier,Endpoint.Address,Endpoint.Port,MasterUsername]" --output text >> /tmp/awscli.tmp;\
column -t /tmp/awscli.tmp;\
rm /tmp/awscli.tmp
  • 実行結果
DBInstanceIdentifier                  Endpoint                                                                            Port  MasterUsername
fk-jira                               fk-jira.xxxxxxxxxxxx.ap-northeast-1.rds.amazonaws.com                               5432  postgres
fk-test-aurora-dev-instance-1         fk-test-aurora-dev-instance-1.xxxxxxxxxxxx.ap-northeast-1.rds.amazonaws.com         3306  admin
fk-test-aurora-postgresql-instance-1  fk-test-aurora-postgresql-instance-1.xxxxxxxxxxxx.ap-northeast-1.rds.amazonaws.com  5432  master
fk-test-aurora-prod-instance-1        fk-test-aurora-prod-instance-1.xxxxxxxxxxxx.ap-northeast-1.rds.amazonaws.com        3306  admin

補足

AuroraのWriter、Readerノードのエンドポイントを表示するコマンド

aws rds describe-db-cluster-endpoints --query "DBClusterEndpoints[].[DBClusterIdentifier,Endpoint,EndpointType]" --output text
  • 実行結果
fk-test-aurora-postgresql  fk-test-aurora-postgresql.cluster-xxxxxxxxxxxx.ap-northeast-1.rds.amazonaws.com     WRITER
fk-test-aurora-postgresql  fk-test-aurora-postgresql.cluster-ro-xxxxxxxxxxxx.ap-northeast-1.rds.amazonaws.com  READER
fk-test-aurora-prod        fk-test-aurora-prod.cluster-xxxxxxxxxxxx.ap-northeast-1.rds.amazonaws.com           WRITER
fk-test-aurora-prod        fk-test-aurora-prod.cluster-ro-xxxxxxxxxxxx.ap-northeast-1.rds.amazonaws.com        READER
fk-test-aurora-dev         fk-test-aurora-dev.cluster-xxxxxxxxxxxx.ap-northeast-1.rds.amazonaws.com            WRITER
fk-test-aurora-dev         fk-test-aurora-dev.cluster-ro-xxxxxxxxxxxx.ap-northeast-1.rds.amazonaws.com         READER

セキュリティグループ情報(5個まで表示)

コマンド(ヘッダー無し)

aws rds describe-db-instances --query "DBInstances[].[DBInstanceIdentifier,\
VpcSecurityGroups[0].VpcSecurityGroupId,\
VpcSecurityGroups[1].VpcSecurityGroupId,\
VpcSecurityGroups[2].VpcSecurityGroupId,\
VpcSecurityGroups[3].VpcSecurityGroupId,\
VpcSecurityGroups[4].VpcSecurityGroupId]" \
--output text | column -t
  • 実行結果
fk-jira                               sg-xxxxxxxxxxxxxxxxx3  None  None  None  None
fk-test-aurora-dev-instance-1         sg-xxxxxxxxxxxxxxxxx3  None  None  None  None
fk-test-aurora-postgresql-instance-1  sg-xxxxxxxxxxxxxxxxx1  None  None  None  None
fk-test-aurora-prod-instance-1        sg-xxxxxxxxxxxxxxxxx3  None  None  None  None

コマンド(ヘッダー有り)

echo "DBInstanceIdentifier VpcSecurityGroupId[1] VpcSecurityGroupId[2] VpcSecurityGroupId[3] VpcSecurityGroupId[4] VpcSecurityGroupId[5]" > /tmp/awscli.tmp;\
aws rds describe-db-instances --query "DBInstances[].[DBInstanceIdentifier,\
VpcSecurityGroups[0].VpcSecurityGroupId,\
VpcSecurityGroups[1].VpcSecurityGroupId,\
VpcSecurityGroups[2].VpcSecurityGroupId,\
VpcSecurityGroups[3].VpcSecurityGroupId,\
VpcSecurityGroups[4].VpcSecurityGroupId]" \
--output text  >> /tmp/awscli.tmp;\
column -t /tmp/awscli.tmp;\
rm /tmp/awscli.tmp
  • 実行結果
DBInstanceIdentifier                  VpcSecurityGroupId[1]  VpcSecurityGroupId[2]  VpcSecurityGroupId[3]  VpcSecurityGroupId[4]  VpcSecurityGroupId[5]
fk-jira                               sg-xxxxxxxxxxxxxxxxx3   None                   None                   None                   None
fk-test-aurora-dev-instance-1         sg-xxxxxxxxxxxxxxxxx3   None                   None                   None                   None
fk-test-aurora-postgresql-instance-1  sg-xxxxxxxxxxxxxxxxx1   None                   None                   None                   None
fk-test-aurora-prod-instance-1        sg-xxxxxxxxxxxxxxxxx3   None                   None                   None                   None

ステータスチェック

コマンド(ヘッダー無し)

aws rds describe-db-instances --query "DBInstances[].[DBInstanceIdentifier,DBInstanceStatus]" --output text | column -t
  • 実行結果
fk-jira                               available
fk-test-aurora-dev-instance-1         stopped
fk-test-aurora-postgresql-instance-1  stopped
fk-test-aurora-prod-instance-1        stopped

コマンド(ヘッダー有り)

echo "DBInstanceIdentifier DBInstanceStatus" > /tmp/awscli.tmp;\
aws rds describe-db-instances --query "DBInstances[].[DBInstanceIdentifier,DBInstanceStatus]" --output text  >> /tmp/awscli.tmp;\
column -t /tmp/awscli.tmp;\
rm /tmp/awscli.tmp
  • 実行結果
DBInstanceIdentifier                  DBInstanceStatus
fk-jira                               available
fk-test-aurora-dev-instance-1         stopped
fk-test-aurora-postgresql-instance-1  stopped
fk-test-aurora-prod-instance-1        stopped

ボリューム情報

Auroraのボリュームは自動で増強されるため、 StorageType が「aurora」と表示されるようです。

コマンド(ヘッダー無し)

aws rds describe-db-instances --query "DBInstances[].[DBInstanceIdentifier,StorageType,AllocatedStorage,MaxAllocatedStorage,StorageEncrypted,KmsKeyId]" --output text | column -t
  • 実行結果
fk-jira                               gp2     20  30    False  None
fk-test-aurora-dev-instance-1         aurora  1   None  True   arn:aws:kms:ap-northeast-1:xxxxxxxxxxxx:key/xxxxxxx-xxxxxx-xxxx-xxxx-xxxxxxxxxxx
fk-test-aurora-postgresql-instance-1  aurora  1   None  True   arn:aws:kms:ap-northeast-1:xxxxxxxxxxxx:key/xxxxxxx-xxxxxx-xxxx-xxxx-xxxxxxxxxxx
fk-test-aurora-prod-instance-1        aurora  1   None  True   arn:aws:kms:ap-northeast-1:xxxxxxxxxxxx:key/xxxxxxx-xxxxxx-xxxx-xxxx-xxxxxxxxxxx

コマンド(ヘッダー有り)

echo "DBInstanceIdentifier StorageType AllocatedStorage MaxAllocatedStorage StorageEncrypted KmsKeyId" > /tmp/awscli.tmp;\
aws rds describe-db-instances --query "DBInstances[].[DBInstanceIdentifier,StorageType,AllocatedStorage,MaxAllocatedStorage,StorageEncrypted,KmsKeyId]" --output text >> /tmp/awscli.tmp;\
column -t /tmp/awscli.tmp;\
rm /tmp/awscli.tmp
  • 実行結果
DBInstanceIdentifier                  StorageType  AllocatedStorageort  MaxAllocatedStorage  StorageEncrypted  KmsKeyId
fk-jira                               gp2          20                   30                   False             None
fk-test-aurora-dev-instance-1         aurora       1                    None                 True              arn:aws:kms:ap-northeast-1:xxxxxxxxxxxx:key/xxxxxxx-xxxxxx-xxxx-xxxx-xxxxxxxxxxx
fk-test-aurora-postgresql-instance-1  aurora       1                    None                 True              arn:aws:kms:ap-northeast-1:xxxxxxxxxxxx:key/xxxxxxx-xxxxxx-xxxx-xxxx-xxxxxxxxxxx
fk-test-aurora-prod-instance-1        aurora       1                    None                 True              arn:aws:kms:ap-northeast-1:xxxxxxxxxxxx:key/xxxxxxx-xxxxxx-xxxx-xxxx-xxxxxxxxxxx

バックアップ・メンテンナンスウィンドウ情報

コマンド(ヘッダー無し)

aws rds describe-db-instances --query "DBInstances[].[DBInstanceIdentifier,PreferredBackupWindow,BackupRetentionPeriod,PreferredMaintenanceWindow]" --output text | column -t
  • 実行結果
fk-jira                               16:25-16:55  0  fri:19:44-fri:20:14
fk-test-aurora-dev-instance-1         16:54-17:24  1  thu:16:01-thu:16:31
fk-test-aurora-postgresql-instance-1  17:50-18:20  7  fri:13:50-fri:14:20
fk-test-aurora-prod-instance-1        14:31-15:01  1  sat:16:53-sat:17:23

コマンド(ヘッダー有り)

echo "DBInstanceIdentifier PreferredBackupWindow BackupRetentionPeriod PreferredMaintenanceWindow" > /tmp/awscli.tmp;\
aws rds describe-db-instances --query "DBInstances[].[DBInstanceIdentifier,PreferredBackupWindow,BackupRetentionPeriod,PreferredMaintenanceWindow]" --output text >> /tmp/awscli.tmp;\
column -t /tmp/awscli.tmp;\
rm /tmp/awscli.tmp
  • 実行結果
DBInstanceIdentifier                  PreferredBackupWindow  BackupRetentionPeriod  PreferredMaintenanceWindow
fk-jira                               16:25-16:55            0                      fri:19:44-fri:20:14
fk-test-aurora-dev-instance-1         16:54-17:24            1                      thu:16:01-thu:16:31
fk-test-aurora-postgresql-instance-1  17:50-18:20            7                      fri:13:50-fri:14:20
fk-test-aurora-prod-instance-1        14:31-15:01            1                      sat:16:53-sat:17:23

スナップショット情報

コマンド(ヘッダー無し)

aws rds describe-db-snapshots --query "DBSnapshots[].[DBInstanceIdentifier,SnapshotCreateTime,DBSnapshotIdentifier,SnapshotType]" --output text | column -t
  • 実行結果
fk-jira  2020-12-01T03:35:20.592000+00:00  test  manual

コマンド(ヘッダー有り)

echo "DBInstanceIdentifier SnapshotCreateTime DBSnapshotIdentifier SnapshotType" > /tmp/awscli.tmp;\
aws rds describe-db-snapshots --query "DBSnapshots[].[DBInstanceIdentifier,SnapshotCreateTime,DBSnapshotIdentifier,SnapshotType]" --output text >> /tmp/awscli.tmp;\
column -t /tmp/awscli.tmp;\
rm /tmp/awscli.tmp
  • 実行結果
DBInstanceIdentifier  SnapshotCreateTime                DBSnapshotIdentifier  SnapshotType
fk-jira               2020-12-01T03:35:20.592000+00:00  test                  manual

パラメーターおよびオプショングループ情報

コマンド(ヘッダー無し)

aws rds describe-db-instances --query "DBInstances[].[DBInstanceIdentifier,DBParameterGroups[0].DBParameterGroupName,OptionGroupMemberships[0].OptionGroupName]" --output text | column -t
  • 実行結果
fk-jira                               default.postgres11                         default:postgres-11
fk-test-aurora-dev-instance-1         default.aurora5.6                          default:aurora-5-6
fk-test-aurora-postgresql-instance-1  fk-test-aurora-postgresql-parameter-group  default:aurora-postgresql-9-6
fk-test-aurora-prod-instance-1        default.aurora5.6                          default:aurora-5-6

コマンド(ヘッダー有り)

echo "DBInstanceIdentifier DBParameterGroupName DBSubnetGroupName" > /tmp/awscli.tmp;\
aws rds describe-db-instances --query "DBInstances[].[DBInstanceIdentifier,DBParameterGroups[0].DBParameterGroupName,OptionGroupMemberships[0].OptionGroupName]" --output text >> /tmp/awscli.tmp;\
column -t /tmp/awscli.tmp;\
rm /tmp/awscli.tmp
  • 実行結果
DBInstanceIdentifier                  DBParameterGroupName                       DBSubnetGroupName
fk-jira                               default.postgres11                         default:postgres-11
fk-test-aurora-dev-instance-1         default.aurora5.6                          default:aurora-5-6
fk-test-aurora-postgresql-instance-1  fk-test-aurora-postgresql-parameter-group  default:aurora-postgresql-9-6
fk-test-aurora-prod-instance-1        default.aurora5.6                          default:aurora-5-6

パラメーターグループのデフォルト値をExcelに出力する方法を以前ご紹介しているため、 ご興味がある方は、こちらもご参照ください。

blog.serverworks.co.jp

出力ログ情報

コマンド(ヘッダー無し)

aws rds describe-db-instances --query "DBInstances[].[DBInstanceIdentifier,Engine,EnabledCloudwatchLogsExports[0],EnabledCloudwatchLogsExports[1],EnabledCloudwatchLogsExports[2],EnabledCloudwatchLogsExports[3],EnabledCloudwatchLogsExports[4]]" --output text | column -t
  • 実行結果
fk-jira                               postgres           postgresql  upgrade  None  None  None
fk-test-aurora-dev-instance-1         aurora             None        None     None  None  None
fk-test-aurora-postgresql-instance-1  aurora-postgresql  None        None     None  None  None
fk-test-aurora-prod-instance-1        aurora             None        None     None  None  None

コマンド(ヘッダー有り)

echo "DBInstanceIdentifier Engine CloudwatchLogsExports[1] CloudwatchLogsExports[2] CloudwatchLogsExports[3] CloudwatchLogsExports[4] CloudwatchLogsExports[5]" > /tmp/awscli.tmp;\
aws rds describe-db-instances --query "DBInstances[].[DBInstanceIdentifier,Engine,EnabledCloudwatchLogsExports[0],EnabledCloudwatchLogsExports[1],EnabledCloudwatchLogsExports[2],EnabledCloudwatchLogsExports[3],EnabledCloudwatchLogsExports[4]]" --output text >> /tmp/awscli.tmp;\
column -t /tmp/awscli.tmp;\
rm /tmp/awscli.tmp
  • 実行結果
DBInstanceIdentifier                  Engine             CloudwatchLogsExports[1]  CloudwatchLogsExports[2]  CloudwatchLogsExports[3]  CloudwatchLogsExports[4]  CloudwatchLogsExports[5]
fk-jira                               postgres           postgresql                upgrade                   None                      None                      None
fk-test-aurora-dev-instance-1         aurora             None                      None                      None                      None                      None
fk-test-aurora-postgresql-instance-1  aurora-postgresql  None                      None                      None                      None                      None
fk-test-aurora-prod-instance-1        aurora             None                      None                      None                      None                      None

タグ情報(10個まで表示)

コマンド(ヘッダー無し)

aws rds describe-db-instances --query "DBInstances[].[DBInstanceIdentifier,\
TagList[0].Key,TagList[0].Value,\
TagList[1].Key,TagList[1].Value,\
TagList[2].Key,TagList[2].Value,\
TagList[3].Key,TagList[3].Value,\
TagList[4].Key,TagList[4].Value,\
TagList[5].Key,TagList[5].Value,\
TagList[6].Key,TagList[6].Value,\
TagList[7].Key,TagList[7].Value,\
TagList[8].Key,TagList[8].Value,\
TagList[9].Key,TagList[9].Value]" \
--output text | column -t
  • 実行結果
fk-jira                               Control  CloudAutomator  None  None  None  None  None  None  None  None  None  None  None  None  None  None  None  None  None  None
fk-test-aurora-dev-instance-1         None     None            None  None  None  None  None  None  None  None  None  None  None  None  None  None  None  None  None  None
fk-test-aurora-postgresql-instance-1  None     None            None  None  None  None  None  None  None  None  None  None  None  None  None  None  None  None  None  None
fk-test-aurora-prod-instance-1        None     None            None  None  None  None  None  None  None  None  None  None  None  None  None  None  None  None  None  None

コマンド(ヘッダー有り)

echo "DBClusterIdentifier \
key[1] value[1] \
key[2] value[2] \
key[3] value[3] \
key[4] value[4] \
key[5] value[5] \
key[6] value[6] \
key[7] value[7] \
key[8] value[8] \
key[9] value[9] \
key[10] value[10]" > /tmp/awscli.tmp;\
aws rds describe-db-instances --query "DBInstances[].[DBInstanceIdentifier,\
TagList[0].Key,TagList[0].Value,\
TagList[1].Key,TagList[1].Value,\
TagList[2].Key,TagList[2].Value,\
TagList[3].Key,TagList[3].Value,\
TagList[4].Key,TagList[4].Value,\
TagList[5].Key,TagList[5].Value,\
TagList[6].Key,TagList[6].Value,\
TagList[7].Key,TagList[7].Value,\
TagList[8].Key,TagList[8].Value,\
TagList[9].Key,TagList[9].Value]" \
--output text >> /tmp/awscli.tmp;\
column -t /tmp/awscli.tmp;\
rm /tmp/awscli.tmp
  • 実行結果
DBClusterIdentifier                   key[1]   value[1]        key[2]  value[2]  key[3]  value[3]  key[4]  value[4]  key[5]  value[5]  key[6]  value[6]  key[7]  value[7]  key[8]  value[8]  key[9]  value[9]  key[10]  value[10]
fk-jira                               Control  CloudAutomator  None    None      None    None      None    None      None    None      None    None      None    None      None    None      None    None      None     None
fk-test-aurora-dev-instance-1         None     None            None    None      None    None      None    None      None    None      None    None      None    None      None    None      None    None      None     None
fk-test-aurora-postgresql-instance-1  None     None            None    None      None    None      None    None      None    None      None    None      None    None      None    None      None    None      None     None
fk-test-aurora-prod-instance-1        None     None            None    None      None    None      None    None      None    None      None    None      None    None      None    None      None    None      None     None

その他設定値

その他設定値は、
・マルチAZ
・自動マイナーバージョンアップグレードの有無
・モニタリング間隔
・PerformanceInsightsの有無
・データベース認証オプション
・削除保護の有無
の情報を表示しております。

コマンド(ヘッダー無し)

aws rds describe-db-instances --query "DBInstances[].[DBInstanceIdentifier,MultiAZ,AutoMinorVersionUpgrade,PubliclyAccessible,MonitoringInterval,PerformanceInsightsEnabled,CACertificateIdentifier,IAMDatabaseAuthenticationEnabled,DeletionProtection]" --output text | column -t
  • 実行結果
fk-jira                               False  False  False  0   False  rds-ca-2019  False  False
fk-test-aurora-dev-instance-1         False  True   False  60  False  rds-ca-2019  False  False
fk-test-aurora-postgresql-instance-1  False  False  False  60  True   rds-ca-2019  False  False
fk-test-aurora-prod-instance-1        False  True   False  60  False  rds-ca-2019  False  False

コマンド(ヘッダー有り)

echo "DBInstanceIdentifier MultiAZ AutoMinorVersionUpgrade PubliclyAccessible MonitoringInterval PerformanceInsights CACertificateIdentifier IAMAuthentication DeletionProtection" > /tmp/awscli.tmp;\
aws rds describe-db-instances --query "DBInstances[].[DBInstanceIdentifier,MultiAZ,AutoMinorVersionUpgrade,PubliclyAccessible,MonitoringInterval,PerformanceInsightsEnabled,CACertificateIdentifier,IAMDatabaseAuthenticationEnabled,DeletionProtection]" --output text >> /tmp/awscli.tmp;\
column -t /tmp/awscli.tmp;\
rm /tmp/awscli.tmp
  • 実行結果
DBInstanceIdentifier                  MultiAZ  AutoMinorVersionUpgrade  PubliclyAccessible  MonitoringInterval  PerformanceInsights  CACertificateIdentifier  IAMAuthentication  DeletionProtection
fk-jira                               False    False                    False               0                   False                rds-ca-2019              False              False
fk-test-aurora-dev-instance-1         False    True                     False               60                  False                rds-ca-2019              False              False
fk-test-aurora-postgresql-instance-1  False    False                    False               60                  True                 rds-ca-2019              False              False
fk-test-aurora-prod-instance-1        False    True                     False               60                  False                rds-ca-2019              False              False

DBサブネット情報

コマンド(ヘッダー無し)

aws rds describe-db-subnet-xxxxxxxxxxxxxxxxxBSubnetGroups[].[DBSubnetGroupName,VpcId,Subnets[0].SubnetIdentifier,Subnets[0].SubnetAvailabilityZone.Name,Subnets[1].SubnetIdentifier,Subnets[1].SubnetAvailabilityZone.Name,Subnets[2].SubnetIdentifier,Subnets[2].SubnetAvailabilityZone.Name]" --output text | column -t
  • 実行結果
default                        vpc-xxxxxxxxxxxxxxxxx subnet-xxxxxxxxxxxxxxxxx  ap-northeast-1a  subnet-xxxxxxxxxxxxxxxxx  ap-northeast-1c  subnet-xxxxxxxxxxxxxxxxx  ap-northeast-1d
default-vpc-xxxxxxxxxxxxxxxxx vpc-xxxxxxxxxxxxxxxxx subnet-xxxxxxxxxxxxxxxxx  ap-northeast-1c  subnet-xxxxxxxxxxxxxxxxx  ap-northeast-1a  subnet-xxxxxxxxxxxxxxxxx  ap-northeast-1c
fk-test-dbsubnet               vpc-xxxxxxxxxxxxxxxxx subnet-xxxxxxxxxxxxxxxxx  ap-northeast-1c  subnet-xxxxxxxxxxxxxxxxx  ap-northeast-1a  None                      None

コマンド(ヘッダー有り)

echo "DBSubnetGroupName VpcId SubnetIdentifier[1] SubnetAvailabilityZone[1] SubnetIdentifier[2] SubnetAvailabilityZone[2] SubnetIdentifier[3] SubnetAvailabilityZone[3]" > /tmp/awscli.tmp;\
aws rds describe-db-subnet-xxxxxxxxxxxxxxxxxBSubnetGroups[].[DBSubnetGroupName,VpcId,Subnets[0].SubnetIdentifier,Subnets[0].SubnetAvailabilityZone.Name,Subnets[1].SubnetIdentifier,Subnets[1].SubnetAvailabilityZone.Name,Subnets[2].SubnetIdentifier,Subnets[2].SubnetAvailabilityZone.Name]" --output text | column -t >> /tmp/awscli.tmp;\
column -t /tmp/awscli.tmp;\
rm /tmp/awscli.tmp
  • 実行結果
DBSubnetGroupName              VpcId                  SubnetIdentifier[1]       SubnetAvailabilityZone[1]  SubnetIdentifier[2]       SubnetAvailabilityZone[2]  SubnetIdentifier[3]       SubnetAvailabilityZone[3]
default                        vpc-xxxxxxxxxxxxxxxxx subnet-xxxxxxxxxxxxxxxxx  ap-northeast-1a            subnet-xxxxxxxxxxxxxxxxx  ap-northeast-1c            subnet-xxxxxxxxxxxxxxxxx  ap-northeast-1d
default-vpc-xxxxxxxxxxxxxxxxx vpc-xxxxxxxxxxxxxxxxx subnet-xxxxxxxxxxxxxxxxx  ap-northeast-1c            subnet-xxxxxxxxxxxxxxxxx  ap-northeast-1a            subnet-xxxxxxxxxxxxxxxxx  ap-northeast-1c
fk-test-dbsubnet               vpc-xxxxxxxxxxxxxxxxx subnet-xxxxxxxxxxxxxxxxx  ap-northeast-1c            subnet-xxxxxxxxxxxxxxxxx  ap-northeast-1a            None                      None

イベント情報

コマンド

aws rds describe-events --query "Events[].[Date,SourceIdentifier,SourceType,Message]" --output table
  • 実行結果
--------------------------------------------------------------------------------------------------------------------------------------
|                                                           DescribeEvents                                                           |
+----------------------------------+----------------------------------------+--------------+-----------------------------------------+
|  2020-12-01T01:55:53.920000+00:00|  fk-test-aurora-postgresql-instance-1  |  db-instance |  Monitoring Interval changed to 60      |
|  2020-12-01T01:55:53.920000+00:00|  fk-test-aurora-postgresql-instance-1  |  db-instance |  Performance Insights has been enabled  |
+----------------------------------+----------------------------------------+--------------+-----------------------------------------+

おわりに

今回は、RDS関連のリソース情報を取得するコマンドをご紹介いたしました。
次回は、Auroraのクラスタ関連のコマンドをご紹介したいと思います。

福島 和弥 (記事一覧)

SRE3課

2019/10 入社

AWS CLIが好きです。