Skip to content
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
112 changes: 24 additions & 88 deletions src/server/lib/jsonschema/schemas/1.0.0.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,7 @@
"type": "number"
}
},
"required": [
"name"
]
"required": ["name"]
}
},
"optionalServices": {
Expand All @@ -69,9 +67,7 @@
"type": "number"
}
},
"required": [
"name"
]
"required": ["name"]
}
},
"webhooks": {
Expand Down Expand Up @@ -124,9 +120,7 @@
"type": "number"
}
},
"required": [
"image"
]
"required": ["image"]
},
"command": {
"type": "object",
Expand All @@ -142,20 +136,13 @@
"type": "number"
}
},
"required": [
"image",
"script"
]
"required": ["image", "script"]
},
"env": {
"type": "object"
}
},
"required": [
"state",
"type",
"env"
]
"required": ["state", "type", "env"]
}
}
}
Expand Down Expand Up @@ -187,9 +174,7 @@
"type": "string"
}
},
"required": [
"name"
]
"required": ["name"]
}
},
"deploymentDependsOn": {
Expand Down Expand Up @@ -307,9 +292,7 @@
}
}
},
"required": [
"name"
]
"required": ["name"]
},
"envLens": {
"type": "boolean"
Expand Down Expand Up @@ -381,9 +364,7 @@
"minItems": 1
}
},
"required": [
"dockerfilePath"
]
"required": ["dockerfilePath"]
},
"init": {
"type": "object",
Expand All @@ -402,15 +383,10 @@
"type": "object"
}
},
"required": [
"dockerfilePath"
]
"required": ["dockerfilePath"]
}
},
"required": [
"defaultTag",
"app"
]
"required": ["defaultTag", "app"]
}
}
},
Expand Down Expand Up @@ -654,11 +630,7 @@
"type": "string"
}
},
"required": [
"name",
"mountPath",
"storageSize"
]
"required": ["name", "mountPath", "storageSize"]
}
},
"node_selector": {
Expand All @@ -674,10 +646,7 @@
}
}
},
"required": [
"repository",
"branchName"
]
"required": ["repository", "branchName"]
},
"github": {
"type": "object",
Expand Down Expand Up @@ -747,9 +716,7 @@
"minItems": 1
}
},
"required": [
"dockerfilePath"
]
"required": ["dockerfilePath"]
},
"init": {
"type": "object",
Expand All @@ -768,15 +735,10 @@
"type": "object"
}
},
"required": [
"dockerfilePath"
]
"required": ["dockerfilePath"]
}
},
"required": [
"defaultTag",
"app"
]
"required": ["defaultTag", "app"]
},
"deployment": {
"type": "object",
Expand Down Expand Up @@ -981,11 +943,7 @@
"type": "string"
}
},
"required": [
"name",
"mountPath",
"storageSize"
]
"required": ["name", "mountPath", "storageSize"]
}
},
"node_selector": {
Expand All @@ -1001,11 +959,7 @@
}
}
},
"required": [
"repository",
"branchName",
"docker"
]
"required": ["repository", "branchName", "docker"]
},
"docker": {
"type": "object",
Expand Down Expand Up @@ -1232,11 +1186,7 @@
"type": "string"
}
},
"required": [
"name",
"mountPath",
"storageSize"
]
"required": ["name", "mountPath", "storageSize"]
}
},
"node_selector": {
Expand All @@ -1252,10 +1202,7 @@
}
}
},
"required": [
"dockerImage",
"defaultTag"
]
"required": ["dockerImage", "defaultTag"]
},
"externalHttp": {
"type": "object",
Expand All @@ -1268,10 +1215,7 @@
"type": "string"
}
},
"required": [
"defaultInternalHostname",
"defaultPublicUrl"
]
"required": ["defaultInternalHostname", "defaultPublicUrl"]
},
"auroraRestore": {
"type": "object",
Expand All @@ -1284,10 +1228,7 @@
"type": "string"
}
},
"required": [
"command",
"arguments"
]
"required": ["command", "arguments"]
},
"configuration": {
"type": "object",
Expand All @@ -1300,16 +1241,11 @@
"type": "string"
}
},
"required": [
"defaultTag",
"branchName"
]
"required": ["defaultTag", "branchName"]
}
},
"required": [
"name"
]
"required": ["name"]
}
}
}
}
}
47 changes: 31 additions & 16 deletions src/server/services/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@ export default class DeployService extends BaseService {
* Helper function to check if an Aurora database already exists in AWS
* @param buildUuid The build UUID to search for
* @param serviceName The service name to search for
* @returns The database endpoint address if found, null otherwise
* @returns The database cluster endpoint address if found (or instance endpoint if not clustered), null otherwise
*/
private async findExistingAuroraDatabase(buildUuid: string, serviceName: string): Promise<string | null> {
try {
Expand All @@ -341,21 +341,36 @@ export default class DeployService extends BaseService {
})
.promise();

if (results.ResourceTagMappingList && results.ResourceTagMappingList.length > 0) {
const dbArn = results.ResourceTagMappingList[0].ResourceARN;
const params = {
Filters: [
{
Name: 'db-instance-id' /* required */,
Values: [dbArn],
},
],
};
const instances = await rds.describeDBInstances(params, null).promise();

if (instances.DBInstances.length === 1) {
const database = instances.DBInstances[0];
return database.Endpoint?.Address || null;
const instanceArn = results.ResourceTagMappingList?.find((mapping) =>
mapping.ResourceARN?.includes(':db:')
)?.ResourceARN;

if (instanceArn) {
const instanceIdentifier = instanceArn.split(':').pop();
if (instanceIdentifier) {
const instances = await rds
.describeDBInstances({
DBInstanceIdentifier: instanceIdentifier,
})
.promise();
const database = instances.DBInstances?.[0];
if (database) {
let databaseAddress = database.Endpoint?.Address;
// If this instance is part of a cluster, use the cluster endpoint instead
// for better resilience during instance failures and replacements
if (database.DBClusterIdentifier) {
const clusters = await rds
.describeDBClusters({
DBClusterIdentifier: database.DBClusterIdentifier,
})
.promise();
const clusterEndpoint = clusters.DBClusters?.[0]?.Endpoint;
if (clusterEndpoint) {
databaseAddress = clusterEndpoint;
}
}
return databaseAddress || null;
}
}
}
return null;
Expand Down