3
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

[aws-cli]RDSをjson形式設定ファイルから起動する。

Last updated at Posted at 2016-06-17

[aws-cli]RDSをjson形式設定ファイルから起動する。

RDSの起動コマンドはcreate-db-inscance
create-db-instance — AWS CLI 1.10.38 Command Reference

デフォルトの設定ファイルを出力


$ aws rds create-db-instance --generate-cli-skeleton > defaultRDS.json
$ cat defaultRDS.json
{
    "DBName": "",
    "DBInstanceIdentifier": "",
    "AllocatedStorage": 0,
    "DBInstanceClass": "",
    "Engine": "",
    "MasterUsername": "",
    "MasterUserPassword": "",
    "DBSecurityGroups": [
        "" 
    ],
    "VpcSecurityGroupIds": [
        "" 
    ],
    "AvailabilityZone": "",
    "DBSubnetGroupName": "",
    "PreferredMaintenanceWindow": "",
    "DBParameterGroupName": "",
    "BackupRetentionPeriod": 0,
    "PreferredBackupWindow": "",
    "Port": 0,
    "MultiAZ": true,
    "EngineVersion": "",
    "AutoMinorVersionUpgrade": true,
    "LicenseModel": "",
    "Iops": 0,
    "OptionGroupName": "",
    "CharacterSetName": "",
    "PubliclyAccessible": true,
    "Tags": [
        {
            "Key": "",
            "Value": "" 
        }
    ],
    "DBClusterIdentifier": "",
    "StorageType": "",
    "TdeCredentialArn": "",
    "TdeCredentialPassword": "",
    "StorageEncrypted": true,
    "KmsKeyId": "",
    "CopyTagsToSnapshot": true
} 

各項目について確認

DBName: database名
DBInstanceIdentifier: DBインスタンス名 アカウント内で一意
AllocatedStorage: ストレージのサイズ
DBInstanceClass: インスタンスタイプ
Engine: DBエンジン
MasterUserName: DB管理ユーザ名
MasterUserPassword: DB管理ユーザパスワード
DBSecurityGroups: DBセキュリティグループの配列
VpcSecurityGroupIds: VPCセキュリティグループの配列
AvailabilityZone: アベイラビリティゾーン
DBSubnetGroupName: DBサブネットグループ名
PreferredMaintenanceWindow: メンテナンスウィンドウ ddd:hh24:mi-ddd:hh24:mi
DBParameterGroupName: DBパラメータグループ名
BackupRetentionPeriod: バックアップ保持期間 0だとバックアップを行わない
PreferredBackupWindow: バックアップウィンドウ hh24:mi-hh24:mi
Port: ポート 未定義であればデフォルト
MultiAZ: マルチAZ構成にするか否か
EngineVersion: DBエンジンのバージョン
AutoMinorVersionUpgrade: マイナーバージョンアップを適用するか否か
LicenseModel: ライセンシングモデル license-included | bring-your-own-license | general-public-license
Iops: ストレージへの秒間IO上限
OptionGroupName: オプショングループ名
CharacterSetName: 文字コード
PubliclyAccessible: 外部アクセス可否
Tags: タグの配列
DBClusterIdentifier: DBクラスタ名
StorageType: ストレージタイプ standard | gp2 | io1
TdeCredentialArn: HAパーティショングループのリソース番号
TdeCredentialPassword: HAパーティショングループの初期化時に使用したパーティションパスワード
StorageEncrypted: ストレージの暗号化有無
KmsKeyId: KMSで設定されたID
CopyTagsToSnapshot: スナップショットにタグをコピーするか否か

書き換え


$ cat createRDS.json
{
    "DBName": "test",
    "DBInstanceIdentifier": "test",
    "AllocatedStorage": 5,
    "DBInstanceClass": "db.t2.micro",
    "Engine": "MySQL",
    "MasterUsername": "root",
    "MasterUserPassword": "password",
    "VpcSecurityGroupIds": [
        "sg-xxxxxx" 
    ],
    "AvailabilityZone": "ap-northeast-1a",
    "DBSubnetGroupName": "default-vpc-xxxxxxx",
    "PreferredMaintenanceWindow": "Sat:18:00-Sat:18:30",
    "BackupRetentionPeriod": 3, 
    "PreferredBackupWindow": "19:00-19:30",
    "MultiAZ": false,
    "EngineVersion": "5.6.27",
    "AutoMinorVersionUpgrade": true,
    "LicenseModel": "general-public-license",
    "Iops": 0,
    "OptionGroupName": "",
    "PubliclyAccessible": false,
    "Tags": [
        {
            "Key": "test",
            "Value": "test" 
        }
    ],
    "DBClusterIdentifier": "",
    "StorageType": "standard",
    "StorageEncrypted": false,
    "CopyTagsToSnapshot": true
}

作成


$ aws --region ap-northeast-1 rds create-db-instance --cli-input-json file:///tmp/createRDS.json
{
    "DBInstance": {
        "PubliclyAccessible": false,
        "MasterUsername": "root",
        "LicenseModel": "general-public-license",
        "VpcSecurityGroups": [
            {
                "Status": "active",
                "VpcSecurityGroupId": "sg-xxxxxxxx" 
            }
        ],
        "CopyTagsToSnapshot": true,
        "OptionGroupMemberships": [
            {
                "Status": "in-sync",
                "OptionGroupName": "default:mysql-5-6" 
            }
        ],
        "PendingModifiedValues": {
            "MasterUserPassword": "****" 
        },
        "Engine": "mysql",
        "MultiAZ": false,
        "DBSecurityGroups": [],
        "DBParameterGroups": [
            {
                "DBParameterGroupName": "default.mysql5.6",
                "ParameterApplyStatus": "in-sync" 
            }
        ],
        "AutoMinorVersionUpgrade": true,
        "PreferredBackupWindow": "19:00-19:30",
        "DBSubnetGroup": {
            "Subnets": [
                {
                    "SubnetStatus": "Active",
                    "SubnetIdentifier": "subnet-xxxxxxxx",
                    "SubnetAvailabilityZone": {
                        "Name": "ap-northeast-1c" 
                    }
                },
                {
                    "SubnetStatus": "Active",
                    "SubnetIdentifier": "subnet-xxxxxxxx",
                    "SubnetAvailabilityZone": {
                        "Name": "ap-northeast-1a" 
                    }
                }
            ],
            "DBSubnetGroupName": "default-vpc-xxxxxxxx",
            "VpcId": "vpc-xxxxxxxx",
            "DBSubnetGroupDescription": "Created from the RDS Management Console",
            "SubnetGroupStatus": "Complete" 
        },
        "ReadReplicaDBInstanceIdentifiers": [],
        "AllocatedStorage": 5,
        "BackupRetentionPeriod": 3,
        "DBName": "test",
        "PreferredMaintenanceWindow": "sat:18:00-sat:18:30",
        "DBInstanceStatus": "creating",
        "EngineVersion": "5.6.27",
        "AvailabilityZone": "ap-northeast-1a",
        "StorageType": "standard",
        "DbiResourceId": "db-XXXXXXXXXXXXXXXXXXX",
        "CACertificateIdentifier": "rds-ca-2015",
        "StorageEncrypted": false,
        "DBInstanceClass": "db.t2.micro",
        "DbInstancePort": 0,
        "DBInstanceIdentifier": "account-dev" 
    }
}

エラー集

A client error (InvalidParameterCombination) occurred when calling the CreateDBInstance operation: Invalid license model '' for engine 'mysql'. Valid license models are: general-public-license
LicenseModelを設定していなかったのが原因。
general-public-licenseをセットして解消。
 
A client error (InvalidParameterCombination) occurred when calling the CreateDBInstance operation: DB Instance class db.t2.micro does not support encryption at rest
StorageEncryptedがtrueになっていたのが原因。
falseをセットして解消。
 
A client error (InvalidParameterCombination) occurred when calling the CreateDBInstance operation: To enable encryption at rest StorageEncrypted must be set to 'true'
StorageEncryptedがfalseなのにKmsKeyIdが設定されているのが原因。
KmsKeyIdを削除して解消。
 
A client error (InvalidParameterValue) occurred when calling the CreateDBInstance operation: Invalid endpoint port 0. Valid range is: 1150-65535
Portに0が設定されているのが原因。
Portを削除して解消。
各DBのデフォルトポートが使用される。
 
A client error (InvalidParameterValue) occurred when calling the CreateDBInstance operation: The parameter MasterUserPassword is not a valid password because it is shorter than 8 characters.
MasterUserPasswordが8文字以下なのが原因。
8文字以上を設定して解消。
 
A client error (InvalidParameterCombination) occurred when calling the CreateDBInstance operation: DB Security Groups and Vpc Security Groups cannot both be provided.
DBSecurityGroupsとVpcSecurityGroupIdsが両方設定されているのが原因。
DBSecurityGroupsを削除して解消。
 
A client error (StorageTypeNotSupported) occurred when calling the CreateDBInstance operation: Invalid storage type:
StorageTypeが空になっているのが原因。
standardを設定して解消。
 
A client error (InvalidParameterValue) occurred when calling the CreateDBInstance operation: Character sets not supported on create for engine: mysql and version5.6.27
CharacterSetNameが空になっているのが原因。
CharacterSetNameを削除して解消。
 
A client error (DBParameterGroupNotFound) occurred when calling the CreateDBInstance operation: DBParameterGroup not found:
DBParameterGroupNameが空になっているのが原因。
DBParameterGroupNameを削除して解消。
 
A client error (InvalidParameterCombination) occurred when calling the CreateDBInstance operation: Could not create the client with the key store.
TdeCredentialArnとTdeCredentialPasswordが設定されているのが原因。
TdeCredentialArnとTdeCredentialPasswordを削除して解消。
 
3
4
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
3
4

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?