==================================================================== 1.2. rds (create: DBインスタンス PostgreSQL Single AZ / Public) ==================================================================== .. include:: ./_defines-rds.txt .. .. |AWS_DEFAULT_PROFILE| replace:: .. .. |DIR_CONF| replace:: ${HOME}/tmp/conf-rds .. .. |RDS_SUBNET_GROUP_NAME| replace:: ---------------------------------------------------------------- 作業の目的 [why] ---------------------------------------------------------------- DBインスタンス"\ |RDS_INSTANCE_IDENT|\ "を作成します。 .. include:: ../../../resource-catalog/task-rds/rds-db_instance-create/_display-condition-common-rds-db_instance-create.txt .. include:: ../../../resource-catalog/task-rds/rds-db_instance-create/rds-db_instance-postgresql-single_az-publicly_accessible-create.txt 3.3. 後処理に必要な作業 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% .. 後処理に必要な作業があれば実施します。 .. rubric:: エンドポイントの確認 変数の設定: .. code-block:: sh RDS_INSTANCE_ENDPOINT=$( \ aws rds describe-db-instances \ --db-instance-identifier ${RDS_INSTANCE_IDENT} \ --query 'DBInstances[].Endpoint.Address' \ --output text \ ) \ && echo ${RDS_INSTANCE_ENDPOINT} 結果(例): .. parsed-literal:: \ |RDS_INSTANCE_IDENT|\ .xxxxxxxxxxxx.ap-northeast-1.rds.amazonaws.com .. rubric:: 接続情報設定ファイルの作成 変数の確認: .. code-block:: sh cat << ETX RDS_INSTANCE_ENDPOINT: ${RDS_INSTANCE_ENDPOINT} VPC_SG_PORT: ${VPC_SG_PORT} RDS_DB_NAME: ${RDS_DB_NAME} RDS_USER_NAME: ${RDS_USER_NAME} RDS_USER_PASS: ${RDS_USER_PASS} ETX コマンド: .. code-block:: sh echo "${RDS_INSTANCE_ENDPOINT}:${VPC_SG_PORT}:${RDS_DB_NAME}:${RDS_USER_NAME}:${RDS_USER_PASS}" >> ${HOME}/.pgpass \ && chmod 600 ${HOME}/.pgpass \ && cat ${HOME}/.pgpass .. rubric:: 接続 コマンド: .. code-block:: sh psql \ --host=${RDS_INSTANCE_ENDPOINT} \ --username=${RDS_USER_NAME} \ --dbname=${RDS_DB_NAME} 結果(例): .. code-block:: text psql (9.5.5, server 9.5.4) SSL connection (protocol: TLSv1.2, cipher: ECDHE-RSA-AES256-GCM-SHA384, bits: 256, compression: off) Type "help" for help. handson20161114=> DBコマンドのテスト実行をしてみます。 SQL: .. code-block:: sql select version(); 結果(例): .. code-block:: text version ---------------------------------------------------------------------------------------------------------- PostgreSQL 9.5.4 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.8.2 20140120 (Red Hat 4.8.2-16), 64-bit (1 row) .. rubric:: 切断 DBへの接続を切断します。 コマンド: .. code-block:: sh \q ---------------------------------------------------------------- 完了 ----------------------------------------------------------------