Skip to content

Instantly share code, notes, and snippets.

@AstroTom
Last active August 14, 2025 00:07
Show Gist options
  • Save AstroTom/5dc863a0203eca760868f7909de7e306 to your computer and use it in GitHub Desktop.
Save AstroTom/5dc863a0203eca760868f7909de7e306 to your computer and use it in GitHub Desktop.

Revisions

  1. AstroTom revised this gist Aug 14, 2025. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion rds.sh
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,5 @@
    ##
    ## some usefule RDS CLI
    ## some useful RDS CLI
    ##

    # RDS events
  2. AstroTom created this gist Aug 13, 2025.
    36 changes: 36 additions & 0 deletions rds.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,36 @@
    ##
    ## some usefule RDS CLI
    ##

    # RDS events
    # Returns events related to DB instances, DB clusters, DB parameter groups, DB security groups,
    # DB snapshots, DB cluster snapshots, and RDS Proxies for the past 14 days

    # e.g. See changes to Parameter groups
    aws rds describe-events --source-identifier your_parameter_group_name --source-type db-parameter-group

    # RDS events (same as console)
    aws rds describe-events --source-identifier your_db_instance_name --source-type db-instance

    export AWS_DEFAULT_REGION=us-east-1
    INSTANCE_ID=your_db_instance_name
    DATE=$(date +%Y-%m-%dT%H:%M:%S --date='- 14 day ago')
    DATE=$(date +%Y-%m-%dT%H:%M:%S --date='- 13 day - 16 hour ago')

    aws rds describe-db-instances --db-instance-identifier ${INSTANCE_ID}
    aws rds describe-events --source-type db-instance --source-identifier ${INSTANCE_ID} --start-time ${DATE}

    DB_INSTANCE=DB_NAME

    # get list of DB logs
    aws rds describe-db-log-files --db-instance-identifier $DB_INSTANCE

    # download 1 log file
    aws rds download-db-log-file-portion --db-instance-identifier $DB_INSTANCE \
    --log-file-name error/postgresql.log.2025-08-12-17 \
    --starting-token 0 \
    --output text > log.2025-08-12-17.txt