forked from terraform-community-modules/tf_aws_rds
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.tf
40 lines (36 loc) · 1.42 KB
/
main.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
//
// Module: tf_aws_rds
//
// This template creates the following resources
// - An RDS instance
// - A database subnet group
// - You should want your RDS instance in a VPC
// Provider specific configs
provider "aws" {
access_key = "${var.aws_access_key}"
secret_key = "${var.aws_secret_key}"
region = "${var.aws_region}"
}
resource "aws_db_instance" "main_rds_instance" {
identifier = "${var.rds_instance_name}"
allocated_storage = "${var.rds_allocated_storage}"
engine = "${var.rds_engine_type}"
engine_version = "${var.rds_engine_version}"
instance_class = "${var.rds_instance_class}"
name = "${var.database_name}"
username = "${var.database_user}"
password = "${var.database_password}"
// Because we're assuming a VPC, we use this option, but only one SG id
vpc_security_group_ids = ["${var.rds_security_group_id}"]
// We're creating a subnet group in the module and passing in the name
db_subnet_group_name = "${aws_db_subnet_group.main_db_subnet_group.name}"
parameter_group_name = "${var.db_parameter_group}"
// We want the multi-az setting to be toggleable, but off by default
multi_az = "${var.rds_is_multi_az}"
storage_type = "${var.rds_storage_type}"
}
resource "aws_db_subnet_group" "main_db_subnet_group" {
name = "${var.rds_instance_name}-subnetgrp"
description = "RDS subnet group"
subnet_ids = ["${var.subnet_az1}", "${var.subnet_az2}"]
}