Amazon DocumentDB examples using Amazon CLI
The following code examples show you how to perform actions and implement common scenarios by using the Amazon Command Line Interface with Amazon DocumentDB.
Actions are code excerpts from larger programs and must be run in context. While actions show you how to call individual service functions, you can see actions in context in their related scenarios.
Each example includes a link to the complete source code, where you can find instructions on how to set up and run the code in context.
Topics
Actions
The following code example shows how to use add-tags-to-resource.
- Amazon CLI
-
To add one or more tags to a specified resource
The following
add-tags-to-resourceexample adds three tags tosample-cluster. One tag (CropB) has a key name but no value.aws docdb add-tags-to-resource \ --resource-namearn:aws:rds:us-west-2:123456789012:cluster:sample-cluster\ --tags Key="CropA",Value="Apple" Key="CropB" Key="CropC",Value="Corn"This command produces no output.
For more information, see Tagging Amazon DocumentDB Resources
in the Amazon DocumentDB Developer Guide. -
For API details, see AddTagsToResource
in Amazon CLI Command Reference.
-
The following code example shows how to use apply-pending-maintenance-action.
- Amazon CLI
-
To have pending maintenance actions take place during the next maintenance window
The following
apply-pending-maintenance-actionexample causes all system-update actions to be performed during the next scheduled maintenance window.aws docdb apply-pending-maintenance-action \ --resource-identifierarn:aws:rds:us-west-2:123456789012:cluster:sample-cluster\ --apply-actionsystem-update\ --opt-in-typenext-maintenanceThis command produces no output.
For more information, see Applying Amazon DocumentDB Updates
in the Amazon DocumentDB Developer Guide. -
For API details, see ApplyPendingMaintenanceAction
in Amazon CLI Command Reference.
-
The following code example shows how to use copy-db-cluster-parameter-group.
- Amazon CLI
-
To duplicate an existing DB cluster parameter group
The following
copy-db-cluster-parameter-groupexample makes a copy of the parameter groupcustom-docdb3-6namedcustom-docdb3-6-copy. When making the copy it adds tags to the new parameter group.aws docdb copy-db-cluster-parameter-group \ --source-db-cluster-parameter-group-identifiercustom-docdb3-6\ --target-db-cluster-parameter-group-identifiercustom-docdb3-6-copy\ --target-db-cluster-parameter-group-description"Copy of custom-docdb3-6"\ --tags Key="CopyNumber",Value="1" Key="Modifiable",Value="Yes"Output:
{ "DBClusterParameterGroup": { "DBParameterGroupFamily": "docdb3.6", "DBClusterParameterGroupArn": "arn:aws:rds:us-east-1:12345678901:cluster-pg:custom-docdb3-6-copy", "DBClusterParameterGroupName": "custom-docdb3-6-copy", "Description": "Copy of custom-docdb3-6" } }For more information, see Copying an Amazon DocumentDB Cluster Parameter Group
in the Amazon DocumentDB Developer Guide. -
For API details, see CopyDbClusterParameterGroup
in Amazon CLI Command Reference.
-
The following code example shows how to use copy-db-cluster-snapshot.
- Amazon CLI
-
To create a copy of a snapshot
The following
copy-db-cluster-snapshotexample makes a copy ofsample-cluster-snapshotnamedsample-cluster-snapshot-copy. The copy has all the tags of the original plus a new tag with the key nameCopyNumber.aws docdb copy-db-cluster-snapshot \ --source-db-cluster-snapshot-identifiersample-cluster-snapshot\ --target-db-cluster-snapshot-identifiersample-cluster-snapshot-copy\ --copy-tags \ --tags Key="CopyNumber",Value="1"This command produces no output.
For more information, see Copying a Cluster Snapshot
in the Amazon DocumentDB Developer Guide. -
For API details, see CopyDbClusterSnapshot
in Amazon CLI Command Reference.
-
The following code example shows how to use create-db-cluster-parameter-group.
- Amazon CLI
-
To create an Amazon DocumentDB cluster parameter group
The following
create-db-cluster-parameter-groupexample creates the DB cluster parameter groupsample-parameter-groupusing thedocdb3.6family.aws docdb create-db-cluster-parameter-group \ --db-cluster-parameter-group-namesample-parameter-group\ --db-parameter-group-familydocdb3.6\ --description"Sample parameter group based on docdb3.6"Output:
{ "DBClusterParameterGroup": { "Description": "Sample parameter group based on docdb3.6", "DBParameterGroupFamily": "docdb3.6", "DBClusterParameterGroupArn": "arn:aws:rds:us-west-2:123456789012:cluster-pg:sample-parameter-group", "DBClusterParameterGroupName": "sample-parameter-group" } }For more information, see Creating an Amazon DocumentDB Cluster Parameter Group
in the Amazon DocumentDB Developer Guide. -
For API details, see CreateDbClusterParameterGroup
in Amazon CLI Command Reference.
-
The following code example shows how to use create-db-cluster-snapshot.
- Amazon CLI
-
To create a manual Amazon DocumentDB cluster snapshot
The following
create-db-cluster-snapshotexample creates an Amazon DB cluster snapshot named sample-cluster-snapshot.aws docdb create-db-cluster-snapshot \ --db-cluster-identifiersample-cluster\ --db-cluster-snapshot-identifiersample-cluster-snapshotOutput:
{ "DBClusterSnapshot": { "MasterUsername": "master-user", "SnapshotCreateTime": "2019-03-18T18:27:14.794Z", "AvailabilityZones": [ "us-west-2a", "us-west-2b", "us-west-2c", "us-west-2d", "us-west-2e", "us-west-2f" ], "SnapshotType": "manual", "DBClusterSnapshotArn": "arn:aws:rds:us-west-2:123456789012:cluster-snapshot:sample-cluster-snapshot", "EngineVersion": "3.6.0", "PercentProgress": 0, "DBClusterSnapshotIdentifier": "sample-cluster-snapshot", "Engine": "docdb", "DBClusterIdentifier": "sample-cluster", "Status": "creating", "ClusterCreateTime": "2019-03-15T20:29:58.836Z", "Port": 0, "StorageEncrypted": false, "VpcId": "vpc-91280df6" } }For more information, see Creating a Manual Cluster Snapshot
in the Amazon DocumentDB Developer Guide. -
For API details, see CreateDbClusterSnapshot
in Amazon CLI Command Reference.
-
The following code example shows how to use create-db-cluster.
- Amazon CLI
-
To create an Amazon DocumentDB cluster
The following
create-db-clusterexample creates an Amazon DocumentDB cluster namedsample-clusterwith the preferred maintenance window on Sundays between 20:30 and 11:00.aws docdb create-db-cluster \ --db-cluster-identifiersample-cluster\ --enginedocdb\ --master-username master-user \ --master-user-passwordpassword \ --preferred-maintenance-windowSun:20:30-Sun:21:00Output:
{ "DBCluster": { "DBClusterParameterGroup": "default.docdb3.6", "AssociatedRoles": [], "DBSubnetGroup": "default", "ClusterCreateTime": "2019-03-18T18:06:34.616Z", "Status": "creating", "Port": 27017, "PreferredMaintenanceWindow": "sun:20:30-sun:21:00", "HostedZoneId": "ZNKXH85TT8WVW", "DBClusterMembers": [], "Engine": "docdb", "DBClusterIdentifier": "sample-cluster", "PreferredBackupWindow": "10:12-10:42", "AvailabilityZones": [ "us-west-2d", "us-west-2f", "us-west-2e" ], "MasterUsername": "master-user", "BackupRetentionPeriod": 1, "ReaderEndpoint": "sample-cluster.cluster-ro-corcjozrlsfc.us-west-2.docdb.amazonaws.com", "VpcSecurityGroups": [ { "VpcSecurityGroupId": "sg-77186e0d", "Status": "active" } ], "StorageEncrypted": false, "DBClusterArn": "arn:aws:rds:us-west-2:123456789012:cluster:sample-cluster", "DbClusterResourceId": "cluster-L3R4YRSBUYDP4GLMTJ2WF5GH5Q", "MultiAZ": false, "Endpoint": "sample-cluster.cluster-corcjozrlsfc.us-west-2.docdb.amazonaws.com", "EngineVersion": "3.6.0" } }For more information, see Creating an Amazon DocumentDB Cluster
in the Amazon DocumentDB Developer Guide. -
For API details, see CreateDbCluster
in Amazon CLI Command Reference.
-
The following code example shows how to use create-db-instance.
- Amazon CLI
-
To create an Amazon DocumentDB cluster instance
The following
create-db-instanceexample code creates the instancesample-cluster-instance-2in the Amazon DocumentDB clustersample-cluster.aws docdb create-db-instance \ --db-cluster-identifiersample-cluster\ --db-instance-classdb.r4.xlarge\ --db-instance-identifiersample-cluster-instance-2\ --enginedocdbOutput:
{ "DBInstance": { "DBInstanceStatus": "creating", "PendingModifiedValues": { "PendingCloudwatchLogsExports": { "LogTypesToEnable": [ "audit" ] } }, "PubliclyAccessible": false, "PreferredBackupWindow": "00:00-00:30", "PromotionTier": 1, "EngineVersion": "3.6.0", "BackupRetentionPeriod": 3, "DBInstanceIdentifier": "sample-cluster-instance-2", "PreferredMaintenanceWindow": "tue:10:28-tue:10:58", "StorageEncrypted": false, "Engine": "docdb", "DBClusterIdentifier": "sample-cluster", "DBSubnetGroup": { "Subnets": [ { "SubnetAvailabilityZone": { "Name": "us-west-2a" }, "SubnetStatus": "Active", "SubnetIdentifier": "subnet-4e26d263" }, { "SubnetAvailabilityZone": { "Name": "us-west-2c" }, "SubnetStatus": "Active", "SubnetIdentifier": "subnet-afc329f4" }, { "SubnetAvailabilityZone": { "Name": "us-west-2d" }, "SubnetStatus": "Active", "SubnetIdentifier": "subnet-53ab3636" }, { "SubnetAvailabilityZone": { "Name": "us-west-2b" }, "SubnetStatus": "Active", "SubnetIdentifier": "subnet-991cb8d0" } ], "DBSubnetGroupDescription": "default", "SubnetGroupStatus": "Complete", "VpcId": "vpc-91280df6", "DBSubnetGroupName": "default" }, "DBInstanceClass": "db.r4.xlarge", "VpcSecurityGroups": [ { "Status": "active", "VpcSecurityGroupId": "sg-77186e0d" } ], "DBInstanceArn": "arn:aws:rds:us-west-2:123456789012:db:sample-cluster-instance-2", "DbiResourceId": "db-XEKJLEMGRV5ZKCARUVA4HO3ITE" } }For more information, see Adding an Amazon DocumentDB Instance to a Cluster
in the Amazon DocumentDB Developer Guide. -
For API details, see CreateDbInstance
in Amazon CLI Command Reference.
-
The following code example shows how to use create-db-subnet-group.
- Amazon CLI
-
To create an Amazon DocumentDB subnet group
The following
create-db-subnet-groupexample creates an Amazon DocumentDB subnet group namedsample-subnet-group.aws docdb create-db-subnet-group \ --db-subnet-group-description"a sample subnet group"\ --db-subnet-group-namesample-subnet-group\ --subnet-ids"subnet-29ab1025""subnet-991cb8d0""subnet-53ab3636"Output:
{ "DBSubnetGroup": { "SubnetGroupStatus": "Complete", "DBSubnetGroupName": "sample-subnet-group", "DBSubnetGroupDescription": "a sample subnet group", "VpcId": "vpc-91280df6", "DBSubnetGroupArn": "arn:aws:rds:us-west-2:123456789012:subgrp:sample-subnet-group", "Subnets": [ { "SubnetStatus": "Active", "SubnetIdentifier": "subnet-53ab3636", "SubnetAvailabilityZone": { "Name": "us-west-2d" } }, { "SubnetStatus": "Active", "SubnetIdentifier": "subnet-991cb8d0", "SubnetAvailabilityZone": { "Name": "us-west-2b" } }, { "SubnetStatus": "Active", "SubnetIdentifier": "subnet-29ab1025", "SubnetAvailabilityZone": { "Name": "us-west-2c" } } ] } }For more information, see Creating an Amazon DocumentDB Subnet Group
in the Amazon DocumentDB Developer Guide. -
For API details, see CreateDbSubnetGroup
in Amazon CLI Command Reference.
-
The following code example shows how to use delete-db-cluster-parameter-group.
- Amazon CLI
-
To delete an Amazon DocumentDB cluster parameter group
The following
delete-db-cluster-parameter-groupexample deletes the Amazon DocumentDB parameter groupsample-parameter-group.aws docdb delete-db-cluster-parameter-group \ --db-cluster-parameter-group-namesample-parameter-groupThis command produces no output.
For more information, see Deleting an Amazon DocumentDB Cluster Parameter Group
in the Amazon DocumentDB Developer Guide. -
For API details, see DeleteDbClusterParameterGroup
in Amazon CLI Command Reference.
-
The following code example shows how to use delete-db-cluster-snapshot.
- Amazon CLI
-
To delete an Amazon DocumentDB cluster snapshot
The following
delete-db-cluster-snapshotexample deletes the Amazon DocumentDB cluster snapshotsample-cluster-snapshot.aws docdb delete-db-cluster-snapshot \ --db-cluster-snapshot-identifiersample-cluster-snapshotOutput:
{ "DBClusterSnapshot": { "DBClusterIdentifier": "sample-cluster", "AvailabilityZones": [ "us-west-2a", "us-west-2b", "us-west-2c", "us-west-2d" ], "DBClusterSnapshotIdentifier": "sample-cluster-snapshot", "VpcId": "vpc-91280df6", "DBClusterSnapshotArn": "arn:aws:rds:us-west-2:123456789012:cluster-snapshot:sample-cluster-snapshot", "EngineVersion": "3.6.0", "Engine": "docdb", "SnapshotCreateTime": "2019-03-18T18:27:14.794Z", "Status": "available", "MasterUsername": "master-user", "ClusterCreateTime": "2019-03-15T20:29:58.836Z", "PercentProgress": 100, "StorageEncrypted": false, "SnapshotType": "manual", "Port": 0 } }For more information, see Deleting a Cluster Snapshot
in the Amazon DocumentDB Developer Guide. -
For API details, see DeleteDbClusterSnapshot
in Amazon CLI Command Reference.
-
The following code example shows how to use delete-db-cluster.
- Amazon CLI
-
To delete an Amazon DocumentDB cluster
The following
delete-db-clusterexample deletes the Amazon DocumentDB clustersample-cluster. No backup of the cluster is made prior to deleting it. NOTE: You must delete all instances associated with the cluster before you can delete it.aws docdb delete-db-cluster \ --db-cluster-identifiersample-cluster\ --skip-final-snapshotOutput:
{ "DBCluster": { "DBClusterIdentifier": "sample-cluster", "DBSubnetGroup": "default", "EngineVersion": "3.6.0", "Engine": "docdb", "LatestRestorableTime": "2019-03-18T18:07:24.610Z", "PreferredMaintenanceWindow": "sun:20:30-sun:21:00", "StorageEncrypted": false, "EarliestRestorableTime": "2019-03-18T18:07:24.610Z", "Port": 27017, "VpcSecurityGroups": [ { "Status": "active", "VpcSecurityGroupId": "sg-77186e0d" } ], "MultiAZ": false, "MasterUsername": "master-user", "DBClusterArn": "arn:aws:rds:us-west-2:123456789012:cluster:sample-cluster", "Status": "available", "PreferredBackupWindow": "10:12-10:42", "ReaderEndpoint": "sample-cluster.cluster-ro-corcjozrlsfc.us-west-2.docdb.amazonaws.com", "AvailabilityZones": [ "us-west-2c", "us-west-2b", "us-west-2a" ], "Endpoint": "sample-cluster.cluster-corcjozrlsfc.us-west-2.docdb.amazonaws.com", "DbClusterResourceId": "cluster-L3R4YRSBUYDP4GLMTJ2WF5GH5Q", "ClusterCreateTime": "2019-03-18T18:06:34.616Z", "AssociatedRoles": [], "DBClusterParameterGroup": "default.docdb3.6", "HostedZoneId": "ZNKXH85TT8WVW", "BackupRetentionPeriod": 1, "DBClusterMembers": [] } }For more information, see Deleting an Amazon DocumentDB Cluster
in the Amazon DocumentDB Developer Guide. -
For API details, see DeleteDbCluster
in Amazon CLI Command Reference.
-
The following code example shows how to use delete-db-instance.
- Amazon CLI
-
To delete an Amazon DocumentDB instance
The following
delete-db-instanceexample deletes the Amazon DocumentDB instancesample-cluster-instance-2.aws docdb delete-db-instance \ --db-instance-identifiersample-cluster-instance-2Output:
{ "DBInstance": { "DBSubnetGroup": { "Subnets": [ { "SubnetAvailabilityZone": { "Name": "us-west-2a" }, "SubnetStatus": "Active", "SubnetIdentifier": "subnet-4e26d263" }, { "SubnetAvailabilityZone": { "Name": "us-west-2c" }, "SubnetStatus": "Active", "SubnetIdentifier": "subnet-afc329f4" }, { "SubnetAvailabilityZone": { "Name": "us-west-2d" }, "SubnetStatus": "Active", "SubnetIdentifier": "subnet-53ab3636" }, { "SubnetAvailabilityZone": { "Name": "us-west-2b" }, "SubnetStatus": "Active", "SubnetIdentifier": "subnet-991cb8d0" } ], "DBSubnetGroupName": "default", "DBSubnetGroupDescription": "default", "VpcId": "vpc-91280df6", "SubnetGroupStatus": "Complete" }, "PreferredBackupWindow": "00:00-00:30", "InstanceCreateTime": "2019-03-18T18:37:33.709Z", "DBInstanceClass": "db.r4.xlarge", "DbiResourceId": "db-XEKJLEMGRV5ZKCARUVA4HO3ITE", "BackupRetentionPeriod": 3, "Engine": "docdb", "VpcSecurityGroups": [ { "Status": "active", "VpcSecurityGroupId": "sg-77186e0d" } ], "AutoMinorVersionUpgrade": true, "PromotionTier": 1, "EngineVersion": "3.6.0", "Endpoint": { "Address": "sample-cluster-instance-2.corcjozrlsfc.us-west-2.docdb.amazonaws.com", "HostedZoneId": "ZNKXH85TT8WVW", "Port": 27017 }, "DBInstanceIdentifier": "sample-cluster-instance-2", "PreferredMaintenanceWindow": "tue:10:28-tue:10:58", "EnabledCloudwatchLogsExports": [ "audit" ], "PendingModifiedValues": {}, "DBInstanceStatus": "deleting", "PubliclyAccessible": false, "DBInstanceArn": "arn:aws:rds:us-west-2:123456789012:db:sample-cluster-instance-2", "DBClusterIdentifier": "sample-cluster", "AvailabilityZone": "us-west-2c", "StorageEncrypted": false } }For more information, see Deleting an Amazon DocumentDB Instance
in the Amazon DocumentDB Developer Guide. -
For API details, see DeleteDbInstance
in Amazon CLI Command Reference.
-
The following code example shows how to use delete-db-subnet-group.
- Amazon CLI
-
To delete an Amazon DocumentDB subnet group
The following
delete-db-subnet-groupexample deletes the Amazon DocumentDB subnet groupsample-subnet-group.aws docdb delete-db-subnet-group \ --db-subnet-group-namesample-subnet-groupThis command produces no output.
For more information, see Deleting an Amazon DocumentDB Subnet Group
in the Amazon DocumentDB Developer Guide. -
For API details, see DeleteDbSubnetGroup
in Amazon CLI Command Reference.
-
The following code example shows how to use describe-db-cluster-parameter-groups.
- Amazon CLI
-
To see the details of one or more Amazon DocumentDB cluster parameter groups
The following
describe-db-cluster-parameter-groupsexample displays details for the Amazon DocumentDB cluster parameter groupcustom3-6-param-grp.aws docdb describe-db-cluster-parameter-groups \ --db-cluster-parameter-group-namecustom3-6-param-grpOutput:
{ "DBClusterParameterGroups": [ { "DBParameterGroupFamily": "docdb3.6", "DBClusterParameterGroupArn": "arn:aws:rds:us-east-1:123456789012:cluster-pg:custom3-6-param-grp", "Description": "Custom docdb3.6 parameter group", "DBClusterParameterGroupName": "custom3-6-param-grp" } ] }For more information, see Viewing Amazon DocumentDB Cluster Parameter Groups
in the Amazon DocumentDB Developer Guide. -
For API details, see DescribeDbClusterParameterGroups
in Amazon CLI Command Reference.
-
The following code example shows how to use describe-db-cluster-parameters.
- Amazon CLI
-
To view the detailed parameter list for an Amazon DocumentDB cluster parameter group.
The following
describe-db-cluster-parametersexample lists the parameters for the Amazon DocumentDB parameter group custom3-6-param-grp.aws docdb describe-db-cluster-parameters \ --db-cluster-parameter-group-namecustom3-6-param-grpOutput:
{ "Parameters": [ { "DataType": "string", "ParameterName": "audit_logs", "IsModifiable": true, "ApplyMethod": "pending-reboot", "Source": "system", "ApplyType": "dynamic", "AllowedValues": "enabled,disabled", "Description": "Enables auditing on cluster.", "ParameterValue": "disabled" }, { "DataType": "string", "ParameterName": "tls", "IsModifiable": true, "ApplyMethod": "pending-reboot", "Source": "system", "ApplyType": "static", "AllowedValues": "disabled,enabled", "Description": "Config to enable/disable TLS", "ParameterValue": "enabled" }, { "DataType": "string", "ParameterName": "ttl_monitor", "IsModifiable": true, "ApplyMethod": "pending-reboot", "Source": "user", "ApplyType": "dynamic", "AllowedValues": "disabled,enabled", "Description": "Enables TTL Monitoring", "ParameterValue": "enabled" } ] }For more information, see Viewing Amazon DocumentDB Cluster Parameters
in the Amazon DocumentDB Developer Guide. -
For API details, see DescribeDbClusterParameters
in Amazon CLI Command Reference.
-
The following code example shows how to use describe-db-cluster-snapshot-attributes.
- Amazon CLI
-
To list an Amazon DocumentDB snapshot attribute names and values
The following
describe-db-cluster-snapshot-attributesexample lists the attribute names and values for the Amazon DocumentDB snapshotsample-cluster-snapshot.aws docdb describe-db-cluster-snapshot-attributes \ --db-cluster-snapshot-identifiersample-cluster-snapshotOutput:
{ "DBClusterSnapshotAttributesResult": { "DBClusterSnapshotAttributes": [ { "AttributeName": "restore", "AttributeValues": [] } ], "DBClusterSnapshotIdentifier": "sample-cluster-snapshot" } }For more information, see DescribeDBClusterSnapshotAttributes
in the Amazon DocumentDB Developer Guide. -
For API details, see DescribeDbClusterSnapshotAttributes
in Amazon CLI Command Reference.
-
The following code example shows how to use describe-db-cluster-snapshots.
- Amazon CLI
-
To describe Amazon DocumentDB snapshots
The following
describe-db-cluster-snapshotsexample displays details for the Amazon DocumentDB snapshotsample-cluster-snapshot.aws docdb describe-db-cluster-snapshots \ --db-cluster-snapshot-identifiersample-cluster-snapshotOutput:
{ "DBClusterSnapshots": [ { "AvailabilityZones": [ "us-west-2a", "us-west-2b", "us-west-2c", "us-west-2d" ], "Status": "available", "DBClusterSnapshotArn": "arn:aws:rds:us-west-2:123456789012:cluster-snapshot:sample-cluster-snapshot", "SnapshotCreateTime": "2019-03-15T20:41:26.515Z", "SnapshotType": "manual", "DBClusterSnapshotIdentifier": "sample-cluster-snapshot", "DBClusterIdentifier": "sample-cluster", "MasterUsername": "master-user", "StorageEncrypted": false, "VpcId": "vpc-91280df6", "EngineVersion": "3.6.0", "PercentProgress": 100, "Port": 0, "Engine": "docdb", "ClusterCreateTime": "2019-03-15T20:29:58.836Z" } ] }For more information, see DescribeDBClusterSnapshots
in the Amazon DocumentDB Developer Guide. -
For API details, see DescribeDbClusterSnapshots
in Amazon CLI Command Reference.
-
The following code example shows how to use describe-db-clusters.
- Amazon CLI
-
To get detailed information about one or more Amazon DocumentDB clusters.
The following
describe-db-clustersexample displays details for the Amazon DocumentDB clustersample-cluster. By omitting the--db-cluster-identifierparameter you can get information of up to 100 clusters.aws docdb describe-db-clusters --db-cluster-identifiersample-clusterOutput:
{ "DBClusters": [ { "DBClusterParameterGroup": "default.docdb3.6", "Endpoint": "sample-cluster.cluster-corcjozrlsfc.us-west-2.docdb.amazonaws.com", "PreferredBackupWindow": "00:00-00:30", "DBClusterIdentifier": "sample-cluster", "ClusterCreateTime": "2019-03-15T20:29:58.836Z", "LatestRestorableTime": "2019-03-18T20:28:03.239Z", "MasterUsername": "master-user", "DBClusterMembers": [ { "PromotionTier": 1, "DBClusterParameterGroupStatus": "in-sync", "IsClusterWriter": false, "DBInstanceIdentifier": "sample-cluster" }, { "PromotionTier": 1, "DBClusterParameterGroupStatus": "in-sync", "IsClusterWriter": true, "DBInstanceIdentifier": "sample-cluster2" } ], "PreferredMaintenanceWindow": "sat:04:30-sat:05:00", "VpcSecurityGroups": [ { "VpcSecurityGroupId": "sg-77186e0d", "Status": "active" } ], "Engine": "docdb", "ReaderEndpoint": "sample-cluster.cluster-ro-corcjozrlsfc.us-west-2.docdb.amazonaws.com", "DBSubnetGroup": "default", "MultiAZ": true, "AvailabilityZones": [ "us-west-2a", "us-west-2c", "us-west-2b" ], "EarliestRestorableTime": "2019-03-15T20:30:47.020Z", "DbClusterResourceId": "cluster-UP4EF2PVDDFVHHDJQTYDAIGHLE", "DBClusterArn": "arn:aws:rds:us-west-2:123456789012:cluster:sample-cluster", "BackupRetentionPeriod": 3, "HostedZoneId": "ZNKXH85TT8WVW", "StorageEncrypted": false, "EnabledCloudwatchLogsExports": [ "audit" ], "AssociatedRoles": [], "EngineVersion": "3.6.0", "Port": 27017, "Status": "available" } ] }For more information, see Describing Amazon DocumentDB Clusters
in the Amazon DocumentDB Developer Guide. -
For API details, see DescribeDbClusters
in Amazon CLI Command Reference.
-
The following code example shows how to use describe-db-engine-versions.
- Amazon CLI
-
To list available Amazon DocumentDB engine versions
The following
describe-db-engine-versionsexample lists all available Amazon DocumentDB engine versions.awsdocdbdescribe-db-engine-versions \ --engine docdbOutput:
{ "DBEngineVersions": [ { "DBEngineVersionDescription": "DocDB version 1.0.200837", "DBParameterGroupFamily": "docdb3.6", "EngineVersion": "3.6.0", "ValidUpgradeTarget": [], "DBEngineDescription": "Amazon DocumentDB (with MongoDB compatibility)", "SupportsLogExportsToCloudwatchLogs": true, "Engine": "docdb", "ExportableLogTypes": [ "audit" ] } ] }For more information, see DescribeDBEngineVersions
in the Amazon DocumentDB Developer Guide. -
For API details, see DescribeDbEngineVersions
in Amazon CLI Command Reference.
-
The following code example shows how to use describe-db-instances.
- Amazon CLI
-
To find information about provisioned Amazon DocumentDB instances
The following
describe-db-instancesexample displays details for about the Amazon DocumentDB instancesample-cluster-instance. By omitting the--db-instance-identifierparameter you get information on up to 100 instances.aws docdb describe-db-instances \ --db-instance-identifiersample-cluster-instanceOutput:
{ "DBInstances": [ { "Endpoint": { "HostedZoneId": "ZNKXH85TT8WVW", "Address": "sample-cluster-instance.corcjozrlsfc.us-west-2.docdb.amazonaws.com", "Port": 27017 }, "PreferredBackupWindow": "00:00-00:30", "DBInstanceStatus": "available", "DBInstanceClass": "db.r4.large", "EnabledCloudwatchLogsExports": [ "audit" ], "DBInstanceIdentifier": "sample-cluster-instance", "DBSubnetGroup": { "Subnets": [ { "SubnetStatus": "Active", "SubnetIdentifier": "subnet-4e26d263", "SubnetAvailabilityZone": { "Name": "us-west-2a" } }, { "SubnetStatus": "Active", "SubnetIdentifier": "subnet-afc329f4", "SubnetAvailabilityZone": { "Name": "us-west-2c" } }, { "SubnetStatus": "Active", "SubnetIdentifier": "subnet-53ab3636", "SubnetAvailabilityZone": { "Name": "us-west-2d" } }, { "SubnetStatus": "Active", "SubnetIdentifier": "subnet-991cb8d0", "SubnetAvailabilityZone": { "Name": "us-west-2b" } } ], "DBSubnetGroupName": "default", "SubnetGroupStatus": "Complete", "DBSubnetGroupDescription": "default", "VpcId": "vpc-91280df6" }, "InstanceCreateTime": "2019-03-15T20:36:06.338Z", "Engine": "docdb", "StorageEncrypted": false, "AutoMinorVersionUpgrade": true, "DBInstanceArn": "arn:aws:rds:us-west-2:123456789012:db:sample-cluster-instance", "PreferredMaintenanceWindow": "tue:08:39-tue:09:09", "VpcSecurityGroups": [ { "Status": "active", "VpcSecurityGroupId": "sg-77186e0d" } ], "DBClusterIdentifier": "sample-cluster", "PendingModifiedValues": {}, "BackupRetentionPeriod": 3, "PubliclyAccessible": false, "EngineVersion": "3.6.0", "PromotionTier": 1, "AvailabilityZone": "us-west-2c", "DbiResourceId": "db-A2GIKUV6KPOHITGGKI2NHVISZA" } ] }For more information, see Describing Amazon DocumentDB Instances
in the Amazon DocumentDB Developer Guide. -
For API details, see DescribeDbInstances
in Amazon CLI Command Reference.
-
The following code example shows how to use describe-db-subnet-groups.
- Amazon CLI
-
To retrieve a list of Amazon DocumentDB subnet descriptions
The following
describe-db-subnet-groupsexample describes details for the Amazon DocumentDB subnet nameddefault.aws docdb describe-db-subnet-groups \ --db-subnet-group-namedefaultOutput:
{ "DBSubnetGroups": [ { "VpcId": "vpc-91280df6", "DBSubnetGroupArn": "arn:aws:rds:us-west-2:123456789012:subgrp:default", "Subnets": [ { "SubnetIdentifier": "subnet-4e26d263", "SubnetStatus": "Active", "SubnetAvailabilityZone": { "Name": "us-west-2a" } }, { "SubnetIdentifier": "subnet-afc329f4", "SubnetStatus": "Active", "SubnetAvailabilityZone": { "Name": "us-west-2c" } }, { "SubnetIdentifier": "subnet-53ab3636", "SubnetStatus": "Active", "SubnetAvailabilityZone": { "Name": "us-west-2d" } }, { "SubnetIdentifier": "subnet-991cb8d0", "SubnetStatus": "Active", "SubnetAvailabilityZone": { "Name": "us-west-2b" } } ], "DBSubnetGroupName": "default", "SubnetGroupStatus": "Complete", "DBSubnetGroupDescription": "default" } ] }For more information, see Describing Subnet Groups
in the Amazon DocumentDB Developer Guide. -
For API details, see DescribeDbSubnetGroups
in Amazon CLI Command Reference.
-
The following code example shows how to use describe-engine-default-cluster-parameters.
- Amazon CLI
-
To describe the default engine and system parameter information for Amazon DocumentDB
The following
describe-engine-default-cluster-parametersexample displays details for the default engine and system parameter information for the Amazon DocumentDB parameter groupdocdb3.6.aws docdb describe-engine-default-cluster-parameters \ --db-parameter-group-familydocdb3.6Output:
{ "EngineDefaults": { "DBParameterGroupFamily": "docdb3.6", "Parameters": [ { "ApplyType": "dynamic", "ParameterValue": "disabled", "Description": "Enables auditing on cluster.", "Source": "system", "DataType": "string", "MinimumEngineVersion": "3.6.0", "AllowedValues": "enabled,disabled", "ParameterName": "audit_logs", "IsModifiable": true }, { "ApplyType": "static", "ParameterValue": "enabled", "Description": "Config to enable/disable TLS", "Source": "system", "DataType": "string", "MinimumEngineVersion": "3.6.0", "AllowedValues": "disabled,enabled", "ParameterName": "tls", "IsModifiable": true }, { "ApplyType": "dynamic", "ParameterValue": "enabled", "Description": "Enables TTL Monitoring", "Source": "system", "DataType": "string", "MinimumEngineVersion": "3.6.0", "AllowedValues": "disabled,enabled", "ParameterName": "ttl_monitor", "IsModifiable": true } ] } }For more information, see DescribeEngineDefaultClusterParameters
in the Amazon DocumentDB Developer Guide. -
For API details, see DescribeEngineDefaultClusterParameters
in Amazon CLI Command Reference.
-
The following code example shows how to use describe-event-categories.
- Amazon CLI
-
To describe all Amazon DocumentDB event categories
The following
describe-event-categoriesexample lists all categories for the Amazon DocumentDB event source typedb-instance.aws docdb describe-event-categories \ --source-typedb-clusterOutput:
{ "EventCategoriesMapList": [ { "SourceType": "db-cluster", "EventCategories": [ "failover", "maintenance", "notification", "failure" ] } ] }For more information, see Viewing Event Categories
in the Amazon DocumentDB Developer Guide. -
For API details, see DescribeEventCategories
in Amazon CLI Command Reference.
-
The following code example shows how to use describe-events.
- Amazon CLI
-
To list Amazon DocumentDB events
The following
describe-eventsexample list all the Amazon DocumentDB events for the last 24 hours (1440 minutes).aws docdb describe-events \ --duration1440This command produces no output. Output:
{ "Events": [ { "EventCategories": [ "failover" ], "Message": "Started cross AZ failover to DB instance: sample-cluster", "Date": "2019-03-18T21:36:29.807Z", "SourceArn": "arn:aws:rds:us-west-2:123456789012:cluster:sample-cluster", "SourceIdentifier": "sample-cluster", "SourceType": "db-cluster" }, { "EventCategories": [ "availability" ], "Message": "DB instance restarted", "Date": "2019-03-18T21:36:40.793Z", "SourceArn": "arn:aws:rds:us-west-2:123456789012:db:sample-cluster", "SourceIdentifier": "sample-cluster", "SourceType": "db-instance" }, { "EventCategories": [], "Message": "A new writer was promoted. Restarting database as a reader.", "Date": "2019-03-18T21:36:43.873Z", "SourceArn": "arn:aws:rds:us-west-2:123456789012:db:sample-cluster2", "SourceIdentifier": "sample-cluster2", "SourceType": "db-instance" }, { "EventCategories": [ "availability" ], "Message": "DB instance restarted", "Date": "2019-03-18T21:36:51.257Z", "SourceArn": "arn:aws:rds:us-west-2:123456789012:db:sample-cluster2", "SourceIdentifier": "sample-cluster2", "SourceType": "db-instance" }, { "EventCategories": [ "failover" ], "Message": "Completed failover to DB instance: sample-cluster", "Date": "2019-03-18T21:36:53.462Z", "SourceArn": "arn:aws:rds:us-west-2:123456789012:cluster:sample-cluster", "SourceIdentifier": "sample-cluster", "SourceType": "db-cluster" }, { "Date": "2019-03-19T16:51:48.847Z", "EventCategories": [ "configuration change" ], "Message": "Updated parameter audit_logs to enabled with apply method pending-reboot", "SourceIdentifier": "custom3-6-param-grp", "SourceType": "db-parameter-group" }, { "EventCategories": [ "configuration change" ], "Message": "Applying modification to database instance class", "Date": "2019-03-19T17:55:20.095Z", "SourceArn": "arn:aws:rds:us-west-2:123456789012:db:sample-cluster2", "SourceIdentifier": "sample-cluster2", "SourceType": "db-instance" }, { "EventCategories": [ "availability" ], "Message": "DB instance shutdown", "Date": "2019-03-19T17:56:31.127Z", "SourceArn": "arn:aws:rds:us-west-2:123456789012:db:sample-cluster2", "SourceIdentifier": "sample-cluster2", "SourceType": "db-instance" }, { "EventCategories": [ "configuration change" ], "Message": "Finished applying modification to DB instance class", "Date": "2019-03-19T18:00:45.822Z", "SourceArn": "arn:aws:rds:us-west-2:123456789012:db:sample-cluster2", "SourceIdentifier": "sample-cluster2", "SourceType": "db-instance" }, { "EventCategories": [ "availability" ], "Message": "DB instance restarted", "Date": "2019-03-19T18:00:53.397Z", "SourceArn": "arn:aws:rds:us-west-2:123456789012:db:sample-cluster2", "SourceIdentifier": "sample-cluster2", "SourceType": "db-instance" }, { "EventCategories": [ "availability" ], "Message": "DB instance shutdown", "Date": "2019-03-19T18:23:36.045Z", "SourceArn": "arn:aws:rds:us-west-2:123456789012:db:sample-cluster2", "SourceIdentifier": "sample-cluster2", "SourceType": "db-instance" }, { "EventCategories": [ "availability" ], "Message": "DB instance restarted", "Date": "2019-03-19T18:23:46.209Z", "SourceArn": "arn:aws:rds:us-west-2:123456789012:db:sample-cluster2", "SourceIdentifier": "sample-cluster2", "SourceType": "db-instance" }, { "Date": "2019-03-19T18:39:05.822Z", "EventCategories": [ "configuration change" ], "Message": "Updated parameter ttl_monitor to enabled with apply method immediate", "SourceIdentifier": "custom3-6-param-grp", "SourceType": "db-parameter-group" }, { "Date": "2019-03-19T18:39:48.067Z", "EventCategories": [ "configuration change" ], "Message": "Updated parameter audit_logs to disabled with apply method immediate", "SourceIdentifier": "custom3-6-param-grp", "SourceType": "db-parameter-group" } ] }For more information, see Viewing Amazon DocumentDB Events
in the Amazon DocumentDB Developer Guide. -
For API details, see DescribeEvents
in Amazon CLI Command Reference.
-
The following code example shows how to use describe-orderable-db-instance-options.
- Amazon CLI
-
To find the Amazon DocumentDB instance options you can order
The following
describe-orderable-db-instance-optionsexample lists all instance options for Amazon DocumentDB for a region.awsdocdbdescribe-orderable-db-instance-options \ --engine docdb \ --regionus-east-1Output:
{ "OrderableDBInstanceOptions": [ { "Vpc": true, "AvailabilityZones": [ { "Name": "us-east-1a" }, { "Name": "us-east-1b" }, { "Name": "us-east-1c" }, { "Name": "us-east-1d" } ], "EngineVersion": "3.6.0", "DBInstanceClass": "db.r4.16xlarge", "LicenseModel": "na", "Engine": "docdb" }, { "Vpc": true, "AvailabilityZones": [ { "Name": "us-east-1a" }, { "Name": "us-east-1b" }, { "Name": "us-east-1c" }, { "Name": "us-east-1d" } } ], "EngineVersion": "3.6.0", "DBInstanceClass": "db.r4.2xlarge", "LicenseModel": "na", "Engine": "docdb" }, { "Vpc": true, "AvailabilityZones": [ { "Name": "us-east-1a" }, { "Name": "us-east-1b" }, { "Name": "us-east-1c" }, { "Name": "us-east-1d" } ], "EngineVersion": "3.6.0", "DBInstanceClass": "db.r4.4xlarge", "LicenseModel": "na", "Engine": "docdb" }, { "Vpc": true, "AvailabilityZones": [ { "Name": "us-east-1a" }, { "Name": "us-east-1b" }, { "Name": "us-east-1c" }, { "Name": "us-east-1d" } ], "EngineVersion": "3.6.0", "DBInstanceClass": "db.r4.8xlarge", "LicenseModel": "na", "Engine": "docdb" }, { "Vpc": true, "AvailabilityZones": [ { "Name": "us-east-1a" }, { "Name": "us-east-1b" }, { "Name": "us-east-1c" }, { "Name": "us-east-1d" } ], "EngineVersion": "3.6.0", "DBInstanceClass": "db.r4.large", "LicenseModel": "na", "Engine": "docdb" }, { "Vpc": true, "AvailabilityZones": [ { "Name": "us-east-1a" }, { "Name": "us-east-1b" }, { "Name": "us-east-1c" }, { "Name": "us-east-1d" } ], "EngineVersion": "3.6.0", "DBInstanceClass": "db.r4.xlarge", "LicenseModel": "na", "Engine": "docdb" } ] }For more information, see Adding an Amazon DocumentDB Instance to a Cluster
in the Amazon DocumentDB Developer Guide. -
For API details, see DescribeOrderableDbInstanceOptions
in Amazon CLI Command Reference.
-
The following code example shows how to use describe-pending-maintenance-actions.
- Amazon CLI
-
To list your pending Amazon DocumentDB maintenance actions
The following
describe-pending-maintenance-actionsexample lists all your pending Amazon DocumentDB maintenance actions.aws docdb describe-pending-maintenance-actionsOutput:
{ "PendingMaintenanceActions": [] }For more information, see Maintaining Amazon DocumentDB
in the Amazon DocumentDB Developer Guide. -
For API details, see DescribePendingMaintenanceActions
in Amazon CLI Command Reference.
-
The following code example shows how to use failover-db-cluster.
- Amazon CLI
-
To force an Amazon DocumentDB cluster to failover to a replica
The following
failover-db-clusterexample causes the primary instance in the Amazon DocumentDB cluster sample-cluster to failover to a replica.aws docdb failover-db-cluster \ --db-cluster-identifiersample-clusterOutput:
{ "DBCluster": { "AssociatedRoles": [], "DBClusterIdentifier": "sample-cluster", "EngineVersion": "3.6.0", "DBSubnetGroup": "default", "MasterUsername": "master-user", "EarliestRestorableTime": "2019-03-15T20:30:47.020Z", "Endpoint": "sample-cluster.cluster-corcjozrlsfc.us-west-2.docdb.amazonaws.com", "AvailabilityZones": [ "us-west-2a", "us-west-2c", "us-west-2b" ], "LatestRestorableTime": "2019-03-18T21:35:23.548Z", "PreferredMaintenanceWindow": "sat:04:30-sat:05:00", "PreferredBackupWindow": "00:00-00:30", "Port": 27017, "VpcSecurityGroups": [ { "VpcSecurityGroupId": "sg-77186e0d", "Status": "active" } ], "StorageEncrypted": false, "ClusterCreateTime": "2019-03-15T20:29:58.836Z", "MultiAZ": true, "Status": "available", "DBClusterMembers": [ { "DBClusterParameterGroupStatus": "in-sync", "IsClusterWriter": false, "DBInstanceIdentifier": "sample-cluster", "PromotionTier": 1 }, { "DBClusterParameterGroupStatus": "in-sync", "IsClusterWriter": true, "DBInstanceIdentifier": "sample-cluster2", "PromotionTier": 2 } ], "EnabledCloudwatchLogsExports": [ "audit" ], "DBClusterParameterGroup": "default.docdb3.6", "HostedZoneId": "ZNKXH85TT8WVW", "DBClusterArn": "arn:aws:rds:us-west-2:123456789012:cluster:sample-cluster", "BackupRetentionPeriod": 3, "DbClusterResourceId": "cluster-UP4EF2PVDDFVHHDJQTYDAIGHLE", "ReaderEndpoint": "sample-cluster.cluster-ro-corcjozrlsfc.us-west-2.docdb.amazonaws.com", "Engine": "docdb" } }For more information, see Amazon DocumentDB Failover
in the Amazon DocumentDB Developer Guide. -
For API details, see FailoverDbCluster
in Amazon CLI Command Reference.
-
The following code example shows how to use list-tags-for-resource.
- Amazon CLI
-
To list all the tags on an Amazon DocumentDB resource
The following
list-tags-for-resourceexample lists all tags on the Amazon DocumentDB clustersample-cluster.aws docdb list-tags-for-resource \ --resource-namearn:aws:rds:us-west-2:123456789012:cluster:sample-clusterOutput:
{ "TagList": [ { "Key": "A", "Value": "ALPHA" }, { "Key": "B", "Value": "" }, { "Key": "C", "Value": "CHARLIE" } ] }For more information, see Listing Tags on an Amazon DocumentDB Resource
in the Amazon DocumentDB Developer Guide. -
For API details, see ListTagsForResource
in Amazon CLI Command Reference.
-
The following code example shows how to use modify-db-cluster-parameter-group.
- Amazon CLI
-
To modify an Amazon DocumentDB DB cluster parameter group
The following
modify-db-cluster-parameter-groupexample modifies the Amazon DocumentDB cluster parameter groupcustom3-6-param-grpby setting the two parametersaudit_logsandttl_monitorto enabled. The changes are applied at the next reboot.aws docdb modify-db-cluster-parameter-group \ --db-cluster-parameter-group-namecustom3-6-param-grp\ --parametersParameterName=audit_logs,ParameterValue=enabled,ApplyMethod=pending-reboot\ParameterName=ttl_monitor,ParameterValue=enabled,ApplyMethod=pending-rebootOutput:
{ "DBClusterParameterGroupName": "custom3-6-param-grp" }For more information, see Modifying an Amazon DocumentDB Cluster Parameter Group
in the Amazon DocumentDB Developer Guide. -
For API details, see ModifyDbClusterParameterGroup
in Amazon CLI Command Reference.
-
The following code example shows how to use modify-db-cluster-snapshot-attribute.
- Amazon CLI
-
Example 1: To add an attribute to an Amazon DocumentDB snapshot
The following
modify-db-cluster-snapshot-attributeexample adds four attribute values to an Amazon DocumentDB cluster snapshot.aws docdb modify-db-cluster-snapshot-attribute \ --db-cluster-snapshot-identifiersample-cluster-snapshot\ --attribute-namerestore\ --values-to-add123456789011123456789012123456789013Output:
{ "DBClusterSnapshotAttributesResult": { "DBClusterSnapshotAttributes": [ { "AttributeName": "restore", "AttributeValues": [ "123456789011", "123456789012", "123456789013" ] } ], "DBClusterSnapshotIdentifier": "sample-cluster-snapshot" } }Example 2: To remove attributes from an Amazon DocumentDB snapshot
The following
modify-db-cluster-snapshot-attributeexample removes two attribute values from an Amazon DocumentDB cluster snapshot.aws docdb modify-db-cluster-snapshot-attribute \ --db-cluster-snapshot-identifiersample-cluster-snapshot\ --attribute-namerestore\ --values-to-remove123456789012Output:
{ "DBClusterSnapshotAttributesResult": { "DBClusterSnapshotAttributes": [ { "AttributeName": "restore", "AttributeValues": [ "123456789011", "123456789013" ] } ], "DBClusterSnapshotIdentifier": "sample-cluster-snapshot" } }For more information, see ModifyDBClusterSnapshotAttribute
in the Amazon DocumentDB Developer Guide. -
For API details, see ModifyDbClusterSnapshotAttribute
in Amazon CLI Command Reference.
-
The following code example shows how to use modify-db-cluster.
- Amazon CLI
-
To modify an Amazon DocumentDB cluster
The following
modify-db-clusterexample modifies the Amazon DocumentDB clustersample-clusterby making the retention period for automatic backups 7 days, and changing the preferred windows for both backups and maintenance. All changes are applied at the next maintenance window.aws docdb modify-db-cluster \ --db-cluster-identifiersample-cluster\ --no-apply-immediately \ --backup-retention-period7\ --preferred-backup-window18:00-18:30\ --preferred-maintenance-windowsun:20:00-sun:20:30Output:
{ "DBCluster": { "Endpoint": "sample-cluster.cluster-corcjozrlsfc.us-west-2.docdb.amazonaws.com", "DBClusterMembers": [ { "DBClusterParameterGroupStatus": "in-sync", "DBInstanceIdentifier": "sample-cluster", "IsClusterWriter": true, "PromotionTier": 1 }, { "DBClusterParameterGroupStatus": "in-sync", "DBInstanceIdentifier": "sample-cluster2", "IsClusterWriter": false, "PromotionTier": 2 } ], "HostedZoneId": "ZNKXH85TT8WVW", "StorageEncrypted": false, "PreferredBackupWindow": "18:00-18:30", "MultiAZ": true, "EngineVersion": "3.6.0", "MasterUsername": "master-user", "ReaderEndpoint": "sample-cluster.cluster-ro-corcjozrlsfc.us-west-2.docdb.amazonaws.com", "DBSubnetGroup": "default", "LatestRestorableTime": "2019-03-18T22:08:13.408Z", "EarliestRestorableTime": "2019-03-15T20:30:47.020Z", "PreferredMaintenanceWindow": "sun:20:00-sun:20:30", "AssociatedRoles": [], "EnabledCloudwatchLogsExports": [ "audit" ], "Engine": "docdb", "DBClusterParameterGroup": "default.docdb3.6", "DBClusterArn": "arn:aws:rds:us-west-2:123456789012:cluster:sample-cluster", "BackupRetentionPeriod": 7, "DBClusterIdentifier": "sample-cluster", "AvailabilityZones": [ "us-west-2a", "us-west-2c", "us-west-2b" ], "Status": "available", "DbClusterResourceId": "cluster-UP4EF2PVDDFVHHDJQTYDAIGHLE", "ClusterCreateTime": "2019-03-15T20:29:58.836Z", "VpcSecurityGroups": [ { "VpcSecurityGroupId": "sg-77186e0d", "Status": "active" } ], "Port": 27017 } }For more information, see Modifying an Amazon DocumentDB Cluster
in the Amazon DocumentDB Developer Guide. -
For API details, see ModifyDbCluster
in Amazon CLI Command Reference.
-
The following code example shows how to use modify-db-instance.
- Amazon CLI
-
To modify an Amazon DocumentDB instance
The following
modify-db-instanceexample modifies the Amazon DocumentDB instancesample-cluster2by changing its instance class todb.r4.4xlargeand its promotion tier to5. The changes are applied immediately but can only be seen after the instances status is available.aws docdb modify-db-instance \ --db-instance-identifiersample-cluster2\ --apply-immediately \ --db-instance-classdb.r4.4xlarge\ --promotion-tier5Output:
{ "DBInstance": { "EngineVersion": "3.6.0", "StorageEncrypted": false, "DBInstanceClass": "db.r4.large", "PreferredMaintenanceWindow": "mon:08:39-mon:09:09", "AutoMinorVersionUpgrade": true, "VpcSecurityGroups": [ { "VpcSecurityGroupId": "sg-77186e0d", "Status": "active" } ], "PreferredBackupWindow": "18:00-18:30", "EnabledCloudwatchLogsExports": [ "audit" ], "AvailabilityZone": "us-west-2f", "DBInstanceIdentifier": "sample-cluster2", "InstanceCreateTime": "2019-03-15T20:36:06.338Z", "Engine": "docdb", "BackupRetentionPeriod": 7, "DBSubnetGroup": { "DBSubnetGroupName": "default", "DBSubnetGroupDescription": "default", "SubnetGroupStatus": "Complete", "Subnets": [ { "SubnetIdentifier": "subnet-4e26d263", "SubnetAvailabilityZone": { "Name": "us-west-2a" }, "SubnetStatus": "Active" }, { "SubnetIdentifier": "subnet-afc329f4", "SubnetAvailabilityZone": { "Name": "us-west-2c" }, "SubnetStatus": "Active" }, { "SubnetIdentifier": "subnet-53ab3636", "SubnetAvailabilityZone": { "Name": "us-west-2d" }, "SubnetStatus": "Active" }, { "SubnetIdentifier": "subnet-991cb8d0", "SubnetAvailabilityZone": { "Name": "us-west-2b" }, "SubnetStatus": "Active" } ], "VpcId": "vpc-91280df6" }, "PromotionTier": 2, "Endpoint": { "Address": "sample-cluster2.corcjozrlsfc.us-west-2.docdb.amazonaws.com", "HostedZoneId": "ZNKXH85TT8WVW", "Port": 27017 }, "DbiResourceId": "db-A2GIKUV6KPOHITGGKI2NHVISZA", "DBClusterIdentifier": "sample-cluster", "DBInstanceArn": "arn:aws:rds:us-west-2:123456789012:db:sample-cluster2", "PendingModifiedValues": { "DBInstanceClass": "db.r4.4xlarge" }, "PubliclyAccessible": false, "DBInstanceStatus": "available" } }For more information, see Modifying an Amazon DocumentDB Instance
in the Amazon DocumentDB Developer Guide. -
For API details, see ModifyDbInstance
in Amazon CLI Command Reference.
-
The following code example shows how to use modify-db-subnet-group.
- Amazon CLI
-
To modify an Amazon DocumentDB subnet group
The following
modify-db-subnet-groupexample modifies the subnet groupsample-subnet-groupby adding the specified subnets and a new description.aws docdb modify-db-subnet-group \ --db-subnet-group-namesample-subnet-group\ --subnet-idssubnet-b3806e8fsubnet-53ab3636subnet-991cb8d0\ --db-subnet-group-description"New subnet description"Output:
{ "DBSubnetGroup": { "DBSubnetGroupName": "sample-subnet-group", "SubnetGroupStatus": "Complete", "DBSubnetGroupArn": "arn:aws:rds:us-west-2:123456789012:subgrp:sample-subnet-group", "VpcId": "vpc-91280df6", "DBSubnetGroupDescription": "New subnet description", "Subnets": [ { "SubnetIdentifier": "subnet-b3806e8f", "SubnetStatus": "Active", "SubnetAvailabilityZone": { "Name": "us-west-2a" } }, { "SubnetIdentifier": "subnet-53ab3636", "SubnetStatus": "Active", "SubnetAvailabilityZone": { "Name": "us-west-2c" } }, { "SubnetIdentifier": "subnet-991cb8d0", "SubnetStatus": "Active", "SubnetAvailabilityZone": { "Name": "us-west-2b" } } ] } }For more information, see Modifying an Amazon DocumentDB Subnet Group
in the Amazon DocumentDB Developer Guide. -
For API details, see ModifyDbSubnetGroup
in Amazon CLI Command Reference.
-
The following code example shows how to use reboot-db-instance.
- Amazon CLI
-
To reboot an Amazon DocumentDB instance
The following
reboot-db-instanceexample reboots the Amazon DocumentDB instancesample-cluster2.aws docdb reboot-db-instance \ --db-instance-identifiersample-cluster2This command produces no output. Output:
{ "DBInstance": { "PreferredBackupWindow": "18:00-18:30", "DBInstanceIdentifier": "sample-cluster2", "VpcSecurityGroups": [ { "Status": "active", "VpcSecurityGroupId": "sg-77186e0d" } ], "DBSubnetGroup": { "VpcId": "vpc-91280df6", "Subnets": [ { "SubnetStatus": "Active", "SubnetAvailabilityZone": { "Name": "us-west-2a" }, "SubnetIdentifier": "subnet-4e26d263" }, { "SubnetStatus": "Active", "SubnetAvailabilityZone": { "Name": "us-west-2c" }, "SubnetIdentifier": "subnet-afc329f4" }, { "SubnetStatus": "Active", "SubnetAvailabilityZone": { "Name": "us-west-2d" }, "SubnetIdentifier": "subnet-53ab3636" }, { "SubnetStatus": "Active", "SubnetAvailabilityZone": { "Name": "us-west-2b" }, "SubnetIdentifier": "subnet-991cb8d0" } ], "SubnetGroupStatus": "Complete", "DBSubnetGroupName": "default", "DBSubnetGroupDescription": "default" }, "PendingModifiedValues": {}, "Endpoint": { "Address": "sample-cluster2.corcjozrlsfc.us-west-2.docdb.amazonaws.com", "HostedZoneId": "ZNKXH85TT8WVW", "Port": 27017 }, "EnabledCloudwatchLogsExports": [ "audit" ], "StorageEncrypted": false, "DbiResourceId": "db-A2GIKUV6KPOHITGGKI2NHVISZA", "AutoMinorVersionUpgrade": true, "Engine": "docdb", "InstanceCreateTime": "2019-03-15T20:36:06.338Z", "EngineVersion": "3.6.0", "PromotionTier": 5, "BackupRetentionPeriod": 7, "DBClusterIdentifier": "sample-cluster", "PreferredMaintenanceWindow": "mon:08:39-mon:09:09", "PubliclyAccessible": false, "DBInstanceClass": "db.r4.4xlarge", "AvailabilityZone": "us-west-2d", "DBInstanceArn": "arn:aws:rds:us-west-2:123456789012:db:sample-cluster2", "DBInstanceStatus": "rebooting" } }For more information, see Rebooting an Amazon DocumentDB ILnstance
in the Amazon DocumentDB Developer Guide. -
For API details, see RebootDbInstance
in Amazon CLI Command Reference.
-
The following code example shows how to use remove-tags-from-resource.
- Amazon CLI
-
To remove tags from an Amazon DocumentDB resource
The following
remove-tags-from-resourceexample removes the tag with the key namedBfrom the Amazon DocumentDB clustersample-cluster.aws docdb remove-tags-from-resource \ --resource-namearn:aws:rds:us-west-2:123456789012:cluster:sample-cluster\ --tag-keysBThis command produces no output.
For more information, see Removing Tags from an Amazon DocumentDBResource
in the Amazon DocumentDB Developer Guide. -
For API details, see RemoveTagsFromResource
in Amazon CLI Command Reference.
-
The following code example shows how to use reset-db-cluster-parameter-group.
- Amazon CLI
-
To reset the specified parameter value to its defaults in an Amazon DocumentDB parameter group
The following
reset-db-cluster-parameter-groupexample resets the parameterttl_monitorin the Amazon DocumentDB parameter groupcustom3-6-param-grpto its default value.aws docdb reset-db-cluster-parameter-group \ --db-cluster-parameter-group-namecustom3-6-param-grp\ --parametersParameterName=ttl_monitor,ApplyMethod=immediateOutput:
{ "DBClusterParameterGroupName": "custom3-6-param-grp" }For more information, see title in the Amazon DocumentDB Developer Guide.
To reset specified or all parameter values to their defaults in an Amazon DocumentDB parameter group
The following
reset-db-cluster-parameter-groupexample resets all parameters in the Amazon DocumentDB parameter groupcustom3-6-param-grpto their default value.aws docdb reset-db-cluster-parameter-group \ --db-cluster-parameter-group-namecustom3-6-param-grp\ --reset-all-parametersOutput:
{ "DBClusterParameterGroupName": "custom3-6-param-grp" }For more information, see Resetting an Amazon DocumentDB Cluster Parameter Group
in the Amazon DocumentDB Developer Guide. -
For API details, see ResetDbClusterParameterGroup
in Amazon CLI Command Reference.
-
The following code example shows how to use restore-db-cluster-from-snapshot.
- Amazon CLI
-
To restore an Amazon DocumentDB cluster from an automatic or manual snapshot
The following
restore-db-cluster-from-snapshotexample creates a new Amazon DocumentDB cluster namedsample-cluster-2019-03-16-00-01-restoredfrom the snapshotrds:sample-cluster-2019-03-16-00-01.aws docdb restore-db-cluster-from-snapshot \ --db-cluster-identifiersample-cluster-2019-03-16-00-01-restored\ --enginedocdb\ --snapshot-identifierrds:sample-cluster-2019-03-16-00-01Output:
{ "DBCluster": { "ClusterCreateTime": "2019-03-19T18:45:01.857Z", "HostedZoneId": "ZNKXH85TT8WVW", "Engine": "docdb", "DBClusterMembers": [], "MultiAZ": false, "AvailabilityZones": [ "us-west-2a", "us-west-2c", "us-west-2b" ], "StorageEncrypted": false, "ReaderEndpoint": "sample-cluster-2019-03-16-00-01-restored.cluster-ro-corcjozrlsfc.us-west-2.docdb.amazonaws.com", "Endpoint": "sample-cluster-2019-03-16-00-01-restored.cluster-corcjozrlsfc.us-west-2.docdb.amazonaws.com", "Port": 27017, "PreferredBackupWindow": "00:00-00:30", "DBSubnetGroup": "default", "DBClusterIdentifier": "sample-cluster-2019-03-16-00-01-restored", "PreferredMaintenanceWindow": "sat:04:30-sat:05:00", "DBClusterArn": "arn:aws:rds:us-west-2:123456789012:cluster:sample-cluster-2019-03-16-00-01-restored", "DBClusterParameterGroup": "default.docdb3.6", "DbClusterResourceId": "cluster-XOO46Q3RH4LWSYNH3NMZKXPISU", "MasterUsername": "master-user", "EngineVersion": "3.6.0", "BackupRetentionPeriod": 3, "AssociatedRoles": [], "Status": "creating", "VpcSecurityGroups": [ { "Status": "active", "VpcSecurityGroupId": "sg-77186e0d" } ] } }For more information, see Restoring from a Cluster Snapshot
in the Amazon DocumentDB Developer Guide. -
For API details, see RestoreDbClusterFromSnapshot
in Amazon CLI Command Reference.
-
The following code example shows how to use restore-db-cluster-to-point-in-time.
- Amazon CLI
-
To restore an Amazon DocumentDB cluster to a point-in-time from a manual snapshot
The following
restore-db-cluster-to-point-in-timeexample uses thesample-cluster-snapshotto create a new Amazon DocumentDB cluster,sample-cluster-pit, using the latest restorable time.aws docdb restore-db-cluster-to-point-in-time \ --db-cluster-identifiersample-cluster-pit\ --source-db-cluster-identifierarn:aws:rds:us-west-2:123456789012:cluster:sample-cluster\ --use-latest-restorable-timeOutput:
{ "DBCluster": { "StorageEncrypted": false, "BackupRetentionPeriod": 3, "MasterUsername": "master-user", "HostedZoneId": "ZNKXH85TT8WVW", "PreferredBackupWindow": "00:00-00:30", "MultiAZ": false, "DBClusterIdentifier": "sample-cluster-pit", "DBSubnetGroup": "default", "ClusterCreateTime": "2019-04-03T15:55:21.320Z", "AssociatedRoles": [], "DBClusterParameterGroup": "default.docdb3.6", "DBClusterMembers": [], "Status": "creating", "AvailabilityZones": [ "us-west-2a", "us-west-2d", "us-west-2b" ], "ReaderEndpoint": "sample-cluster-pit.cluster-ro-corcjozrlsfc.us-west-2.docdb.amazonaws.com", "Port": 27017, "Engine": "docdb", "EngineVersion": "3.6.0", "VpcSecurityGroups": [ { "VpcSecurityGroupId": "sg-77186e0d", "Status": "active" } ], "PreferredMaintenanceWindow": "sat:04:30-sat:05:00", "Endpoint": "sample-cluster-pit.cluster-corcjozrlsfc.us-west-2.docdb.amazonaws.com", "DbClusterResourceId": "cluster-NLCABBXOSE2QPQ4GOLZIFWEPLM", "DBClusterArn": "arn:aws:rds:us-west-2:123456789012:cluster:sample-cluster-pit" } }For more information, see Restoring a Snapshot to a Point in Time
in the Amazon DocumentDB Developer Guide. -
For API details, see RestoreDbClusterToPointInTime
in Amazon CLI Command Reference.
-
The following code example shows how to use start-db-cluster.
- Amazon CLI
-
To start a stopped Amazon DocumentDB cluster
The following
start-db-clusterexample starts the specified Amazon DocumentDB cluster.aws docdb start-db-cluster \ --db-cluster-identifiersample-clusterOutput:
{ "DBCluster": { "ClusterCreateTime": "2019-03-19T18:45:01.857Z", "HostedZoneId": "ZNKXH85TT8WVW", "Engine": "docdb", "DBClusterMembers": [], "MultiAZ": false, "AvailabilityZones": [ "us-east-1a", "us-east-1c", "us-east-1f" ], "StorageEncrypted": false, "ReaderEndpoint": "sample-cluster-2019-03-16-00-01-restored.cluster-ro-corcjozrlsfc.us-east-1.docdb.amazonaws.com", "Endpoint": "sample-cluster-2019-03-16-00-01-restored.cluster-corcjozrlsfc.us-east-1.docdb.amazonaws.com", "Port": 27017, "PreferredBackupWindow": "00:00-00:30", "DBSubnetGroup": "default", "DBClusterIdentifier": "sample-cluster-2019-03-16-00-01-restored", "PreferredMaintenanceWindow": "sat:04:30-sat:05:00", "DBClusterArn": "arn:aws:rds:us-east-1:123456789012:cluster:sample-cluster-2019-03-16-00-01-restored", "DBClusterParameterGroup": "default.docdb3.6", "DbClusterResourceId": "cluster-XOO46Q3RH4LWSYNH3NMZKXPISU", "MasterUsername": "master-user", "EngineVersion": "3.6.0", "BackupRetentionPeriod": 3, "AssociatedRoles": [], "Status": "creating", "VpcSecurityGroups": [ { "Status": "active", "VpcSecurityGroupId": "sg-77186e0d" } ] } }For more information, see Stopping and Starting an Amazon DocumentDB Cluster
in the Amazon DocumentDB Developer Guide. -
For API details, see StartDbCluster
in Amazon CLI Command Reference.
-
The following code example shows how to use stop-db-cluster.
- Amazon CLI
-
To stop a running Amazon DocumentDB cluster
The following
stop-db-clusterexample stops the specified Amazon DocumentDB cluster.aws docdb stop-db-cluster \ --db-cluster-identifiersample-clusterOutput:
{ "DBCluster": { "ClusterCreateTime": "2019-03-19T18:45:01.857Z", "HostedZoneId": "ZNKXH85TT8WVW", "Engine": "docdb", "DBClusterMembers": [], "MultiAZ": false, "AvailabilityZones": [ "us-east-1a", "us-east-1c", "us-east-1f" ], "StorageEncrypted": false, "ReaderEndpoint": "sample-cluster-2019-03-16-00-01-restored.cluster-ro-corcjozrlsfc.us-east-1.docdb.amazonaws.com", "Endpoint": "sample-cluster-2019-03-16-00-01-restored.cluster-corcjozrlsfc.us-east-1.docdb.amazonaws.com", "Port": 27017, "PreferredBackupWindow": "00:00-00:30", "DBSubnetGroup": "default", "DBClusterIdentifier": "sample-cluster-2019-03-16-00-01-restored", "PreferredMaintenanceWindow": "sat:04:30-sat:05:00", "DBClusterArn": "arn:aws:rds:us-east-1:123456789012:cluster:sample-cluster-2019-03-16-00-01-restored", "DBClusterParameterGroup": "default.docdb3.6", "DbClusterResourceId": "cluster-XOO46Q3RH4LWSYNH3NMZKXPISU", "MasterUsername": "master-user", "EngineVersion": "3.6.0", "BackupRetentionPeriod": 3, "AssociatedRoles": [], "Status": "creating", "VpcSecurityGroups": [ { "Status": "active", "VpcSecurityGroupId": "sg-77186e0d" } ] } }For more information, see Stopping and Starting an Amazon DocumentDB Cluster
in the Amazon DocumentDB Developer Guide. -
For API details, see StopDbCluster
in Amazon CLI Command Reference.
-