使用Terraform创建SQL Server RDS实例

时间:2016-10-06 07:39:18

标签: sql-server amazon-web-services amazon-rds terraform

我将使用Terraform在RDS中创建SQL Server数据库。我的Terraform文件如下所示:

### RDS ###

# Subnet Group
resource "aws_db_subnet_group" "private" {
   name = "db_arcgis-${var.env_name}-dbsubnet"
   description = "Subnet Group for Arcgis ${var.env_tag}} DB"
   subnet_ids = ["${aws_subnet.public1.id}", "${aws_subnet.public2.id}"]

tags {
    Env = "${var.env_tag}"
 }
}

# RDS DB parameter group
# Must enabled triggers to allow Multi-AZ
resource "aws_db_parameter_group" "allow_triggers" {
   name = "arcgis-${var.env_name}-allow-triggers"
   family = "sqlserver-se-12.0"
   description = "Parameter Group for Arcgis ${var.env_tag} to allow triggers"

   parameter {
     name = "log_bin_trust_function_creators"
     value = "1"
   }

   tags {
    Env = "${var.env_tag}"
   }
}

# RDS
resource "aws_db_instance" "main" {
  allocated_storage    = "${var.db_size}"
  engine               = "${var.db_engine}"
  engine_version       = "${var.db_version}"
  instance_class       = "${var.db_instance}"
  identifier             = "arcgis-${var.env_name}-db"
  name                 = "${var.db_name}"
  username             = "${var.db_username}"
  password             = "${var.db_password}"
  db_subnet_group_name = "${aws_db_subnet_group.private.id}"
  parameter_group_name = "${aws_db_parameter_group.allow_triggers.id}"
  multi_az           = "${var.db_multiaz}"
  vpc_security_group_ids = ["${aws_security_group.private_rds.id}"]
  #availability_zone     = "${var.vpc_az1}"
  publicly_accessible    = "true"
  backup_retention_period = "2"

  apply_immediately = "true"

  tags {
    Env = "${var.env_tag}"
  }
}

我通过应用Terraform文件得到了这个错误:

Error applying plan:

1 error(s) occurred:

* aws_db_parameter_group.allow_triggers: Error modifying DB Parameter Group:    InvalidParameterValue: Could not find parameter with name: log_bin_trust_function_creators
    status code: 400, request id: d298ab14-8b94-11e6-a088-31e21873c378  

1 个答案:

答案 0 :(得分:1)

这里显而易见的问题是log_bin_trust_function_creators不是sqlserver-se-12.0参数组系列的可用参数,正如您在此处根据{{列出参数组中的所有参数时所见1}}:

sqlserver-se-12.0

相反,该参数仅在MySQL风格中可用:

$ aws rds describe-db-parameters --db-parameter-group-name test-sqlserver-se-12-0 --query 'Parameters[*].ParameterName'
[
    "1204",
    "1211",
    "1222",
    "1224",
    "2528",
    "3205",
    "3226",
    "3625",
    "4199",
    "4616",
    "6527",
    "7806",
    "access check cache bucket count",
    "access check cache quota",
    "ad hoc distributed queries",
    "affinity i/o mask",
    "affinity mask",
    "agent xps",
    "allow updates",
    "backup compression default",
    "blocked process threshold (s)",
    "c2 audit mode",
    "clr enabled",
    "contained database authentication",
    "cost threshold for parallelism",
    "cross db ownership chaining",
    "cursor threshold",
    "database mail xps",
    "default full-text language",
    "default language",
    "default trace enabled",
    "disallow results from triggers",
    "filestream access level",
    "fill factor (%)",
    "ft crawl bandwidth (max)",
    "ft crawl bandwidth (min)",
    "ft notify bandwidth (max)",
    "ft notify bandwidth (min)",
    "in-doubt xact resolution",
    "index create memory (kb)",
    "lightweight pooling",
    "locks",
    "max degree of parallelism",
    "max full-text crawl range",
    "max server memory (mb)",
    "max text repl size (b)",
    "max worker threads",
    "media retention",
    "min memory per query (kb)",
    "min server memory (mb)",
    "nested triggers",
    "network packet size (b)",
    "ole automation procedures",
    "open objects",
    "optimize for ad hoc workloads",
    "ph timeout (s)",
    "priority boost",
    "query governor cost limit",
    "query wait (s)",
    "recovery interval (min)",
    "remote access",
    "remote admin connections",
    "remote login timeout (s)",
    "remote proc trans",
    "remote query timeout (s)",
    "replication xps",
    "scan for startup procs",
    "server trigger recursion",
    "set working set size",
    "show advanced options",
    "smo and dmo xps",
    "transform noise words",
    "two digit year cutoff",
    "user connections",
    "user options",
    "xp_cmdshell"
]