Skip to content

Instantly share code, notes, and snippets.

@marcgascon
Created August 12, 2019 20:44
Show Gist options
  • Save marcgascon/5e5cc60b32e931da5e654c2c3b060ff5 to your computer and use it in GitHub Desktop.
Save marcgascon/5e5cc60b32e931da5e654c2c3b060ff5 to your computer and use it in GitHub Desktop.
Creates an aurora cluster by default. It is retrieving the password from AWS secrets manager, so it assumes that you have one secret called db-passwords created there
terraform {
required_version = ">= 0.12.2"
required_providers {
aws = "~> 2.23"
}
}
provider "aws" {
region = "eu-west-1"
}
data "aws_secretsmanager_secret" "aurora_rds_password_metadata" {
name = "db-passwords"
}
data "aws_secretsmanager_secret_version" "aurora_rds_password" {
secret_id = "${data.aws_secretsmanager_secret.aurora_rds_password_metadata.id}"
}
resource "aws_rds_cluster" "default" {
cluster_identifier = "challenge-marc"
engine = "aurora-mysql"
engine_version = "5.7.mysql_aurora.2.03.2"
availability_zones = ["eu-west-1a", "eu-west-1b", "eu-west-1c"]
database_name = "challenge"
master_username = "adm"
master_password = jsondecode(data.aws_secretsmanager_secret_version.aurora_rds_password.secret_string)["user_adm"]
backup_retention_period = 1
preferred_backup_window = "07:00-09:00"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment