diff --git a/packages/fxa-admin-panel/src/components/PageRelyingParties/index.test.tsx b/packages/fxa-admin-panel/src/components/PageRelyingParties/index.test.tsx index 9f518c18147..1e66e50e9bb 100644 --- a/packages/fxa-admin-panel/src/components/PageRelyingParties/index.test.tsx +++ b/packages/fxa-admin-panel/src/components/PageRelyingParties/index.test.tsx @@ -147,9 +147,8 @@ it('creates a new relying party via UI', async () => { await screen.findByText( 'To finalize this new RP, a couple more steps are needed' ); - await screen.findByText( - 'gcloud pubsub topics create rpQueue-new-id --message-retention-duration=2678400s' - ); + await screen.findByText('eventbroker_endpoint_subscription_config'); + await screen.findByText('fxa-legacy/tf/stage/locals.tf'); await screen.findByText('client_secret: SECRET123'); fireEvent.click(screen.getByText('Got it!')); diff --git a/packages/fxa-admin-panel/src/components/PageRelyingParties/index.tsx b/packages/fxa-admin-panel/src/components/PageRelyingParties/index.tsx index 253d9da0d21..2e5c8ab02fe 100644 --- a/packages/fxa-admin-panel/src/components/PageRelyingParties/index.tsx +++ b/packages/fxa-admin-panel/src/components/PageRelyingParties/index.tsx @@ -17,7 +17,11 @@ import { AdminPanelFeature } from '@fxa/shared/guards'; import { Guard } from '../Guard'; import { useGuardContext } from '../../hooks/GuardContext'; import { useUserContext } from '../../hooks/UserContext'; -import { getFormattedDate, getWafTfPath } from '../../lib/utils'; +import { + getEventBrokerTfPath, + getFormattedDate, + getWafTfPath, +} from '../../lib/utils'; import { TableRowYHeader, TableYHeaders } from '../TableYHeaders'; import { adminApi } from '../../lib/api'; @@ -194,21 +198,8 @@ const CreateRelyingParty = ({ onExit }: { onExit: () => void }) => { const [rpId, setRpId] = useState(''); const [rpSecret, setRpSecret] = useState(''); - // Note, these are v1 projects. We need to migrate queues over to V2. - const gcpTerminalLink = - window.location.host === 'fxa-admin-panel.prod.mozaws.net' - ? `https://console.cloud.google.com/welcome?cloudshell=true&project=moz-fx-fxa-prod-375e` - : `https://console.cloud.google.com/welcome?cloudshell=true&project=moz-fx-fxa-nonprod-375e`; - - const oauthClientConfig = - window.location.host === 'fxa-admin-panel.prod.mozaws.net' - ? `https://github.com/mozilla/webservices-infra/blob/main/fxa/k8s/fxa/values-prod.yaml` - : `https://github.com/mozilla/webservices-infra/blob/main/fxa/k8s/fxa/values-stage.yaml`; - - const eventBrokerTfConfig = - window.location.host === 'fxa-admin-panel.prod.mozaws.net' - ? `https://github.com/mozilla-services/cloudops-infra/blob/master/projects/fxa/tf/prod/envs/prod/resources/eventbroker.tf` - : `https://github.com/mozilla-services/cloudops-infra/blob/master/projects/fxa/tf/nonprod/envs/stage/resources/eventbroker.tf`; + const eventBrokerTfPath = getEventBrokerTfPath(); + const eventBrokerTfUrl = `https://github.com/mozilla/webservices-infra/blob/main/${eventBrokerTfPath}`; const resetState = () => { setStatus(''); @@ -246,49 +237,29 @@ const CreateRelyingParty = ({ onExit }: { onExit: () => void }) => { To finalize this new RP, a couple more steps are needed

- Step 1: Create a pubsub queue. In order to do this click{' '} - - here - {' '} - to open a gcp terminal, and issue the following command: -

-              gcloud pubsub topics create rpQueue-{rpId}{' '}
-              --message-retention-duration=2678400s
-            
-

- -

- Step 2: Next, update this{' '} + Step 1: Add the client id to the{' '} + eventbroker_endpoint_subscription_config map in{' '} - file + {eventBrokerTfPath} {' '} - accordingly. This registers the webhook used for message delivery. -

- -

- Step 3: Next, update the OAUTH_CLIENT_IDS mappings{' '} - - here - - . This is used to map client-ids to a known name for legacy - amplitude events. This is considered optional, and may be RP - dependant. + (webservices-infra). One entry provisions the topic, the push + subscription, and the Firestore webhook document. +

{`"${rpId}" = {
+  endpoint        = "",
+  resource_server = ,
+},`}
+ Both attributes are optional. resource_server defaults + to false. Omit endpoint entirely for a + topic with no webhook.

- Step 4: Provide the following secret in secure manner to the + Step 2: Provide the following secret in secure manner to the relying party. This secret cannot be displayed again! If it is lost or compromised, the RP's secret must be rotated.
diff --git a/packages/fxa-admin-panel/src/lib/utils.spec.ts b/packages/fxa-admin-panel/src/lib/utils.spec.ts index 429fed44a77..83532c7c30d 100644 --- a/packages/fxa-admin-panel/src/lib/utils.spec.ts +++ b/packages/fxa-admin-panel/src/lib/utils.spec.ts @@ -2,7 +2,14 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -import { getFormattedDuration } from './utils'; +import { getEventBrokerTfPath, getFormattedDuration } from './utils'; + +const setHost = (host: string) => { + Object.defineProperty(window, 'location', { + value: { host }, + writable: true, + }); +}; describe('utils', () => { describe('formatDuration', () => { @@ -24,4 +31,33 @@ describe('utils', () => { ); }); }); + + describe('getEventBrokerTfPath', () => { + const originalLocation = window.location; + + afterEach(() => { + Object.defineProperty(window, 'location', { + value: originalLocation, + writable: true, + }); + }); + + it.each([ + { + host: 'fxa-admin-panel.prod.mozaws.net', + expected: 'fxa-legacy/tf/prod/locals.tf', + }, + { + host: 'fxa-admin-panel.prod.mozgcp.net', + expected: 'fxa-legacy/tf/prod/locals.tf', + }, + { + host: 'fxa-admin-panel.stage.mozaws.net', + expected: 'fxa-legacy/tf/stage/locals.tf', + }, + ])('should return $expected on $host', ({ host, expected }) => { + setHost(host); + expect(getEventBrokerTfPath()).toBe(expected); + }); + }); }); diff --git a/packages/fxa-admin-panel/src/lib/utils.ts b/packages/fxa-admin-panel/src/lib/utils.ts index 939221b3c16..d7a363d9c4f 100644 --- a/packages/fxa-admin-panel/src/lib/utils.ts +++ b/packages/fxa-admin-panel/src/lib/utils.ts @@ -22,3 +22,8 @@ export const getWafTfPath = () => window.location.host.startsWith('fxa-admin-panel.prod.') ? 'fxa/tf/prod/waf.tf' : 'fxa/tf/stage/waf.tf'; + +export const getEventBrokerTfPath = () => + window.location.host.startsWith('fxa-admin-panel.prod.') + ? 'fxa-legacy/tf/prod/locals.tf' + : 'fxa-legacy/tf/stage/locals.tf';