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

[RELEASE] 20240509210837 #3731

Merged
merged 2 commits into from
May 13, 2024
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
2 changes: 1 addition & 1 deletion provider/aws/formation/app.json.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@
"Properties": {
"Handler": "index.handler",
"Role": { "Fn::GetAtt": [ "TimerRole", "Arn" ] },
"Runtime": "nodejs16.x",
"Runtime": "nodejs20.x",
"Timeout": 60,
"Code": {
"ZipFile": { "Fn::Join": [ "\n", [
Expand Down
4 changes: 2 additions & 2 deletions provider/aws/formation/g1/app.json.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@
"Handler": "index.external",
"MemorySize": "128",
"Role": { "Fn::GetAtt": [ "CustomTopicRole", "Arn" ] },
"Runtime": "nodejs16.x",
"Runtime": "nodejs20.x",
"Timeout": "300"
}
},
Expand Down Expand Up @@ -785,7 +785,7 @@
"Properties": {
"Handler": "index.handler",
"Role": { "Fn::GetAtt": [ "CronRole", "Arn" ] },
"Runtime": "nodejs16.x",
"Runtime": "nodejs20.x",
"Timeout": 50,
"Code": {
"ZipFile": { "Fn::Join": ["\n", [
Expand Down
2 changes: 1 addition & 1 deletion provider/aws/formation/rack.json
Original file line number Diff line number Diff line change
Expand Up @@ -1319,7 +1319,7 @@
"Handler": "index.external",
"MemorySize": "128",
"Role": { "Fn::GetAtt": [ "CustomTopicRole", "Arn" ] },
"Runtime": "nodejs16.x",
"Runtime": "nodejs20.x",
"Timeout": "300",
"VpcConfig": { "Fn::If": [ "PrivateAndPlaceLambdaInVpc",
{
Expand Down
21 changes: 14 additions & 7 deletions provider/aws/formation/resource/mariadb.json.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
"BlankEncrypted": { "Fn::Equals": [ { "Ref": "Encrypted" }, "" ] },
"BlankIops": { "Fn::Equals": [ { "Ref": "Iops" }, "0" ] },
"BlankParameterGroupName": { "Fn::Equals": [ { "Ref": "ParameterGroupName" }, "" ] },
"BlankPreferredBackupWindow": { "Fn::Equals": [ { "Ref": "PreferredBackupWindow" }, "" ] }
"BlankPreferredBackupWindow": { "Fn::Equals": [ { "Ref": "PreferredBackupWindow" }, "" ] },
"IsReadReplica": { "Fn::Not": [ { "Fn::Equals": [ { "Ref": "ReadSourceDB" }, "" ] }]},
"BlankPreferredBackupWindowOrReadReplica": { "Fn::Or": [ { "Condition": "BlankPreferredBackupWindow" }, { "Condition": "IsReadReplica" } ] }
},
"Parameters": {
"AutoMinorVersionUpgrade": {
Expand Down Expand Up @@ -56,6 +58,10 @@
"MinLength": "1",
"Type": "String"
},
"ReadSourceDB": {
"Type": "String",
"Default": ""
},
"Storage": {
"Type": "Number",
"Default": "20"
Expand Down Expand Up @@ -101,30 +107,31 @@
"AllocatedStorage": { "Ref": "Storage" },
"AllowMajorVersionUpgrade": "true",
"AutoMinorVersionUpgrade": { "Ref": "AutoMinorVersionUpgrade" },
"BackupRetentionPeriod": { "Ref": "BackupRetentionPeriod" },
"BackupRetentionPeriod": { "Fn::If": [ "IsReadReplica", { "Ref": "AWS::NoValue" }, { "Ref": "BackupRetentionPeriod" } ] },
"DBInstanceClass": { "Ref": "Class" },
"DBInstanceIdentifier": { "Ref": "AWS::StackName" },
"DBName": "app",
"DBName": { "Fn::If": [ "IsReadReplica", { "Ref": "AWS::NoValue" }, "app" ] },
"DBParameterGroupName": { "Fn::If": [ "BlankParameterGroupName", { "Fn::Sub": [ "default.mariadb${Base}", {
"Base": { "Fn::Join": [ ".", [
{ "Fn::Select": [ 0, { "Fn::Split": [ ".", { "Ref": "Version" } ] } ] },
{ "Fn::Select": [ 1, { "Fn::Split": [ ".", { "Ref": "Version" } ] } ] }
] ] }
} ] },
{ "Ref": "ParameterGroupName" } ] },
"DBSubnetGroupName": { "Ref": "SubnetGroup" },
"DBSubnetGroupName": { "Fn::If": [ "IsReadReplica", { "Ref": "AWS::NoValue" }, { "Ref": "SubnetGroup" } ] },
"DeletionProtection": { "Ref": "DeletionProtection" },
"Engine": "mariadb",
"EngineVersion": { "Ref": "Version" },
"Iops": { "Fn::If": [ "BlankIops", { "Ref": "AWS::NoValue" }, { "Ref": "Iops" } ] },
"MasterUsername": "app",
"MasterUserPassword": { "Ref": "Password" },
"MasterUsername": { "Fn::If": [ "IsReadReplica", { "Ref": "AWS::NoValue" }, "app" ] },
"MasterUserPassword": { "Fn::If": [ "IsReadReplica", { "Ref": "AWS::NoValue" }, { "Ref": "Password" } ] },
"MultiAZ": { "Ref": "Durable" },
"Port": "3306",
"PreferredBackupWindow": { "Fn::If": [ "BlankPreferredBackupWindow", { "Ref": "AWS::NoValue" }, { "Ref": "PreferredBackupWindow" } ] },
"PreferredBackupWindow": { "Fn::If": [ "BlankPreferredBackupWindowOrReadReplica", { "Ref": "AWS::NoValue" }, { "Ref": "PreferredBackupWindow" } ] },
"PubliclyAccessible": "false",
"StorageEncrypted": { "Ref": "Encrypted" },
"StorageType": { "Fn::If": [ "BlankIops", "gp2", "io2" ] },
"SourceDBInstanceIdentifier": { "Fn::If": [ "IsReadReplica", { "Ref": "ReadSourceDB" }, { "Ref": "AWS::NoValue" } ] },
"VPCSecurityGroups": [ { "Ref": "SecurityGroup" } ]
}
}
Expand Down
21 changes: 14 additions & 7 deletions provider/aws/formation/resource/mysql.json.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
"BlankEncrypted": { "Fn::Equals": [ { "Ref": "Encrypted" }, "" ] },
"BlankIops": { "Fn::Equals": [ { "Ref": "Iops" }, "0" ] },
"BlankParameterGroupName": { "Fn::Equals": [ { "Ref": "ParameterGroupName" }, "" ] },
"BlankPreferredBackupWindow": { "Fn::Equals": [ { "Ref": "PreferredBackupWindow" }, "" ] }
"BlankPreferredBackupWindow": { "Fn::Equals": [ { "Ref": "PreferredBackupWindow" }, "" ] },
"IsReadReplica": { "Fn::Not": [ { "Fn::Equals": [ { "Ref": "ReadSourceDB" }, "" ] }]},
"BlankPreferredBackupWindowOrReadReplica": { "Fn::Or": [ { "Condition": "BlankPreferredBackupWindow" }, { "Condition": "IsReadReplica" } ] }
},
"Parameters": {
"AutoMinorVersionUpgrade": {
Expand Down Expand Up @@ -56,6 +58,10 @@
"MinLength": "1",
"Type": "String"
},
"ReadSourceDB": {
"Type": "String",
"Default": ""
},
"Storage": {
"Type": "Number",
"Default": "20"
Expand Down Expand Up @@ -101,30 +107,31 @@
"AllocatedStorage": { "Ref": "Storage" },
"AllowMajorVersionUpgrade": "true",
"AutoMinorVersionUpgrade": { "Ref": "AutoMinorVersionUpgrade" },
"BackupRetentionPeriod": { "Ref": "BackupRetentionPeriod" },
"BackupRetentionPeriod": { "Fn::If": [ "IsReadReplica", { "Ref": "AWS::NoValue" }, { "Ref": "BackupRetentionPeriod" } ] },
"DBInstanceClass": { "Ref": "Class" },
"DBInstanceIdentifier": { "Ref": "AWS::StackName" },
"DBName": "app",
"DBName": { "Fn::If": [ "IsReadReplica", { "Ref": "AWS::NoValue" }, "app" ] },
"DBParameterGroupName": { "Fn::If": [ "BlankParameterGroupName", { "Fn::Sub": [ "default.mysql${Base}", {
"Base": { "Fn::Join": [ ".", [
{ "Fn::Select": [ 0, { "Fn::Split": [ ".", { "Ref": "Version" } ] } ] },
{ "Fn::Select": [ 1, { "Fn::Split": [ ".", { "Ref": "Version" } ] } ] }
] ] }
} ] },
{ "Ref": "ParameterGroupName" } ] },
"DBSubnetGroupName": { "Ref": "SubnetGroup" },
"DBSubnetGroupName": { "Fn::If": [ "IsReadReplica", { "Ref": "AWS::NoValue" }, { "Ref": "SubnetGroup" } ] },
"DeletionProtection": { "Ref": "DeletionProtection" },
"Engine": "mysql",
"EngineVersion": { "Ref": "Version" },
"Iops": { "Fn::If": [ "BlankIops", { "Ref": "AWS::NoValue" }, { "Ref": "Iops" } ] },
"MasterUsername": "app",
"MasterUserPassword": { "Ref": "Password" },
"MasterUsername": { "Fn::If": [ "IsReadReplica", { "Ref": "AWS::NoValue" }, "app" ] },
"MasterUserPassword": { "Fn::If": [ "IsReadReplica", { "Ref": "AWS::NoValue" }, { "Ref": "Password" } ] },
"MultiAZ": { "Ref": "Durable" },
"Port": "3306",
"PreferredBackupWindow": { "Fn::If": [ "BlankPreferredBackupWindow", { "Ref": "AWS::NoValue" }, { "Ref": "PreferredBackupWindow" } ] },
"PreferredBackupWindow": { "Fn::If": [ "BlankPreferredBackupWindowOrReadReplica", { "Ref": "AWS::NoValue" }, { "Ref": "PreferredBackupWindow" } ] },
"PubliclyAccessible": "false",
"StorageEncrypted": { "Ref": "Encrypted" },
"StorageType": { "Fn::If": [ "BlankIops", "gp2", "io2" ] },
"SourceDBInstanceIdentifier": { "Fn::If": [ "IsReadReplica", { "Ref": "ReadSourceDB" }, { "Ref": "AWS::NoValue" } ] },
"VPCSecurityGroups": [ { "Ref": "SecurityGroup" } ]
}
}
Expand Down
19 changes: 13 additions & 6 deletions provider/aws/formation/resource/postgres.json.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
"BlankEncrypted": { "Fn::Equals": [ { "Ref": "Encrypted" }, "" ] },
"BlankIops": { "Fn::Equals": [ { "Ref": "Iops" }, "0" ] },
"BlankPreferredBackupWindow": { "Fn::Equals": [ { "Ref": "PreferredBackupWindow" }, "" ] },
"IsReadReplica": { "Fn::Not": [ { "Fn::Equals": [ { "Ref": "ReadSourceDB" }, "" ] }]},
"BlankPreferredBackupWindowOrReadReplica": { "Fn::Or": [ { "Condition": "BlankPreferredBackupWindow" }, { "Condition": "IsReadReplica" } ] },
"BlankParameterGroupName": { "Fn::Equals": [ { "Ref": "ParameterGroupName" }, "" ] },
"Version9": { "Fn::Equals": [ { "Fn::Select": [ 0, { "Fn::Split": [ ".", { "Ref": "Version" } ] } ] }, "9" ] }
},
Expand Down Expand Up @@ -56,6 +58,10 @@
"Rack": {
"MinLength": "1",
"Type": "String"
},
"ReadSourceDB": {
"Type": "String",
"Default": ""
},
"Storage": {
"Type": "Number",
Expand Down Expand Up @@ -102,10 +108,10 @@
"AllocatedStorage": { "Ref": "Storage" },
"AllowMajorVersionUpgrade": "true",
"AutoMinorVersionUpgrade": { "Ref": "AutoMinorVersionUpgrade" },
"BackupRetentionPeriod": { "Ref": "BackupRetentionPeriod" },
"BackupRetentionPeriod": { "Fn::If": [ "IsReadReplica", { "Ref": "AWS::NoValue" }, { "Ref": "BackupRetentionPeriod" } ] },
"DBInstanceClass": { "Ref": "Class" },
"DBInstanceIdentifier": { "Ref": "AWS::StackName" },
"DBName": "app",
"DBName": { "Fn::If": [ "IsReadReplica", { "Ref": "AWS::NoValue" }, "app" ] },
"DBParameterGroupName": { "Fn::If": [ "BlankParameterGroupName",
{ "Fn::Sub": [ "default.postgres${Base}", {
"Base": { "Fn::If": [ "Version9",
Expand All @@ -118,19 +124,20 @@
} ] }
,
{ "Ref": "ParameterGroupName" } ] },
"DBSubnetGroupName": { "Ref": "SubnetGroup" },
"DBSubnetGroupName": { "Fn::If": [ "IsReadReplica", { "Ref": "AWS::NoValue" }, { "Ref": "SubnetGroup" } ] },
"DeletionProtection": { "Ref": "DeletionProtection" },
"Engine": "postgres",
"EngineVersion": { "Ref": "Version" },
"Iops": { "Fn::If": [ "BlankIops", { "Ref": "AWS::NoValue" }, { "Ref": "Iops" } ] },
"MasterUsername": "app",
"MasterUserPassword": { "Ref": "Password" },
"MasterUsername": { "Fn::If": [ "IsReadReplica", { "Ref": "AWS::NoValue" }, "app" ] },
"MasterUserPassword": { "Fn::If": [ "IsReadReplica", { "Ref": "AWS::NoValue" }, { "Ref": "Password" } ] },
"MultiAZ": { "Ref": "Durable" },
"Port": "5432",
"PreferredBackupWindow": { "Fn::If": [ "BlankPreferredBackupWindow", { "Ref": "AWS::NoValue" }, { "Ref": "PreferredBackupWindow" } ] },
"PreferredBackupWindow": { "Fn::If": [ "BlankPreferredBackupWindowOrReadReplica", { "Ref": "AWS::NoValue" }, { "Ref": "PreferredBackupWindow" } ] },
"PubliclyAccessible": "false",
"StorageEncrypted": { "Ref": "Encrypted" },
"StorageType": { "Fn::If": [ "BlankIops", "gp2", "io2" ] },
"SourceDBInstanceIdentifier": { "Fn::If": [ "IsReadReplica", { "Ref": "ReadSourceDB" }, { "Ref": "AWS::NoValue" } ] },
"VPCSecurityGroups": [ { "Ref": "SecurityGroup" } ]
}
}
Expand Down
54 changes: 54 additions & 0 deletions provider/aws/releases.go
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,29 @@ func (p *Provider) ReleasePromote(app, id string, opts structs.ReleasePromoteOpt
}
}

if sourceDB := params[upperName("readSourceDB")]; sourceDB != "" {
if rName := strings.TrimPrefix(sourceDB, "#convox.resources."); rName != sourceDB {
exist := false
if rName != r.Name {
for i := range m.Resources {
if m.Resources[i].Name == rName {
exist = true
if m.Resources[i].Type != r.Type {
return fmt.Errorf("resource type mismatch for readSourceDB")
}
params[upperName("readSourceDB")], err = p.getResourceDBIdentifier(app, rName)
if err != nil {
return err
}
}
}
}
if !exist {
return fmt.Errorf("invalid resource name for readSourceDB")
}
}
}

ou, err := p.ObjectStore(app, "", bytes.NewReader(data), structs.ObjectStoreOptions{Presign: options.Bool(true)})
if err != nil {
return err
Expand Down Expand Up @@ -998,3 +1021,34 @@ func (p *Provider) getResourceTemplateAndParams(app, resourceName string) ([]byt

return tmplBody, params, nil
}

func (p *Provider) getResourceDBIdentifier(app, resourceName string) (string, error) {
ars, err := p.describeStackResources(&cloudformation.DescribeStackResourcesInput{
StackName: aws.String(p.rackStack(app)),
})
if err != nil {
return "", err
}

arsns := map[string]string{}

for _, ar := range ars.StackResources {
arsns[cs(ar.LogicalResourceId, "")] = cs(ar.PhysicalResourceId, "")
}

stack := arsns[fmt.Sprintf("Resource%s", upperName(resourceName))]
res, err := p.describeStackResources(&cloudformation.DescribeStackResourcesInput{
StackName: aws.String(stack),
})
if err != nil {
return "", err
}

for _, r := range res.StackResources {
if *r.ResourceType == "AWS::RDS::DBInstance" {
return *r.PhysicalResourceId, nil
}
}

return "", fmt.Errorf("db instance not found")
}
2 changes: 1 addition & 1 deletion provider/aws/templates/resource/webhook.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"Environment": { "Variables": { "WEBHOOK_URL": { "Ref": "Url" } } },
"Handler": "index.handler",
"Role": { "Fn::GetAtt": [ "ForwarderRole", "Arn" ] },
"Runtime": "nodejs16.x",
"Runtime": "nodejs20.x",
"Timeout": "10"
}
},
Expand Down
2 changes: 1 addition & 1 deletion provider/kaws/formation/rack.yml
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ Resources:
}
Handler: index.main
Role: !GetAtt DomainMapperRole.Arn
Runtime: nodejs16.x
Runtime: nodejs20.x
DomainMapperRole:
Type: AWS::IAM::Role
Condition: BaseDomainBlank
Expand Down
Loading