Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding mysql to engine_version validation #71

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
Use this URL for the source of the module. See the usage examples below for more details.

```hcl
github.com/pbs/terraform-aws-rds-module?ref=1.0.0
github.com/pbs/terraform-aws-rds-module?ref=x.y.z
```

### Alternative Installation Methods
Expand All @@ -28,7 +28,7 @@ Integrate this module like so:

```hcl
module "rds" {
source = "github.com/pbs/terraform-aws-rds-module?ref=1.0.0"
source = "github.com/pbs/terraform-aws-rds-module?ref=x.y.z"

# Required Parameters
private_hosted_zone = "example.local"
Expand All @@ -47,7 +47,7 @@ module "rds" {

If this repo is added as a subtree, then the version of the module should be close to the version shown here:

`1.0.0`
`x.y.z`

Note, however that subtrees can be altered as desired within repositories.

Expand Down
12 changes: 9 additions & 3 deletions optional.tf
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ variable "engine_mode" {
default = "provisioned"
type = string
validation {
condition = var.engine_mode == "provisioned" || var.engine_mode == "serverless"
condition = (var.engine_mode == "provisioned" || var.engine_mode == "serverless")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

terraform fmt made this update.

error_message = "This module supports only Aurora provisioned or Serverless v2. Please set engine_mode to 'serverless' for Serverless v2 or 'provisioned' for provisioned mode."
}
}
Expand All @@ -62,9 +62,15 @@ variable "engine_version" {
description = "Engine version of the RDS cluster"
default = "14.6" # Use a valid version for Serverless v2
type = string

validation {
condition = (var.engine_version >= "13.7" && var.engine_version <= "13.7") || (var.engine_version >= "14" && var.engine_version <= "15")
error_message = "Ensure the engine version is compatible with Aurora PostgreSQL versions that support Serverless v2 (>= 13.7 or 14.x)."
condition = (
can(regex("^14.*$", var.engine_version)) # PostgreSQL
|| can(regex("^8.*.mysql_aurora.*$", var.engine_version)) # Aurora MySQL
|| can(regex("^8.*$", var.engine_version)) # MySQL 8
|| can(regex("^5.7$", var.engine_version)) # MySQL 5.7
)
error_message = "Ensure the engine version is compatible with the selected engine type. PostgreSQL versions must be >= 13.7 or between 14.x-15.x. For MySQL, please provide a valid engine version."
}
}

Expand Down
Loading