-
Notifications
You must be signed in to change notification settings - Fork 0
Provisioning the AWS RDS instance

Now we are ready to create our AWS RDS instance:
aws rds create-db-instance `
--db-instance-identifier sakila-aws `
--db-instance-class db.t2.micro --engine mysql `
--master-username "admindb" `
--master-user-password "my-password" `
--engine-version 8.0.26 `
--storage-type gp2 `
--publicly-accessible `
--allocated-storage 19
The output tells us the status of the RDS instance creation is Creating
. Therefore the endpoint address is not available yet. It takes on average 10 minutes for the instance to be on available
status
To obtain the endpoint of the RDS DB, this is possible with just calling a describe-db-instances statement
. As the output of this command its quite lengthy, to only retrieve the basic information we need such as DBInstanceIdentifier, Endpoint, etc, we can use the --filter
or --query
options to filter responses. As the --filter option is supported by a limited number of AWS commands and sub-commands, I prefer to use --query
. This option can be used with all AWS commands and uses exclusively the JMESPath
JSON scripting language.
--query
operates in the actual JSON response and does not need support from the AWS API to support on the filtering.
To query out new RDS:
aws rds describe-db-instances `
--db-instance-identifier sakila-aws `
--query 'DBInstances[].Endpoint[].Address[]'
In this way we are getting the information we want. However with the help of the db-instance-available
command, we could combine the three commands with pipes and ask AWS the following:
"Create my DB, wait until the InstanceStatus becomes Available
, then give me the basic information"
aws rds create-db-instance `
--db-instance-identifier sakila-aws `
--db-instance-class db.t2.micro `
--engine mysql `
--master-username "admindb" `
--master-user-password "my-password" `
--engine-version 8.0.26 `
--storage-type gp2 `
--publicly-accessible `
--allocated-storage 20 | `
aws rds wait db-instance-available `
--db-instance-identifier sakila-aws | `
aws rds describe-db-instances `
--db-instance-identifier sakila-aws `
--query "DBInstances[*].[Engine,DBInstanceIdentifier,EngineVersion,DBInstanceStatus,`
Endpoint.Address,AllocatedStorage,DBInstanceClass,MasterUsername,Endpoint.Port]"
Now we have the database access credentials:
-
User: admindb
-
Endpoint: sakila-aws.cxrtws4xiav1.eu-central-1.rds.amazonaws.com
-
Master-password: my-password
aws rds modify-db-instance `
--db-instance-identifier "sakila-aws" `
--db-parameter-group-name "superuser"
aws ec2 describe-security-groups `
--group-names default `
--query 'SecurityGroups[*].[GroupId]'