@pattform/api-kit 2.6.1 → 2.6.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -46,6 +46,5 @@ export interface FormComponentArgs {
46
46
  brevoApiKey?: pulumi.Input<string>;
47
47
  turnstileSiteKey?: pulumi.Input<string>;
48
48
  turnstileSecret?: pulumi.Input<string>;
49
- alarmEmail?: string;
50
49
  reservedConcurrency?: number;
51
50
  }
@@ -127,35 +127,6 @@ class FormComponent extends pulumi.ComponentResource {
127
127
  provider: awsProvider,
128
128
  parent: this,
129
129
  });
130
- const alarmTopic = new aws.sns.Topic(`${baseName}-alarms-${env}`, {}, {
131
- provider: awsProvider,
132
- parent: this,
133
- });
134
- // The email subscription must be confirmed once from the inbox.
135
- new aws.sns.TopicSubscription(`${baseName}-alarm-email-${env}`, {
136
- topic: alarmTopic.arn,
137
- protocol: "email",
138
- endpoint: args.alarmEmail || "contact@pattform.io",
139
- }, {
140
- provider: awsProvider,
141
- parent: this,
142
- });
143
- new aws.cloudwatch.MetricAlarm(`${baseName}-errors-${env}`, {
144
- namespace: "AWS/Lambda",
145
- metricName: "Errors",
146
- dimensions: { FunctionName: this.lambda.name },
147
- statistic: "Sum",
148
- period: 300,
149
- evaluationPeriods: 1,
150
- comparisonOperator: "GreaterThanOrEqualToThreshold",
151
- threshold: 1,
152
- treatMissingData: "notBreaching",
153
- alarmDescription: `Form endpoint ${baseName} is returning errors`,
154
- alarmActions: [alarmTopic.arn],
155
- }, {
156
- provider: awsProvider,
157
- parent: this,
158
- });
159
130
  this.endpoint = this.functionUrl.functionUrl;
160
131
  this.turnstileSiteKey = pulumi.output(turnstileSiteKey);
161
132
  this.registerOutputs({
package/dist/index.d.ts CHANGED
@@ -4,4 +4,4 @@ export { AppComponent, AppComponentArgs, DnsRecordInstruction } from "./AppCompo
4
4
  export { ClientAccountComponent, ClientAccountComponentArgs } from "./ClientAccountComponent";
5
5
  export { GcpProjectComponent, GcpProjectComponentArgs } from "./GcpProjectComponent";
6
6
  export { FormComponent, FormComponentArgs, FormFieldSpec, FormDestination } from "./FormComponent";
7
- export { getClientRoleArn } from "./pattformHelper";
7
+ export { getClientRoleArn, getClientGcpDeploySa, getClientGcpProvider } from "./pattformHelper";
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getClientRoleArn = exports.FormComponent = exports.GcpProjectComponent = exports.ClientAccountComponent = exports.AppComponent = exports.ApiComponent = exports.ContainerComponent = void 0;
3
+ exports.getClientGcpProvider = exports.getClientGcpDeploySa = exports.getClientRoleArn = exports.FormComponent = exports.GcpProjectComponent = exports.ClientAccountComponent = exports.AppComponent = exports.ApiComponent = exports.ContainerComponent = void 0;
4
4
  var ContainerComponent_1 = require("./ContainerComponent");
5
5
  Object.defineProperty(exports, "ContainerComponent", { enumerable: true, get: function () { return ContainerComponent_1.ContainerComponent; } });
6
6
  var ApiComponent_1 = require("./ApiComponent");
@@ -15,3 +15,5 @@ var FormComponent_1 = require("./FormComponent");
15
15
  Object.defineProperty(exports, "FormComponent", { enumerable: true, get: function () { return FormComponent_1.FormComponent; } });
16
16
  var pattformHelper_1 = require("./pattformHelper");
17
17
  Object.defineProperty(exports, "getClientRoleArn", { enumerable: true, get: function () { return pattformHelper_1.getClientRoleArn; } });
18
+ Object.defineProperty(exports, "getClientGcpDeploySa", { enumerable: true, get: function () { return pattformHelper_1.getClientGcpDeploySa; } });
19
+ Object.defineProperty(exports, "getClientGcpProvider", { enumerable: true, get: function () { return pattformHelper_1.getClientGcpProvider; } });
@@ -1,3 +1,6 @@
1
1
  import * as pulumi from "@pulumi/pulumi";
2
+ import * as gcp from "@pulumi/gcp";
2
3
  export declare function getClientRoleArn(client: string, infrastructureStack?: string): pulumi.Output<string>;
4
+ export declare function getClientGcpDeploySa(client: string, infrastructureStack?: string): pulumi.Output<string>;
5
+ export declare function getClientGcpProvider(client: string, infrastructureStack?: string): gcp.Provider;
3
6
  export declare function verifyRegion(awsRegion: string): any;
@@ -1,8 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.verifyRegion = exports.getClientRoleArn = void 0;
3
+ exports.verifyRegion = exports.getClientGcpProvider = exports.getClientGcpDeploySa = exports.getClientRoleArn = void 0;
4
4
  const pulumi = require("@pulumi/pulumi");
5
5
  const aws = require("@pulumi/aws");
6
+ const gcp = require("@pulumi/gcp");
6
7
  const DEFAULT_INFRASTRUCTURE_STACK = "Pattform/pattform-infrastructure/prod";
7
8
  // StackReferences are resources, so creating the same one twice in a program
8
9
  // would collide on its URN; memoise per stack name.
@@ -25,6 +26,48 @@ function getClientRoleArn(client, infrastructureStack = DEFAULT_INFRASTRUCTURE_S
25
26
  });
26
27
  }
27
28
  exports.getClientRoleArn = getClientRoleArn;
29
+ // Looks up a client's GCP deploy service account from the
30
+ // pattform-infrastructure stack (GCP analog of getClientRoleArn).
31
+ function getClientGcpDeploySa(client, infrastructureStack = DEFAULT_INFRASTRUCTURE_STACK) {
32
+ if (!stackReferences[infrastructureStack]) {
33
+ stackReferences[infrastructureStack] = new pulumi.StackReference(infrastructureStack);
34
+ }
35
+ return stackReferences[infrastructureStack].requireOutput("clientGcpDeploySas").apply(sas => {
36
+ const sa = sas[client];
37
+ if (!sa) {
38
+ const known = Object.keys(sas).join(", ") || "<none>";
39
+ throw new Error(`Client "${client}" has no GCP deploy service account in ${infrastructureStack} (known clients: ${known}). ` +
40
+ `Add a GcpProjectComponent for it in pattform-infrastructure and deploy that stack first.`);
41
+ }
42
+ return sa;
43
+ });
44
+ }
45
+ exports.getClientGcpDeploySa = getClientGcpDeploySa;
46
+ // Providers are resources; memoise so a program can call this repeatedly.
47
+ const gcpProviders = {};
48
+ // GCP provider that deploys as the client's deploy SA: the base identity from
49
+ // the shared Common gcp-login impersonates deploy@<project>, mirroring the
50
+ // assume-role hop AWS components make with getClientRoleArn. Pass it to GCP
51
+ // resources/components:
52
+ // const gcpProvider = getClientGcpProvider(client);
53
+ // new ContainerComponent(name, args, { providers: [gcpProvider] });
54
+ function getClientGcpProvider(client, infrastructureStack = DEFAULT_INFRASTRUCTURE_STACK) {
55
+ const key = `${infrastructureStack}/${client}`;
56
+ if (!gcpProviders[key]) {
57
+ const gcpConfig = new pulumi.Config("gcp");
58
+ gcpProviders[key] = new gcp.Provider(`pattform-gcp-${client}`, {
59
+ // Explicit providers do not inherit gcp:* stack config (same trap
60
+ // as aws:accessKey on explicit AWS providers), so the base token
61
+ // performing the impersonation must be passed through.
62
+ accessToken: gcpConfig.get("accessToken"),
63
+ project: gcpConfig.get("project"),
64
+ region: gcpConfig.get("region"),
65
+ impersonateServiceAccount: getClientGcpDeploySa(client, infrastructureStack),
66
+ });
67
+ }
68
+ return gcpProviders[key];
69
+ }
70
+ exports.getClientGcpProvider = getClientGcpProvider;
28
71
  function verifyRegion(awsRegion) {
29
72
  for (const [key, value] of Object.entries(aws.Region)) {
30
73
  if (value == awsRegion) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pattform/api-kit",
3
- "version": "2.6.1",
3
+ "version": "2.6.3",
4
4
  "description": "Pulumi infra library for building and deploying an API",
5
5
  "author": "Pattform <contact@pattform.io>",
6
6
  "license": "SEE LICENSE IN LICENSE",