Skip to content

Commit

Permalink
Add a CMEK warning, and only suggest lowercase csql ids (#8148)
Browse files Browse the repository at this point in the history
* Add a CMEK warning, and only suggest lowercase csql ids

* formats
  • Loading branch information
joehan authored Jan 27, 2025
1 parent 753f032 commit fda4d14
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
9 changes: 9 additions & 0 deletions src/dataconnect/provisionCloudSql.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ export async function provisionCloudSql(args: {
if (err.status !== 404) {
throw err;
}
cmekWarning();
const cta = dryRun ? "It will be created on your next deploy" : "Creating it now.";
silent ||
utils.logLabeledBullet(
Expand Down Expand Up @@ -182,3 +183,11 @@ export function getUpdateReason(instance: Instance, requireGoogleMlIntegration:

return reason;
}

function cmekWarning() {
const message =
"The no-cost Cloud SQL trial instance does not support customer managed encryption keys.\n" +
"If you'd like to use a CMEK to encrypt your data, first create a CMEK encrypted instance (https://cloud.google.com/sql/docs/postgres/configure-cmek#createcmekinstance).\n" +
"Then, edit your `dataconnect.yaml` file to use the encrypted instance and redeploy.";
utils.logLabeledWarning("dataconnect", message);
}
5 changes: 3 additions & 2 deletions src/init/features/dataconnect/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,8 @@ async function askQuestions(setup: Setup, isBillingEnabled: boolean): Promise<Re
// Ensure that the suggested name is DNS compatible
const defaultServiceId = toDNSCompatibleId(basename(process.cwd()));
info.serviceId = info.serviceId || defaultServiceId;
info.cloudSqlInstanceId = info.cloudSqlInstanceId || `${info.serviceId || "app"}-fdc`;
info.cloudSqlInstanceId =
info.cloudSqlInstanceId || `${info.serviceId.toLowerCase() || "app"}-fdc`;
info.locationId = info.locationId || `us-central1`;
info.cloudSqlDatabase = info.cloudSqlDatabase || `fdcdb`;
}
Expand Down Expand Up @@ -370,7 +371,7 @@ async function promptForCloudSQL(setup: Setup, info: RequiredInfo): Promise<Requ
info.cloudSqlInstanceId = await promptOnce({
message: `What ID would you like to use for your new CloudSQL instance?`,
type: "input",
default: `${info.serviceId || "app"}-fdc`,
default: `${info.serviceId.toLowerCase() || "app"}-fdc`,
});
}
if (info.locationId === "") {
Expand Down

0 comments on commit fda4d14

Please sign in to comment.