Last active
April 10, 2022 04:19
-
-
Save softarts/da7865977bd88d36b13543dfc6006ffa to your computer and use it in GitHub Desktop.
terraform-rds
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
terraform { | |
required_version = ">= 1.0.0, < 2.0.0" | |
required_providers { | |
aws = { | |
source = "hashicorp/aws" | |
version = "~> 4.0" | |
} | |
} | |
} | |
provider "aws" { | |
region = "ap-southeast-1" | |
} | |
resource "aws_db_instance" "example" { | |
identifier_prefix = "terraform-example" | |
engine = "mysql" | |
allocated_storage = 5 | |
instance_class = "db.t2.micro" | |
skip_final_snapshot = true | |
publicly_accessible = true | |
db_name = var.db_name | |
username = var.db_username | |
password = var.db_password | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
output "address" { | |
value = aws_db_instance.example.address | |
description = "Connect to the database at this endpoint" | |
} | |
output "port" { | |
value = aws_db_instance.example.port | |
description = "The port the database is listening on" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
variable "db_username" { | |
description = "The username for the database" | |
type = string | |
sensitive = true | |
} | |
variable "db_password" { | |
description = "The password for the database" | |
type = string | |
sensitive = true | |
} | |
variable "db_name" { | |
description = "The name to use for the database" | |
type = string | |
default = "terraform_example_database" | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment