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

MM-62533: Improvements for ExternalDBSettings #880

Merged
merged 1 commit into from
Jan 14, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
}
Comment on lines +162 to +167
Copy link
Contributor

Choose a reason for hiding this comment

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

This is where I'd love it if Golang could implement some syntactic sugar.


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
Loading