Skip to content
This repository has been archived by the owner on Feb 19, 2024. It is now read-only.

Commit

Permalink
[gcp/mysql]Add dns for mysql instances
Browse files Browse the repository at this point in the history
  • Loading branch information
diraol committed Feb 17, 2020
1 parent c738ba6 commit 4cde372
Showing 1 changed file with 62 additions and 2 deletions.
64 changes: 62 additions & 2 deletions google-cloud/gcp/mysql/main.tf
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# Firewall rules
resource "google_compute_firwall" "mysql_cluster_replication" {
resource "google_compute_firewall" "mysql_cluster_replication" {
name = "mysql-cluster-${var.service_name}"
network = "${var.network}"

Expand All @@ -16,7 +16,7 @@ resource "google_compute_firwall" "mysql_cluster_replication" {
]
}

resource "google_compute_firwall" "mysql_cluster" {
resource "google_compute_firewall" "mysql_cluster" {
name = "mysql-cluster-replication-${var.service_name}"
network = "${var.network}"

Expand Down Expand Up @@ -100,6 +100,26 @@ resource "google_compute_instance" "mysqlcluster_module_first" {
}
}

resource "google_dns_record_set" "mysql_first" {
name = "mysqlcluster-${var.service_name}-first.chaos-refugees.minks.xyz"
type = "A"
ttl = 5
project = "cabify-mr-meeseeks-box"
managed_zone = "minks-xyz"
rrdatas = ["${google_compute_instance.mysqlcluster_module_first.network_interface.0.access_config.0.nat_ip}"]
depends_on = ["google_compute_instance.mysqlcluster_module_first"]
}

resource "google_dns_record_set" "mysql_first_internal" {
name = "mysqlcluster-${var.service_name}-first.chaos-blah.minks.xyz"
type = "A"
ttl = 5
project = "cabify-mr-meeseeks-box"
managed_zone = "minks-xyz"
rrdatas = ["${google_compute_instance.mysqlcluster_module_first.network_interface.0.network_ip}"]
depends_on = ["google_compute_instance.mysqlcluster_module_first"]
}

# REPLICAS (instances number 2 and 3)
# Replica A
resource "google_compute_address" "mysqlcluster_module_second" {
Expand Down Expand Up @@ -172,6 +192,26 @@ resource "google_compute_instance" "mysqlcluster_module_second" {
depends_on = ["google_compute_instance.mysqlcluster_module_first"]
}

resource "google_dns_record_set" "mysql_second" {
name = "mysqlcluster-${var.service_name}-second.chaos-refugees.minks.xyz"
type = "A"
ttl = 5
project = "cabify-mr-meeseeks-box"
managed_zone = "minks-xyz"
rrdatas = ["${google_compute_instance.mysqlcluster_module_second.network_interface.0.access_config.0.nat_ip}"]
depends_on = ["google_compute_instance.mysqlcluster_module_second"]
}

resource "google_dns_record_set" "mysql_second_internal" {
name = "mysqlcluster-${var.service_name}-second.chaos-blah.minks.xyz"
type = "A"
ttl = 5
project = "cabify-mr-meeseeks-box"
managed_zone = "minks-xyz"
rrdatas = ["${google_compute_instance.mysqlcluster_module_second.network_interface.0.network_ip}"]
depends_on = ["google_compute_instance.mysqlcluster_module_second"]
}

# Replica B
resource "google_compute_address" "mysqlcluster_module_third" {
name = "mysqlcluster-${var.service_name}-third"
Expand Down Expand Up @@ -241,3 +281,23 @@ resource "google_compute_instance" "mysqlcluster_module_third" {
}
depends_on = ["google_compute_instance.mysqlcluster_module_first"]
}

resource "google_dns_record_set" "mysql_third" {
name = "mysqlcluster-${var.service_name}-third.chaos-refugees.minks.xyz"
type = "A"
ttl = 5
project = "cabify-mr-meeseeks-box"
managed_zone = "minks-xyz"
rrdatas = ["${google_compute_instance.mysqlcluster_module_third.network_interface.0.access_config.0.nat_ip}"]
depends_on = ["google_compute_instance.mysqlcluster_module_third"]
}

resource "google_dns_record_set" "mysql_third_internal" {
name = "mysqlcluster-${var.service_name}-third.chaos-blah.minks.xyz"
type = "A"
ttl = 5
project = "cabify-mr-meeseeks-box"
managed_zone = "minks-xyz"
rrdatas = ["${google_compute_instance.mysqlcluster_module_third.network_interface.0.network_ip}"]
depends_on = ["google_compute_instance.mysqlcluster_module_third"]
}

0 comments on commit 4cde372

Please sign in to comment.