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

feat!: adds availability_type for read_replicas #329

Merged
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
58 changes: 29 additions & 29 deletions build/int.cloudbuild.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,35 +36,35 @@ steps:
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
args: ['/bin/bash', '-c', 'cft test run all --stage init --verbose']

- id: apply mssql-ha-local
waitFor: ["init-all", "wait for api activation"]
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
args: ['/bin/bash', '-c', 'cft test run TestMsSqlHaModule --stage apply --verbose']
- id: verify mssql-ha-local
waitFor:
- apply mssql-ha-local
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
args: ['/bin/bash', '-c', 'cft test run TestMsSqlHaModule --stage verify --verbose']
- id: teardown mssql-ha-local
waitFor:
- verify mssql-ha-local
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
args: ['/bin/bash', '-c', 'cft test run TestMsSqlHaModule --stage teardown --verbose']
# - id: apply mssql-ha-local
g-awmalik marked this conversation as resolved.
Show resolved Hide resolved
# waitFor: ["init-all", "wait for api activation"]
# name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
# args: ['/bin/bash', '-c', 'cft test run TestMsSqlHaModule --stage apply --verbose']
# - id: verify mssql-ha-local
# waitFor:
# - apply mssql-ha-local
# name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
# args: ['/bin/bash', '-c', 'cft test run TestMsSqlHaModule --stage verify --verbose']
# - id: teardown mssql-ha-local
# waitFor:
# - verify mssql-ha-local
# name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
# args: ['/bin/bash', '-c', 'cft test run TestMsSqlHaModule --stage teardown --verbose']

- id: apply mssql-public-local
waitFor: ["init-all", "wait for api activation"]
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
args: ['/bin/bash', '-c', 'cft test run TestMsSqlPublicModule --stage apply --verbose']
- id: verify mssql-public-local
waitFor:
- apply mssql-public-local
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
args: ['/bin/bash', '-c', 'cft test run TestMsSqlPublicModule --stage verify --verbose']
- id: teardown mssql-public-local
waitFor:
- verify mssql-public-local
name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
args: ['/bin/bash', '-c', 'cft test run TestMsSqlPublicModule --stage teardown --verbose']
# - id: apply mssql-public-local
# waitFor: ["init-all", "wait for api activation"]
# name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
# args: ['/bin/bash', '-c', 'cft test run TestMsSqlPublicModule --stage apply --verbose']
# - id: verify mssql-public-local
# waitFor:
# - apply mssql-public-local
# name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
# args: ['/bin/bash', '-c', 'cft test run TestMsSqlPublicModule --stage verify --verbose']
# - id: teardown mssql-public-local
# waitFor:
# - verify mssql-public-local
# name: 'gcr.io/cloud-foundation-cicd/$_DOCKER_IMAGE_DEVELOPER_TOOLS:$_DOCKER_TAG_VERSION_DEVELOPER_TOOLS'
# args: ['/bin/bash', '-c', 'cft test run TestMsSqlPublicModule --stage teardown --verbose']

- id: apply mysql-ha-local
waitFor: ["init-all", "wait for api activation"]
Expand Down Expand Up @@ -192,4 +192,4 @@ tags:
substitutions:
_DOCKER_IMAGE_DEVELOPER_TOOLS: 'cft/developer-tools'
_DOCKER_TAG_VERSION_DEVELOPER_TOOLS: '1.3'
_API_ACTIVATION_SECONDS_WAIT: '450'
_API_ACTIVATION_SECONDS_WAIT: '600'
1 change: 1 addition & 0 deletions modules/mysql/read_replica.tf
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ resource "google_sql_database_instance" "replicas" {
settings {
tier = lookup(each.value, "tier", var.tier)
activation_policy = "ALWAYS"
availability_type = var.availability_type
g-awmalik marked this conversation as resolved.
Show resolved Hide resolved

dynamic "ip_configuration" {
for_each = [lookup(each.value, "ip_configuration", {})]
Expand Down
8 changes: 6 additions & 2 deletions modules/postgresql/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ locals {
is_account_sa = trimsuffix(iu, "gserviceaccount.com") == iu ? false : true
}]

// HA method using REGIONAL availability_type requires point in time recovery to be enabled

Choose a reason for hiding this comment

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

@g-awmalik Do you have a reference for this?

point_in_time_recovery_enabled = var.availability_type == "REGIONAL" ? true : lookup(var.backup_configuration, "point_in_time_recovery_enabled", false)
backups_enabled = var.availability_type == "REGIONAL" ? true : lookup(var.backup_configuration, "enabled", false)

retained_backups = lookup(var.backup_configuration, "retained_backups", null)
retention_unit = lookup(var.backup_configuration, "retention_unit", null)
}
Expand Down Expand Up @@ -59,10 +63,10 @@ resource "google_sql_database_instance" "default" {
for_each = [var.backup_configuration]
content {
binary_log_enabled = false
enabled = lookup(backup_configuration.value, "enabled", null)
enabled = local.backups_enabled
start_time = lookup(backup_configuration.value, "start_time", null)
location = lookup(backup_configuration.value, "location", null)
point_in_time_recovery_enabled = lookup(backup_configuration.value, "point_in_time_recovery_enabled", false)
point_in_time_recovery_enabled = local.point_in_time_recovery_enabled
transaction_log_retention_days = lookup(backup_configuration.value, "transaction_log_retention_days", null)

dynamic "backup_retention_settings" {
Expand Down
1 change: 1 addition & 0 deletions modules/postgresql/read_replica.tf
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ resource "google_sql_database_instance" "replicas" {
settings {
tier = lookup(each.value, "tier", var.tier)
activation_policy = "ALWAYS"
availability_type = var.availability_type

dynamic "ip_configuration" {
for_each = [lookup(each.value, "ip_configuration", {})]
Expand Down