Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

IaC - RDS DB #36

Merged
merged 7 commits into from
Apr 21, 2020
Merged

IaC - RDS DB #36

merged 7 commits into from
Apr 21, 2020

Conversation

starkmatt
Copy link
Contributor

RDS DB Code

Within this code, I've made a few changes when compared to my first revision of the RDS Code.
It contains 3 files.

  • sg.tf
  • rds.tf
  • variables.tf

SG.tf

- Here I have placed the relevant Security groups that will connect the DB to the VPC and to the resources we have created. There will many many additions to this file as the solution evolves.

variables.tf

- Using the existing variables file, I've added a few entries with regards to the DB Cluster Creation.

RDS.tf

- So here, I've added additional resources to help with the DB creation under the guidance of Kiko. What added now are
  • aws_rds_cluster
  • aws_rds_cluster_instance
  • aws_db_subnet_group

It will create in the following AZ's (ap-southeast-2a /b)
Running Serverless engine version 5.7.12

To run this please clone the repo and run

terraform init
terraform plan
terraform apply

Unfortunately there is a bug upon creation.
Terraform advised the following during the apply phase

Error: error creating RDS cluster: InvalidParameterValue: The engine mode serverless you requested is currently unavailable.
status code: 400, request id: 8596d824-df61-4457-9338-33cf4c0752be

hashicorp/terraform-provider-aws#5593
Git Issue #5593 on Terraform repo advises that this issue may be with serverless requiring a specific engine when running.

As per Kiko's instruction located here
#14

Adding
Aurora (MySQL 5.7) 2.07.2
Doesn't seem to work either.

Please let me know your thoughts regarding this Team!

terraform/rds.tf Outdated
availability_zones = ["ap-southeast-2a", "ap-southeast-2b"]
engine = "aurora-mysql"
engine_version = "5.7.12"
engine_mode = "serverless"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can remove this line

Comment on lines 105 to 107
variable "rds_master_password" {
default = "thisisasecurepassword"
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please, dont have your db password in the code... 🗡️

terraform/rds.tf Outdated
database_name = "wpdb"
availability_zones = ["ap-southeast-2a", "ap-southeast-2b"]
engine = "aurora-mysql"
engine_version = "5.7.12"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

use this command to check versions available:
aws rds describe-db-engine-versions --engine aurora-mysql --query "DBEngineVersions[].EngineVersion"

terraform/sg.tf Outdated
Comment on lines 1 to 22
resource "aws_security_group" "wordpress-access" {
name = "wordpress-access"
description = "Allow inbound traffic to Wordpress Instance"
vpc_id = "${aws_vpc.da-wordpress-vpc.id}"

tags = {
Name = "wordpress-access"
}
ingress {
from_port = 443
to_port = 443
protocol = "tcp"
cidr_blocks = ["0.0.0.0/0"]
}
egress {
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = ["0.0.0.0/0"]
}

}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should not be here.. should be part of the LB card

terraform/rds.tf Outdated

cluster_identifier = "wp-db"
database_name = "wpdb"
availability_zones = ["ap-southeast-2a", "ap-southeast-2b"]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be a variable to be used both here and n the VPC

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey Kiko,
I initally wanted to use
data "aws_availability_zones" "iac-azs" { state = "available" }
From the VPC.
But when trying, I recieved an error that the RDS Cluster didn't support ap-southeast-2c
So I manually entered these two.
I can create a list variable with 2a / 2b inside but it won't be the same as the VPC

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

data "aws_availability_zones" "iac-azs" { state = "available" } is not the best way to define where your resources will run, because depending on what you're doing, a resource running on a specific AZ will not be able to be used by another resource running on other AZ and by doing this way, you don;t have control on where things are running.

Ideally you should have a variable(which you already have) that will contain the AZs that you want to deploy your resources. You can have a default value for this variable, so you don't need to add it to every resource you create.

@starkmatt
Copy link
Contributor Author

RDS DB Code v0.3

- Made changes to the RDS File. - Added Output File for Password

Please test and advise

@kikobr82
Copy link
Contributor

few comments not resolved yet. Also, you have a conflict in the variables file that needs to be solved.

Copy link
Contributor

@kikobr82 kikobr82 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@starkmatt starkmatt merged commit 8dc60b3 into master Apr 21, 2020
@kikobr82 kikobr82 deleted the rdsv1 branch April 21, 2020 11:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants