in shardingsphere-operator/pkg/reconcile/storagenode/aws/rdscluster.go [100:150]
func (c *RdsClient) CreateRDSCluster(ctx context.Context, node *v1alpha1.StorageNode, params map[string]string) error {
if err := validateCreateRDSClusterParams(node, ¶ms); err != nil {
return err
}
cc := c.Cluster()
allocatedStorage, err := getAllocatedStorage(params["allocatedStorage"])
if err != nil {
return err
}
iops, err := getIOPS(params["iops"])
if err != nil {
return err
}
if iops > allocatedStorage*50 || iops*2 < allocatedStorage {
return fmt.Errorf("the IOPS to GiB ratio must be between 0.5 and 50, current iops is %d, allocated storage is %d", iops, allocatedStorage)
}
cc.SetEngine(params["engine"]).
SetEngineVersion(params["engineVersion"]).
SetDBClusterIdentifier(params["clusterIdentifier"]).
SetMasterUsername(params["masterUsername"]).
SetMasterUserPassword(params["masterUserPassword"]).
SetAllocatedStorage(int32(allocatedStorage)).
SetDBClusterInstanceClass(params["instanceClass"]).
SetIOPS(int32(iops)).
SetStorageType(params["storageType"])
if v, ok := node.Annotations[v1alpha1.AnnotationsInstanceDBName]; ok && v != "" {
cc.SetDatabaseName(v)
}
if v, ok := params["publicAccessible"]; ok && v == "false" {
cc.SetPublicAccessible(false)
} else {
cc.SetPublicAccessible(true)
}
if params["vpcSecurityGroupIds"] != "" {
cc.SetVpcSecurityGroupIds(strings.Split(params["vpcSecurityGroupIds"], ","))
}
if err := cc.Create(ctx); err != nil {
return fmt.Errorf("create rds cluster failed, %v", err)
}
return nil
}