diff --git a/knowledge base/cloud computing/aws/README.md b/knowledge base/cloud computing/aws/README.md index c738f73..7346577 100644 --- a/knowledge base/cloud computing/aws/README.md +++ b/knowledge base/cloud computing/aws/README.md @@ -817,6 +817,8 @@ Available discount options: Order of application: reserved instances -> Savings plans (EC2 instances -> Compute) +Also check [Branko Petric's X posts] for further suggestions. + ### Free Tier **New** AWS customers get **1 year** of free tier access to **selected** services only. @@ -1248,6 +1250,7 @@ If one can, prefer just build the image from an EC2 instance. [aws config tutorial by stephane maarek]: https://www.youtube.com/watch?v=qHdFoYSrUvk [AWS Fundamentals Blog]: https://awsfundamentals.com/blog [aws savings plans vs. reserved instances: when to use each]: https://www.cloudzero.com/blog/savings-plans-vs-reserved-instances/ +[Branko Petric's X posts]: https://x.com/brankopetric00 [date & time policy conditions at aws - 1-minute iam lesson]: https://www.youtube.com/watch?v=4wpKP1HLEXg [difference in boto3 between resource, client, and session?]: https://stackoverflow.com/questions/42809096/difference-in-boto3-between-resource-client-and-session [Gateway Endpoints vs Internet Routing for S3]: https://awsfundamentals.com/blog/gateway-endpoints-vs-internet-routing-s3 @@ -1255,7 +1258,7 @@ If one can, prefer just build the image from an EC2 instance. [Introduction to the AWS Virtual Private Cloud (VPC) - Part 2]: https://awsfundamentals.com/blog/introduction-to-the-aws-virtual-private-cloud-vpc-part-2 [Introduction to the AWS Virtual Private Cloud (VPC) - Part 3]: https://awsfundamentals.com/blog/amazon-vpc-introduction-part-3 [Learn AWS]: https://www.learnaws.org/ +[The $1,000 AWS mistake]: https://www.geocod.io/code-and-coordinates/2025-11-18-the-1000-aws-mistake/ [using aws kms via the cli with a symmetric key]: https://nsmith.net/aws-kms-cli [VPC Endpoints: Secure and Direct Access to AWS Services]: https://awsfundamentals.com/blog/vpc-endpoints [What Is OIDC and Why Do We Need It?]: https://awsfundamentals.com/blog/oidc-introduction -[The $1,000 AWS mistake]: https://www.geocod.io/code-and-coordinates/2025-11-18-the-1000-aws-mistake/ diff --git a/knowledge base/cloud computing/aws/rds.md b/knowledge base/cloud computing/aws/rds.md index 1b1f9f1..49392bd 100644 --- a/knowledge base/cloud computing/aws/rds.md +++ b/knowledge base/cloud computing/aws/rds.md @@ -17,6 +17,9 @@ 1. [Multi-AZ instances](#multi-az-instances) 1. [Converting instances between Multi-AZ and Single-AZ](#converting-instances-between-multi-az-and-single-az) 1. [Operations](#operations) + 1. [Upgrade the engine version](#upgrade-the-engine-version) + 1. [Upgrade to a new major version](#upgrade-to-a-new-major-version) + 1. [Upgrade to a new minor version](#upgrade-to-a-new-minor-version) 1. [PostgreSQL: reduce allocated storage by migrating using transportable databases](#postgresql-reduce-allocated-storage-by-migrating-using-transportable-databases) 1. [Stop instances](#stop-instances) 1. [Cancel pending modifications](#cancel-pending-modifications) @@ -151,6 +154,20 @@ aws rds cancel-export-task --export-task-identifier 'my_export' # Change the storage type. aws rds modify-db-instance --db-instance-identifier 'instance-name' --storage-type 'gp3' --apply-immediately + + +# Show available upgrade target versions for a given DB engine version. +aws rds describe-db-engine-versions --engine 'postgres' --engine-version '13' \ + --query 'DBEngineVersions[*].ValidUpgradeTarget[*]' +aws rds describe-db-engine-versions --engine 'postgres' --engine-version '13.12' \ + --query 'DBEngineVersions[*].ValidUpgradeTarget[*].{AutoUpgrade:AutoUpgrade,EngineVersion:EngineVersion}[?AutoUpgrade==`true`][]' + +# Start upgrading. +# Requires downtime. +aws rds modify-db-instance --db-instance-identifier 'my-db-instance' \ + --engine-version '14.15' --allow-major-version-upgrade --no-apply-immediately +aws rds modify-db-instance --db-instance-identifier 'my-db-instance' \ + --engine-version '14.20' --apply-immediately ``` @@ -600,6 +617,72 @@ deletes only the secondary instance and volumes. The change does **not** typical ## Operations +### Upgrade the engine version + +> [!caution] +> Database engine upgrades require downtime.
+> Minimize the downtime by using a blue/green deployment. + +In general, **major** engine version upgrades can introduce breaking changes.
+**Minor** version upgrades usually only include changes that are backward-compatible with existing applications. + +At the time of writing, multi-AZ DB clusters only support major version upgrades of PostgreSQL.
+Minor version upgrades are supported for **all** engines. + +> [!important] +> One **cannot** modify a DB instance when it is being upgraded. +> +> During an engine upgrade, the DB instance status changes to `upgrading`.
+> This prevents further changes to the instance while the process is being carried out. + +#### Upgrade to a new major version + +Manually modify a DB engine version through the Console, CLI, or RDS API: + +```sh +# Show available upgrade target versions for a given DB engine version. +aws rds describe-db-engine-versions \ + --engine 'postgres' --engine-version '13' \ + --query 'DBEngineVersions[*].ValidUpgradeTarget[*]' + +# Start upgrading. +aws rds modify-db-instance --db-instance-identifier 'my-db-instance' \ + --engine-version '14.15' --allow-major-version-upgrade --no-apply-immediately +aws rds modify-db-instance … --apply-immediately +``` + +#### Upgrade to a new minor version + +Either: + +- Manually modify a DB engine version through the Console, CLI, or RDS API: + + ```sh + # Show available automatic minor upgrade target versions for a given DB engine version. + aws rds describe-db-engine-versions \ + --engine 'postgres' --engine-version '13' \ + --query 'DBEngineVersions[*].ValidUpgradeTarget[*].{AutoUpgrade:AutoUpgrade,EngineVersion:EngineVersion}[?AutoUpgrade==`true`][]' + + # Start upgrading. + aws rds modify-db-instance --db-instance-identifier 'my-db-instance' --engine-version '14.20' --no-apply-immediately + aws rds modify-db-instance … --apply-immediately + ``` + +- Enable automatic updates for the instance. + +Unless changes are applied immediately, RDS schedules the upgrade to run automatically in the preferred maintenance +window. + +Automatic upgrades incur downtime too.
+The length of the downtime depends on various factors, including the DB engine type and the size of the database. + +During the upgrade, RDS: + +1. Runs a system pre-check to make sure the database can be upgraded. +1. Upgrades the DB engine to the target minor engine version. +1. Runs post-upgrade checks. +1. Marks the database upgrade as complete. + ### PostgreSQL: reduce allocated storage by migrating using transportable databases Refer [Migrating databases using RDS PostgreSQL Transportable Databases], diff --git a/snippets/aws/other commands.fish b/snippets/aws/other commands.fish index 2a6f65c..80229c8 100644 --- a/snippets/aws/other commands.fish +++ b/snippets/aws/other commands.fish @@ -378,6 +378,18 @@ aws rds start-export-task \ # Change the storage type aws rds modify-db-instance --db-instance-identifier 'instance-name' --storage-type 'gp3' --apply-immediately +# Show available upgrade target versions for a given DB engine version. +aws rds describe-db-engine-versions --engine 'postgres' --engine-version '13' \ + --query 'DBEngineVersions[*].ValidUpgradeTarget[*]' +aws rds describe-db-engine-versions --engine 'postgres' --engine-version '13.12' \ + --query 'DBEngineVersions[*].ValidUpgradeTarget[*].{AutoUpgrade:AutoUpgrade,EngineVersion:EngineVersion}[?AutoUpgrade==`true`][]' + +# Start upgrading. +# Requires downtime. +aws rds modify-db-instance --db-instance-identifier 'my-db-instance' --engine-version '14.20' --apply-immediately +aws rds modify-db-instance --db-instance-identifier 'my-db-instance' \ + --engine-version '14.15' --allow-major-version-upgrade --no-apply-immediately + # Max 5 running at any given time, RDS cannot queue echo {1..5} | xargs -p -n '1' -I '{}' aws rds start-export-task …