+ + +
++
`; + } +} diff --git a/src/server_manager/web_app/gcp_account.ts b/src/server_manager/web_app/gcp_account.ts new file mode 100644 index 000000000..6cc9ecc10 --- /dev/null +++ b/src/server_manager/web_app/gcp_account.ts @@ -0,0 +1,330 @@ +// Copyright 2021 The Outline Authors +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +import * as gcp_api from '../cloud/gcp_api'; +import {sleep} from '../infrastructure/sleep'; +import {SCRIPT} from '../install_scripts/gcp_install_script'; +import * as gcp from '../model/gcp'; +import {BillingAccount, Project} from '../model/gcp'; +import * as server from '../model/server'; + +import {GcpServer} from './gcp_server'; +import * as server_install from './server_install'; + +/** Returns a unique, RFC1035-style name as required by GCE. */ +function makeGcpInstanceName(): string { + function pad2(val: number) { + return val.toString().padStart(2, '0'); + } + + const now = new Date(); + const year = now.getUTCFullYear().toString(); + const month = pad2(now.getUTCMonth() + 1); // January is month 0. + const day = pad2(now.getUTCDate()); + const hour = pad2(now.getUTCHours()); + const minute = pad2(now.getUTCMinutes()); + const second = pad2(now.getUTCSeconds()); + return `outline-${year}${month}${day}-${hour}${minute}${second}`; +} + +// Regions where the first f1-micro instance is free. +// See https://cloud.google.com/free/docs/gcp-free-tier/#compute +const FREE_TIER_REGIONS = new Set