generated from TBD54566975/tbd-project-template
-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Previously, we were `CREATE DATABASE ... ` as a response to a successful status check. Now, we spawn a background goroutine to wait for the stack to become ready and run any DDL commands before reporting the task as a success. Closes #3333 --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
- Loading branch information
1 parent
3431255
commit 6b8f7f1
Showing
4 changed files
with
275 additions
and
161 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
package main | ||
|
||
import ( | ||
goformation "github.com/awslabs/goformation/v7/cloudformation" | ||
"github.com/awslabs/goformation/v7/cloudformation/rds" | ||
) | ||
|
||
type PostgresTemplater struct { | ||
resourceID string | ||
cluster string | ||
module string | ||
config *Config | ||
} | ||
|
||
var _ ResourceTemplater = (*PostgresTemplater)(nil) | ||
|
||
func (p *PostgresTemplater) AddToTemplate(template *goformation.Template) error { | ||
clusterID := cloudformationResourceID(p.resourceID, "cluster") | ||
instanceID := cloudformationResourceID(p.resourceID, "instance") | ||
template.Resources[clusterID] = &rds.DBCluster{ | ||
Engine: ptr("aurora-postgresql"), | ||
MasterUsername: ptr("root"), | ||
ManageMasterUserPassword: ptr(true), | ||
DBSubnetGroupName: ptr(p.config.DatabaseSubnetGroupARN), | ||
VpcSecurityGroupIds: []string{p.config.DatabaseSecurityGroup}, | ||
EngineMode: ptr("provisioned"), | ||
Port: ptr(5432), | ||
ServerlessV2ScalingConfiguration: &rds.DBCluster_ServerlessV2ScalingConfiguration{ | ||
MinCapacity: ptr(0.5), | ||
MaxCapacity: ptr(10.0), | ||
}, | ||
Tags: ftlTags(p.cluster, p.module), | ||
} | ||
template.Resources[instanceID] = &rds.DBInstance{ | ||
Engine: ptr("aurora-postgresql"), | ||
DBInstanceClass: ptr("db.serverless"), | ||
DBClusterIdentifier: ptr(goformation.Ref(clusterID)), | ||
Tags: ftlTags(p.cluster, p.module), | ||
} | ||
addOutput(template.Outputs, goformation.GetAtt(clusterID, "Endpoint.Address"), &CloudformationOutputKey{ | ||
ResourceID: p.resourceID, | ||
PropertyName: PropertyPsqlWriteEndpoint, | ||
}) | ||
addOutput(template.Outputs, goformation.GetAtt(clusterID, "ReadEndpoint.Address"), &CloudformationOutputKey{ | ||
ResourceID: p.resourceID, | ||
PropertyName: PropertyPsqlReadEndpoint, | ||
}) | ||
addOutput(template.Outputs, goformation.GetAtt(clusterID, "MasterUserSecret.SecretArn"), &CloudformationOutputKey{ | ||
ResourceID: p.resourceID, | ||
PropertyName: PropertyPsqlMasterUserARN, | ||
}) | ||
return nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.