Skip to content

Commit

Permalink
MM-62533: Improvements for ExternalDBSettings (#880)
Browse files Browse the repository at this point in the history
- We bump the postgres version to 14.9 as that is the version
after which "write forwarding" is available on a Global Aurora
Cluster.
- We also add the ClusterIdentifier for ExternalDBSettings
because we need to attach the DB security group to the DB cluster
like we do for a restored DB backup.

https://mattermost.atlassian.net/browse/MM-62533
  • Loading branch information
agnivade authored Jan 14, 2025
1 parent d28ef1e commit 9314e35
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 7 deletions.
3 changes: 2 additions & 1 deletion config/deployer.sample.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@
"DriverName": "cockroach",
"DataSource": "",
"DataSourceReplicas": [],
"DataSourceSearchReplicas": []
"DataSourceSearchReplicas": [],
"ClusterIdentifier": "",
},
"ExternalBucketSettings": {
"AmazonS3AccessKeyId": "",
Expand Down
1 change: 1 addition & 0 deletions config/deployer.sample.toml
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ DataSource = ''
DataSourceReplicas = []
DataSourceSearchReplicas = []
DriverName = 'cockroach'
ClusterIdentifier = ''

[JobServerSettings]
InstanceCount = 0
Expand Down
2 changes: 2 additions & 0 deletions deployment/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,8 @@ type ExternalDBSettings struct {
DataSourceReplicas []string `default:""`
// DSN to connect to the database search replicas
DataSourceSearchReplicas []string `default:""`
// ClusterIdentifier of the existing DB cluster.
ClusterIdentifier string `default:""`
}

// ExternalBucketSettings contains the necessary data
Expand Down
4 changes: 2 additions & 2 deletions deployment/terraform/assets/bindata.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion deployment/terraform/assets/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ variable "db_engine_version" {
type = map(any)
default = {
"aurora-mysql" = "8.0.mysql_aurora.3.05.2"
"aurora-postgresql" = "14.7"
"aurora-postgresql" = "14.9"
}
}

Expand Down
12 changes: 9 additions & 3 deletions deployment/terraform/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,18 +153,24 @@ func (t *Terraform) Create(extAgent *ssh.ExtAgent, initData bool) error {
return err
}

// If we are restoring from a DB backup, then we need to hook up
// If we are restoring from a DB backup, or using an external database, then we need to hook up
// the security group to it.
if t.config.TerraformDBSettings.ClusterIdentifier != "" {
if t.config.TerraformDBSettings.ClusterIdentifier != "" || t.config.ExternalDBSettings.ClusterIdentifier != "" {
if len(t.output.DBSecurityGroup) == 0 {
return errors.New("No DB security group created")
}
var identifier string
if t.config.TerraformDBSettings.ClusterIdentifier != "" {
identifier = t.config.TerraformDBSettings.ClusterIdentifier
} else {
identifier = t.config.ExternalDBSettings.ClusterIdentifier
}

sgID := t.output.DBSecurityGroup[0].Id
args := []string{
"rds",
"modify-db-cluster",
"--db-cluster-identifier=" + t.config.TerraformDBSettings.ClusterIdentifier,
"--db-cluster-identifier=" + identifier,
"--vpc-security-group-ids=" + sgID,
"--region=" + t.config.AWSRegion,
}
Expand Down
6 changes: 6 additions & 0 deletions docs/config/deployer.md
Original file line number Diff line number Diff line change
Expand Up @@ -366,6 +366,12 @@ The list of dsn for external database read replicas

The list of dsn for external database search replicas

### ClusterIdentifier

*string*

ClusterIdentifier of the existing DB cluster.

## ExternalBucketSettings

### AmazonS3AccessKeyId
Expand Down

0 comments on commit 9314e35

Please sign in to comment.