-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Provision App Hosting compute service account during init flow #8580
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
Changes from 3 commits
93ec712
2460769
2dc8702
0242d9f
e456d81
0337933
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In It's a real trap right now to make a backend without attaching a git repo (or doing deploy from source), since AFAIK we don't have a command to add one later |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,22 +2,25 @@ import * as clc from "colorette"; | |
| import { existsSync } from "fs"; | ||
| import * as ora from "ora"; | ||
| import * as path from "path"; | ||
| import { Setup } from ".."; | ||
| import { webApps } from "../../apphosting/app"; | ||
| import { | ||
| createBackend, | ||
| ensureAppHostingComputeServiceAccount, | ||
| ensureRequiredApisEnabled, | ||
| promptExistingBackend, | ||
| promptLocation, | ||
| promptNewBackendId, | ||
| } from "../../apphosting/backend"; | ||
| import { Config } from "../../config"; | ||
| import { FirebaseError } from "../../error"; | ||
| import { AppHostingSingle } from "../../firebaseConfig"; | ||
| import { ensureApiEnabled } from "../../gcp/apphosting"; | ||
| import { isBillingEnabled } from "../../gcp/cloudbilling"; | ||
| import { input, select } from "../../prompt"; | ||
| import { readTemplateSync } from "../../templates"; | ||
| import * as utils from "../../utils"; | ||
| import { logBullet } from "../../utils"; | ||
| import { input, select } from "../../prompt"; | ||
| import { Setup } from ".."; | ||
| import { isBillingEnabled } from "../../gcp/cloudbilling"; | ||
|
|
||
| const APPHOSTING_YAML_TEMPLATE = readTemplateSync("init/apphosting/apphosting.yaml"); | ||
|
|
||
|
|
@@ -31,6 +34,26 @@ export async function doSetup(setup: Setup, config: Config): Promise<void> { | |
| "Firebase App Hosting requires billing to be enabled on your project. Please enable billing by following the steps at https://cloud.google.com/billing/docs/how-to/modify-project", | ||
| ); | ||
| } | ||
| await ensureApiEnabled({ projectId }); | ||
| await ensureRequiredApisEnabled(projectId); | ||
| // N.B. Deploying a backend from source requires the App Hosting compute service | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are we actually attaching the the storage.objectViewer role right now?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, the storage.objectViewer role change isn't relevant until the follow-up deploy from source PR #8516. Removing the comment. |
||
| // account to have the storage.objectViewer IAM role. | ||
| // | ||
| // We don't want to update the IAM permissions right before attempting to deploy, | ||
| // since IAM propagation delay will likely cause the first one to fail. However, | ||
| // `firebase init apphosting` is a prerequisite to the `firebase deploy` command, | ||
| // so we check and add the role here to give the IAM changes time to propagate. | ||
| try { | ||
| await ensureAppHostingComputeServiceAccount(projectId, /* serviceAccount= */ ""); | ||
| } catch (err) { | ||
| if ((err as FirebaseError).status === 400) { | ||
| utils.logWarning( | ||
| "Your App Hosting compute service account is still being provisioned. Please try again in a few moments.", | ||
| ); | ||
| } | ||
| throw err; | ||
| } | ||
|
|
||
| utils.logBullet( | ||
| "This command links your local project to Firebase App Hosting. You will be able to deploy your web app with `firebase deploy` after setup.", | ||
| ); | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems wrong to me? are we enabling deployments, or making a backend? I think the flow as-written doesn't link to github?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cc @jpreid7396 my understanding is that the description is meant to be generic enough to cover set up for deploy from source, but also any other features we might want to include as part of this flow. I'll defer to Julia here about the language specifics