Search code examples
amazon-web-servicesterraformamazon-rdsterraform-provider-aws

How to create & bind "database mail xps" parameter group with AWS RDS through terraform?


I'm trying to create AWS RDS (Microsoft SQL Server) through terraform. And I want to enable database mail xps. But I'm not sure what to give in parameter name. Please refer below snippet. It is giving an error that: only lowercase alphanumeric characters and hyphens allowed in parameter group "name_prefix".

resource "aws_db_parameter_group" "para" {
  name   = "awsprodreporttool"
  family = "sqlserver-ex-15.0"

  parameter {
    name  = "database-mail-xps"
    value = "1"
  }
}

Solution

  • The correct parameter name is database mail xps:

    resource "aws_db_parameter_group" "para" {
      name   = "awsprodreporttool"
      family = ...
    
      parameter {
        name  = "database mail xps"
        value = "1"
      }
    } 
    

    Please note, Database Mail is not supported for SQL Server Express Edition! Source: aws docs

    In fact, if try to create a parameter group with database mail xps for sqlserver-ex-15.0 using Terraform, you will get the following error:

    ╷
    │ Error: Error modifying DB Parameter Group: InvalidParameterValue: The parameter database mail xps cannot be modified.
    │       status code: 400, request id: a8eebf92-5703-4af2-81bb-3dfb0225874b
    │
    │   with aws_db_parameter_group.para,
    │   on main.tf line 114, in resource "aws_db_parameter_group" "para":
    │  114: resource "aws_db_parameter_group" "para" {
    │
    ╵
    

    Altough, database mail xps appears in the parameter group if one from AWS console, it wont be allowed to be modified for this engine type.

    If you want to see all the parameters and their names, you can create a default parameter group from the AWS console, and run the following command from the CLI:

    aws rds describe-db-parameters --db-parameter-group-name My_PARAMETER_GROUP_NAME --query 'Parameters[*].ParameterName'