github.com/adrian-bl/terraform@v0.7.0-rc2.0.20160705220747-de0a34fc3517/website/source/docs/providers/aws/r/db_instance.html.markdown (about) 1 --- 2 layout: "aws" 3 page_title: "AWS: aws_db_instance" 4 sidebar_current: "docs-aws-resource-db-instance" 5 description: |- 6 Provides an RDS instance resource. 7 --- 8 9 # aws\_db\_instance 10 11 Provides an RDS instance resource. A DB instance is an isolated database 12 environment in the cloud. A DB instance can contain multiple user-created 13 databases. 14 15 Changes to a DB instance can occur when you manually change a 16 parameter, such as `allocated_storage`, and are reflected in the next maintenance 17 window. Because of this, Terraform may report a difference in it's planning 18 phase because a modification has not yet taken place. You can use the 19 `apply_immediately` flag to instruct the service to apply the change immediately 20 (see documentation below). 21 22 ~> **Note:** using `apply_immediately` can result in a 23 brief downtime as the server reboots. See the AWS Docs on [RDS Maintenance][2] 24 for more information. 25 26 27 ## Example Usage 28 29 ``` 30 resource "aws_db_instance" "default" { 31 allocated_storage = 10 32 engine = "mysql" 33 engine_version = "5.6.17" 34 instance_class = "db.t1.micro" 35 name = "mydb" 36 username = "foo" 37 password = "bar" 38 db_subnet_group_name = "my_database_subnet_group" 39 parameter_group_name = "default.mysql5.6" 40 } 41 ``` 42 43 ## Argument Reference 44 45 For more detailed documentation about each argument, refer to 46 the [AWS official documentation](https://docs.aws.amazon.com/AmazonRDS/latest/CommandLineReference/CLIReference-cmd-ModifyDBInstance.html). 47 48 The following arguments are supported: 49 50 * `allocated_storage` - (Required unless a `snapshot_identifier` or `replicate_source_db` is provided) The allocated storage in gigabytes. 51 * `engine` - (Required unless a `snapshot_identifier` or `replicate_source_db` is provided) The database engine to use. 52 * `engine_version` - (Optional) The engine version to use. 53 * `identifier` - (Optional) The name of the RDS instance, if omitted, Terraform will assign a random, unique name 54 * `instance_class` - (Required) The instance type of the RDS instance. 55 * `storage_type` - (Optional) One of "standard" (magnetic), "gp2" (general 56 purpose SSD), or "io1" (provisioned IOPS SSD). The default is "io1" if 57 `iops` is specified, "standard" if not. 58 * `final_snapshot_identifier` - (Optional) The name of your final DB snapshot 59 when this DB instance is deleted. If omitted, no final snapshot will be 60 made. 61 * `skip_final_snapshot` - (Optional) Determines whether a final DB snapshot is created before the DB instance is deleted. If true is specified, no DBSnapshot is created. If false is specified, a DB snapshot is created before the DB instance is deleted, using the value from `final_snapshot_identifier`. Default is true. 62 * `copy_tags_to_snapshot` – (Optional, boolean) On delete, copy all Instance `tags` to 63 the final snapshot (if `final_snapshot_identifier` is specified). Default 64 `false` 65 * `name` - (Optional) The DB name to create. If omitted, no database is created 66 initially. 67 * `password` - (Required unless a `snapshot_identifier` or `replicate_source_db` is provided) Password for the master DB user. Note that this may 68 show up in logs, and it will be stored in the state file. 69 * `username` - (Required unless a `snapshot_identifier` or `replicate_source_db` is provided) Username for the master DB user. 70 * `availability_zone` - (Optional) The AZ for the RDS instance. 71 * `backup_retention_period` - (Optional) The days to retain backups for. Must be 72 `1` or greater to be a source for a [Read Replica][1]. 73 * `backup_window` - (Optional) The backup window. 74 * `iops` - (Optional) The amount of provisioned IOPS. Setting this implies a 75 storage_type of "io1". 76 * `maintenance_window` - (Optional) The window to perform maintenance in. 77 Syntax: "ddd:hh24:mi-ddd:hh24:mi". Eg: "Mon:00:00-Mon:03:00". 78 See [RDS Maintenance Window docs](https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/AdjustingTheMaintenanceWindow.html) for more. 79 * `multi_az` - (Optional) Specifies if the RDS instance is multi-AZ 80 * `port` - (Optional) The port on which the DB accepts connections. 81 * `publicly_accessible` - (Optional) Bool to control if instance is publicly accessible. Defaults to `false`. 82 * `vpc_security_group_ids` - (Optional) List of VPC security groups to associate. 83 * `security_group_names` - (Optional/Deprecated) List of DB Security Groups to associate. 84 Only used for [DB Instances on the _EC2-Classic_ Platform](https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/USER_VPC.html#USER_VPC.FindDefaultVPC). 85 * `db_subnet_group_name` - (Optional) Name of DB subnet group. DB instance will be created in the VPC associated with the DB subnet group. If unspecified, will be created in the `default` VPC, or in EC2 Classic, if available. 86 * `parameter_group_name` - (Optional) Name of the DB parameter group to associate. 87 * `option_group_name` - (Optional) Name of the DB option group to associate. 88 * `storage_encrypted` - (Optional) Specifies whether the DB instance is encrypted. The default is `false` if not specified. 89 * `apply_immediately` - (Optional) Specifies whether any database modifications 90 are applied immediately, or during the next maintenance window. Default is 91 `false`. See [Amazon RDS Documentation for more information.](https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/Overview.DBInstance.Modifying.html) 92 * `replicate_source_db` - (Optional) Specifies that this resource is a Replicate 93 database, and to use this value as the source database. This correlates to the 94 `identifier` of another Amazon RDS Database to replicate. See 95 [DB Instance Replication][1] and 96 [Working with PostgreSQL and MySQL Read Replicas](https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/USER_ReadRepl.html) for 97 more information on using Replication. 98 * `snapshot_identifier` - (Optional) Specifies whether or not to create this database from a snapshot. This correlates to the snapshot ID you'd find in the RDS console, e.g: rds:production-2015-06-26-06-05. 99 * `license_model` - (Optional, but required for some DB engines, i.e. Oracle SE1) License model information for this DB instance. 100 * `auto_minor_version_upgrade` - (Optional) Indicates that minor engine upgrades will be applied automatically to the DB instance during the maintenance window. Defaults to true. 101 * `allow_major_version_upgrade` - (Optional) Indicates that major version upgrades are allowed. Changing this parameter does not result in an outage and the change is asynchronously applied as soon as possible. 102 * `monitoring_role_arn` - (Optional) The ARN for the IAM role that permits RDS to send 103 enhanced monitoring metrics to CloudWatch Logs. You can find more information on the [AWS Documentation](http://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/USER_Monitoring.html) 104 what IAM permissions are needed to allow Enhanced Monitoring for RDS Instances. 105 * `monitoring_interval` - (Optional) The interval, in seconds, between points when Enhanced Monitoring metrics are collected for the DB instance. To disable collecting Enhanced Monitoring metrics, specify 0. The default is 0. Valid Values: 0, 1, 5, 10, 15, 30, 60. 106 * `kms_key_id` - (Optional) The ARN for the KMS encryption key. 107 * `character_set_name` - (Optional) The character set name to use for DB encoding in Oracle instances. This can't be changed. 108 [Oracle Character Sets Supported in Amazon RDS](http://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/Appendix.OracleCharacterSets.html) 109 * `tags` - (Optional) A mapping of tags to assign to the resource. 110 111 ~> **NOTE:** Removing the `replicate_source_db` attribute from an existing RDS 112 Replicate database managed by Terraform will promote the database to a fully 113 standalone database. 114 115 ## Attributes Reference 116 117 The following attributes are exported: 118 119 * `id` - The RDS instance ID. 120 * `address` - The address of the RDS instance. 121 * `arn` - The ARN of the RDS instance. 122 * `allocated_storage` - The amount of allocated storage 123 * `availability_zone` - The availability zone of the instance 124 * `backup_retention_period` - The backup retention period 125 * `backup_window` - The backup window 126 * `endpoint` - The connection endpoint 127 * `engine` - The database engine 128 * `engine_version` - The database engine version 129 * `instance_class`- The RDS instance class 130 * `maintenance_window` - The instance maintenance window 131 * `multi_az` - If the RDS instance is multi AZ enabled 132 * `name` - The database name 133 * `port` - The database port 134 * `status` - The RDS instance status 135 * `username` - The master username for the database 136 * `storage_encrypted` - Specifies whether the DB instance is encrypted 137 138 On Oracle instances the following is exported additionally: 139 140 * `character_set_name` - The character set used on Oracle instances. 141 142 [1]: https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/Overview.Replication.html 143 [2]: https://docs.aws.amazon.com/fr_fr/AmazonRDS/latest/UserGuide/USER_UpgradeDBInstance.Maintenance.html