@ericminassian/platform-engine 0.1.0 → 0.2.0

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.
Files changed (47) hide show
  1. package/dist/clients.d.ts +0 -11
  2. package/dist/clients.js +0 -19
  3. package/dist/clients.js.map +1 -1
  4. package/dist/drivers/cognito.d.ts +0 -9
  5. package/dist/drivers/cognito.js +2 -40
  6. package/dist/drivers/cognito.js.map +1 -1
  7. package/dist/drivers/iam.d.ts +0 -9
  8. package/dist/drivers/iam.js +1 -52
  9. package/dist/drivers/iam.js.map +1 -1
  10. package/dist/drivers/index.d.ts +0 -4
  11. package/dist/drivers/index.js +0 -4
  12. package/dist/drivers/index.js.map +1 -1
  13. package/dist/index.d.ts +2 -1
  14. package/dist/index.js +2 -1
  15. package/dist/index.js.map +1 -1
  16. package/dist/local.d.ts +2 -2
  17. package/dist/local.js +2 -2
  18. package/dist/policy.d.ts +0 -6
  19. package/dist/policy.js +0 -16
  20. package/dist/policy.js.map +1 -1
  21. package/dist/stage.js +1 -1
  22. package/dist/stage.js.map +1 -1
  23. package/package.json +2 -6
  24. package/src/clients.ts +0 -26
  25. package/src/drivers/cognito.ts +1 -53
  26. package/src/drivers/iam.ts +0 -70
  27. package/src/drivers/index.ts +0 -4
  28. package/src/index.ts +2 -1
  29. package/src/local.ts +2 -2
  30. package/src/policy.ts +0 -21
  31. package/src/stage.ts +1 -1
  32. package/dist/drivers/acm.d.ts +0 -20
  33. package/dist/drivers/acm.js +0 -62
  34. package/dist/drivers/acm.js.map +0 -1
  35. package/dist/drivers/cloudfront.d.ts +0 -52
  36. package/dist/drivers/cloudfront.js +0 -223
  37. package/dist/drivers/cloudfront.js.map +0 -1
  38. package/dist/drivers/route53.d.ts +0 -30
  39. package/dist/drivers/route53.js +0 -96
  40. package/dist/drivers/route53.js.map +0 -1
  41. package/dist/drivers/sns.d.ts +0 -7
  42. package/dist/drivers/sns.js +0 -20
  43. package/dist/drivers/sns.js.map +0 -1
  44. package/src/drivers/acm.ts +0 -88
  45. package/src/drivers/cloudfront.ts +0 -291
  46. package/src/drivers/route53.ts +0 -129
  47. package/src/drivers/sns.ts +0 -33
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ericminassian/platform-engine",
3
- "version": "0.1.0",
3
+ "version": "0.2.0",
4
4
  "description": "Idempotent AWS SDK drivers that provision and deploy platform stages (no CloudFormation).",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -23,7 +23,7 @@
23
23
  "src"
24
24
  ],
25
25
  "dependencies": {
26
- "@ericminassian/platform-core": "0.1.0",
26
+ "@ericminassian/platform-core": "0.2.0",
27
27
  "@aws-sdk/client-iam": "^3.1169.0",
28
28
  "@aws-sdk/client-dynamodb": "^3.1169.0",
29
29
  "@aws-sdk/client-sqs": "^3.1169.0",
@@ -35,12 +35,8 @@
35
35
  "@aws-sdk/client-s3": "^3.1169.0",
36
36
  "@aws-sdk/client-ssm": "^3.1169.0",
37
37
  "@aws-sdk/client-cognito-identity-provider": "^3.1169.0",
38
- "@aws-sdk/client-cloudfront": "^3.1169.0",
39
38
  "@aws-sdk/client-cloudfront-keyvaluestore": "^3.1169.0",
40
- "@aws-sdk/client-route-53": "^3.1169.0",
41
- "@aws-sdk/client-acm": "^3.1169.0",
42
39
  "@aws-sdk/client-sts": "^3.1169.0",
43
- "@aws-sdk/client-sns": "^3.1169.0",
44
40
  "@aws-sdk/client-resource-groups-tagging-api": "^3.1169.0",
45
41
  "@aws-sdk/signature-v4a": "^3.1138.0",
46
42
  "@smithy/node-http-handler": "^4.14.2",
package/src/clients.ts CHANGED
@@ -1,7 +1,5 @@
1
1
  import { readFileSync } from 'node:fs';
2
2
  import { Agent } from 'node:https';
3
- import { ACMClient } from '@aws-sdk/client-acm';
4
- import { CloudFrontClient } from '@aws-sdk/client-cloudfront';
5
3
  import { CloudFrontKeyValueStoreClient } from '@aws-sdk/client-cloudfront-keyvaluestore';
6
4
  import { CloudWatchLogsClient } from '@aws-sdk/client-cloudwatch-logs';
7
5
  import { CognitoIdentityProviderClient } from '@aws-sdk/client-cognito-identity-provider';
@@ -11,10 +9,8 @@ import { IAMClient } from '@aws-sdk/client-iam';
11
9
  import { LambdaClient } from '@aws-sdk/client-lambda';
12
10
  import { LambdaWebClient } from '@aws-sdk/client-lambda-web';
13
11
  import { ResourceGroupsTaggingAPIClient } from '@aws-sdk/client-resource-groups-tagging-api';
14
- import { Route53Client } from '@aws-sdk/client-route-53';
15
12
  import { S3Client } from '@aws-sdk/client-s3';
16
13
  import { SchedulerClient } from '@aws-sdk/client-scheduler';
17
- import { SNSClient } from '@aws-sdk/client-sns';
18
14
  import { SQSClient } from '@aws-sdk/client-sqs';
19
15
  import { SSMClient } from '@aws-sdk/client-ssm';
20
16
  import { STSClient } from '@aws-sdk/client-sts';
@@ -48,15 +44,8 @@ export interface AwsClients {
48
44
  readonly s3: S3Client;
49
45
  readonly ssm: SSMClient;
50
46
  readonly cognito: CognitoIdentityProviderClient;
51
- readonly cloudfront: CloudFrontClient;
52
47
  readonly kvs: CloudFrontKeyValueStoreClient;
53
- readonly route53: Route53Client;
54
- /** Certificates for CloudFront and Cognito custom domains must live in us-east-1. */
55
- readonly acm: ACMClient;
56
- readonly sns: SNSClient;
57
48
  readonly tagging: ResourceGroupsTaggingAPIClient;
58
- /** Same clients with different credentials (e.g. an assumed cross-account role). */
59
- withCredentials(credentials: NonNullable<ClientOptions['credentials']>): AwsClients;
60
49
  }
61
50
 
62
51
  type ClientConfig = {
@@ -120,27 +109,12 @@ export function createClients(opts: ClientOptions): AwsClients {
120
109
  get cognito() {
121
110
  return lazy('cognito', () => new CognitoIdentityProviderClient(base));
122
111
  },
123
- get cloudfront() {
124
- return lazy('cloudfront', () => new CloudFrontClient({ ...base, region: 'us-east-1' }));
125
- },
126
112
  get kvs() {
127
113
  return lazy('kvs', () => new CloudFrontKeyValueStoreClient({ ...base, region: 'us-east-1' }));
128
114
  },
129
- get route53() {
130
- return lazy('route53', () => new Route53Client({ ...base, region: 'us-east-1' }));
131
- },
132
- get acm() {
133
- return lazy('acm', () => new ACMClient({ ...base, region: 'us-east-1' }));
134
- },
135
- get sns() {
136
- return lazy('sns', () => new SNSClient(base));
137
- },
138
115
  get tagging() {
139
116
  return lazy('tagging', () => new ResourceGroupsTaggingAPIClient(base));
140
117
  },
141
- withCredentials(credentials) {
142
- return createClients({ ...opts, credentials });
143
- },
144
118
  };
145
119
  }
146
120
 
@@ -2,16 +2,14 @@ import {
2
2
  CreateManagedLoginBrandingCommand,
3
3
  CreateUserPoolClientCommand,
4
4
  CreateUserPoolCommand,
5
- CreateUserPoolDomainCommand,
6
5
  DeleteUserPoolClientCommand,
7
- DescribeUserPoolDomainCommand,
8
6
  type ExplicitAuthFlowsType,
9
7
  ListUserPoolClientsCommand,
10
8
  ListUserPoolsCommand,
11
9
  UpdateUserPoolClientCommand,
12
10
  } from '@aws-sdk/client-cognito-identity-provider';
13
11
  import { AUTH_SCOPES } from '@ericminassian/platform-core';
14
- import { type EngineContext, errorName, ignoreNotFound, isNotImplemented, retry } from '../util.ts';
12
+ import { type EngineContext, errorName, ignoreNotFound, isNotImplemented } from '../util.ts';
15
13
 
16
14
  /** Shared user pool for app end users: email sign-in, self sign-up, Essentials tier (managed login). */
17
15
  export async function ensureUserPool(
@@ -147,53 +145,3 @@ export async function deleteUserPoolClient(
147
145
  ctx.log('info', 'deleted app client', `user-pool-client ${name}`);
148
146
  return true;
149
147
  }
150
-
151
- /**
152
- * Managed login (v2) on a custom domain. Returns the CloudFront domain Route 53
153
- * must alias the custom domain to. The certificate must be in us-east-1.
154
- */
155
- export async function ensureUserPoolDomain(
156
- ctx: EngineContext,
157
- spec: { userPoolId: string; domain: string; certificateArn: string },
158
- ): Promise<string | undefined> {
159
- const cognito = ctx.clients.cognito;
160
- const existing = await cognito.send(new DescribeUserPoolDomainCommand({ Domain: spec.domain }));
161
- if (existing.DomainDescription?.UserPoolId) {
162
- if (existing.DomainDescription.UserPoolId !== spec.userPoolId) {
163
- throw new Error(`domain ${spec.domain} belongs to another user pool`);
164
- }
165
- return existing.DomainDescription.CloudFrontDistribution;
166
- }
167
- // Cognito requires the parent domain to resolve to an A record before it
168
- // accepts a custom domain. On a first run the parent is an alias to a
169
- // CloudFront distribution created moments earlier, which resolves only once
170
- // the distribution has deployed (several minutes), so keep retrying.
171
- let waiting = false;
172
- const res = await retry(
173
- () =>
174
- cognito.send(
175
- new CreateUserPoolDomainCommand({
176
- Domain: spec.domain,
177
- UserPoolId: spec.userPoolId,
178
- ManagedLoginVersion: 2,
179
- CustomDomainConfig: { CertificateArn: spec.certificateArn },
180
- }),
181
- ),
182
- {
183
- attempts: 120,
184
- delayMs: 5_000,
185
- when: (e) => {
186
- const parentMissing = /resolve a DNS A record for the parent domain/i.test(
187
- String((e as Error).message),
188
- );
189
- if (parentMissing && !waiting) {
190
- waiting = true;
191
- ctx.log('info', `waiting for the parent of ${spec.domain} to resolve (CloudFront still deploying)`);
192
- }
193
- return parentMissing;
194
- },
195
- },
196
- );
197
- ctx.log('info', 'created managed login domain', `user-pool-domain ${spec.domain}`);
198
- return res.CloudFrontDomain;
199
- }
@@ -1,20 +1,12 @@
1
1
  import {
2
2
  AttachRolePolicyCommand,
3
- CreateOpenIDConnectProviderCommand,
4
- CreatePolicyCommand,
5
- CreatePolicyVersionCommand,
6
3
  CreateRoleCommand,
7
- DeletePolicyVersionCommand,
8
4
  DeleteRoleCommand,
9
5
  DeleteRolePermissionsBoundaryCommand,
10
6
  DeleteRolePolicyCommand,
11
7
  DetachRolePolicyCommand,
12
- GetPolicyCommand,
13
- GetPolicyVersionCommand,
14
8
  GetRoleCommand,
15
9
  ListAttachedRolePoliciesCommand,
16
- ListOpenIDConnectProvidersCommand,
17
- ListPolicyVersionsCommand,
18
10
  ListRolePoliciesCommand,
19
11
  PutRolePermissionsBoundaryCommand,
20
12
  PutRolePolicyCommand,
@@ -131,65 +123,3 @@ export async function deleteRole(ctx: EngineContext, name: string): Promise<bool
131
123
  ctx.log('info', 'deleted role', `role ${name}`);
132
124
  return true;
133
125
  }
134
-
135
- /** Customer managed policy kept at `document` (new default version when it changes). */
136
- export async function ensureManagedPolicy(
137
- ctx: EngineContext,
138
- spec: { name: string; path?: string; description?: string; document: PolicyDocument },
139
- ): Promise<string> {
140
- const iam = ctx.clients.iam;
141
- const acct = await ctx.accountId();
142
- const path = spec.path ?? '/';
143
- const arn = `arn:aws:iam::${acct}:policy${path}${spec.name}`;
144
- const existing = await ignoreNotFound(iam.send(new GetPolicyCommand({ PolicyArn: arn })));
145
- if (!existing?.Policy) {
146
- await iam.send(
147
- new CreatePolicyCommand({
148
- PolicyName: spec.name,
149
- Path: path,
150
- Description: spec.description,
151
- PolicyDocument: JSON.stringify(spec.document),
152
- }),
153
- );
154
- ctx.log('info', 'created managed policy', `policy ${spec.name}`);
155
- return arn;
156
- }
157
- const version = await iam.send(
158
- new GetPolicyVersionCommand({ PolicyArn: arn, VersionId: existing.Policy.DefaultVersionId }),
159
- );
160
- if (samePolicy(version.PolicyVersion?.Document, spec.document)) return arn;
161
- const versions = await iam.send(new ListPolicyVersionsCommand({ PolicyArn: arn }));
162
- const old = (versions.Versions ?? []).filter((v) => !v.IsDefaultVersion);
163
- if ((versions.Versions ?? []).length >= 5 && old.length > 0) {
164
- const oldest = old.sort((a, b) => (a.CreateDate?.getTime() ?? 0) - (b.CreateDate?.getTime() ?? 0))[0]!;
165
- await iam.send(new DeletePolicyVersionCommand({ PolicyArn: arn, VersionId: oldest.VersionId }));
166
- }
167
- await iam.send(
168
- new CreatePolicyVersionCommand({
169
- PolicyArn: arn,
170
- PolicyDocument: JSON.stringify(spec.document),
171
- SetAsDefault: true,
172
- }),
173
- );
174
- ctx.log('info', 'updated managed policy', `policy ${spec.name}`);
175
- return arn;
176
- }
177
-
178
- /** GitHub Actions OIDC identity provider (one per account). */
179
- export async function ensureGithubOidcProvider(ctx: EngineContext): Promise<string> {
180
- const iam = ctx.clients.iam;
181
- const url = 'token.actions.githubusercontent.com';
182
- const list = await iam.send(new ListOpenIDConnectProvidersCommand({}));
183
- const found = (list.OpenIDConnectProviderList ?? []).find((p) => p.Arn?.endsWith(`/${url}`));
184
- if (found?.Arn) return found.Arn;
185
- const res = await iam.send(
186
- new CreateOpenIDConnectProviderCommand({
187
- Url: `https://${url}`,
188
- ClientIDList: ['sts.amazonaws.com'],
189
- // IAM no longer validates thumbprints for GitHub's well-known issuer, but the field is required.
190
- ThumbprintList: ['6938fd4d98bab03faadb97b34396831e3780aea1'],
191
- }),
192
- );
193
- ctx.log('info', 'created GitHub OIDC provider', `oidc ${url}`);
194
- return res.OpenIDConnectProviderArn!;
195
- }
@@ -1,5 +1,3 @@
1
- export * from './acm.ts';
2
- export * from './cloudfront.ts';
3
1
  export * from './cognito.ts';
4
2
  export * from './dynamodb.ts';
5
3
  export * from './events.ts';
@@ -7,10 +5,8 @@ export * from './iam.ts';
7
5
  export * from './kvs.ts';
8
6
  export * from './lambda.ts';
9
7
  export * from './logs.ts';
10
- export * from './route53.ts';
11
8
  export * from './s3.ts';
12
9
  export * from './scheduler.ts';
13
- export * from './sns.ts';
14
10
  export * from './sqs.ts';
15
11
  export * from './ssm.ts';
16
12
  export * from './web-function.ts';
package/src/index.ts CHANGED
@@ -7,7 +7,8 @@
7
7
  * The same engine runs in three places:
8
8
  * - the control plane's deployer (real AWS),
9
9
  * - `plat dev` / `plat test` (AWS Emulator, `webMode: 'external'`),
10
- * - `foundation/` (the platform's own shared resources).
10
+ * - `foundation/`, which deploys the control plane itself (the platform's
11
+ * shared resources around it are a CDK stack, not engine resources).
11
12
  *
12
13
  * CONTRACT: the exported names and types below are used by the CLI, the
13
14
  * control plane and the foundation. Keep them stable.
package/src/local.ts CHANGED
@@ -6,8 +6,8 @@ import { type EngineContext, platformTags } from './util.ts';
6
6
 
7
7
  /**
8
8
  * Inside a fresh AWS Emulator, create the shared resources a stage deploy
9
- * expects (the same ones `foundation/` creates in AWS, minus CloudFront,
10
- * DNS and certificates) and describe them as a runtime config.
9
+ * expects (the ones the foundation stack holds in AWS, minus CloudFront, DNS,
10
+ * certificates and IAM) and describe them as a runtime config.
11
11
  */
12
12
  export async function ensureLocal(
13
13
  ctx: EngineContext,
package/src/policy.ts CHANGED
@@ -370,27 +370,6 @@ export function controlPlanePolicy(input: {
370
370
  return policy(...statements);
371
371
  }
372
372
 
373
- /** Trust for the platform repo's CI role: GitHub Actions OIDC, main branch only. */
374
- export function githubCiTrustPolicy(input: {
375
- accountId: string;
376
- owner: string;
377
- repo: string;
378
- }): PolicyDocument {
379
- return policy({
380
- Effect: 'Allow',
381
- Principal: {
382
- Federated: `arn:aws:iam::${input.accountId}:oidc-provider/token.actions.githubusercontent.com`,
383
- },
384
- Action: 'sts:AssumeRoleWithWebIdentity',
385
- Condition: {
386
- StringEquals: {
387
- 'token.actions.githubusercontent.com:aud': 'sts.amazonaws.com',
388
- 'token.actions.githubusercontent.com:sub': `repo:${input.owner}/${input.repo}:ref:refs/heads/main`,
389
- },
390
- },
391
- });
392
- }
393
-
394
373
  export function serviceTrustPolicy(...services: string[]): PolicyDocument {
395
374
  return policy({ Effect: 'Allow', Principal: { Service: services }, Action: 'sts:AssumeRole' });
396
375
  }
package/src/stage.ts CHANGED
@@ -130,7 +130,7 @@ export async function deployStage(ctx: EngineContext, input: DeployStageInput):
130
130
  } else if (await describeTable(ctx, names.table(app, stage))) {
131
131
  ctx.log(
132
132
  'warn',
133
- 'db is off in platform.json but the table still exists; keeping it (data)',
133
+ 'db is off in plat.config.ts but the table still exists; keeping it (data)',
134
134
  `table ${names.table(app, stage)}`,
135
135
  );
136
136
  }
@@ -1,20 +0,0 @@
1
- import { type EngineContext } from '../util.ts';
2
- export interface CertificateState {
3
- arn: string;
4
- status: string;
5
- /** DNS records ACM wants for validation (CNAMEs). */
6
- validation: Array<{
7
- domain: string;
8
- name: string;
9
- value: string;
10
- status?: string;
11
- }>;
12
- }
13
- /** A DNS-validated public certificate in us-east-1 (for CloudFront and Cognito custom domains). */
14
- export declare function ensureCertificate(ctx: EngineContext, spec: {
15
- domainName: string;
16
- alternativeNames?: string[];
17
- tags?: Record<string, string>;
18
- }): Promise<CertificateState>;
19
- export declare function describeCertificate(ctx: EngineContext, arn: string): Promise<CertificateState>;
20
- export declare function waitCertificateIssued(ctx: EngineContext, arn: string, timeoutMs?: number): Promise<void>;
@@ -1,62 +0,0 @@
1
- import { DescribeCertificateCommand, ListCertificatesCommand, RequestCertificateCommand, } from '@aws-sdk/client-acm';
2
- import { tagList, waitFor } from '../util.js';
3
- /** A DNS-validated public certificate in us-east-1 (for CloudFront and Cognito custom domains). */
4
- export async function ensureCertificate(ctx, spec) {
5
- const acm = ctx.clients.acm;
6
- const wantedSans = [...new Set([spec.domainName, ...(spec.alternativeNames ?? [])])].sort();
7
- let arn;
8
- let NextToken;
9
- do {
10
- const res = await acm.send(new ListCertificatesCommand({ CertificateStatuses: ['ISSUED', 'PENDING_VALIDATION'], NextToken }));
11
- for (const c of res.CertificateSummaryList ?? []) {
12
- if (c.DomainName !== spec.domainName || !c.CertificateArn)
13
- continue;
14
- const d = await acm.send(new DescribeCertificateCommand({ CertificateArn: c.CertificateArn }));
15
- const sans = [...(d.Certificate?.SubjectAlternativeNames ?? [])].sort();
16
- if (JSON.stringify(sans) === JSON.stringify(wantedSans)) {
17
- arn = c.CertificateArn;
18
- break;
19
- }
20
- }
21
- NextToken = arn ? undefined : res.NextToken;
22
- } while (NextToken);
23
- if (!arn) {
24
- const res = await acm.send(new RequestCertificateCommand({
25
- DomainName: spec.domainName,
26
- SubjectAlternativeNames: wantedSans,
27
- ValidationMethod: 'DNS',
28
- IdempotencyToken: spec.domainName.replace(/[^A-Za-z0-9]/g, '').slice(0, 32),
29
- Tags: spec.tags ? tagList(spec.tags) : undefined,
30
- }));
31
- arn = res.CertificateArn;
32
- ctx.log('info', 'requested certificate', `certificate ${spec.domainName}`);
33
- }
34
- return describeCertificate(ctx, arn);
35
- }
36
- export async function describeCertificate(ctx, arn) {
37
- // Validation records appear a few seconds after the request.
38
- return waitFor(`certificate ${arn} validation records`, async () => {
39
- const d = await ctx.clients.acm.send(new DescribeCertificateCommand({ CertificateArn: arn }));
40
- const cert = d.Certificate;
41
- const validation = (cert.DomainValidationOptions ?? [])
42
- .filter((o) => o.ResourceRecord?.Name)
43
- .map((o) => ({
44
- domain: o.DomainName,
45
- name: o.ResourceRecord.Name,
46
- value: o.ResourceRecord.Value,
47
- ...(o.ValidationStatus ? { status: o.ValidationStatus } : {}),
48
- }));
49
- if (cert.Status === 'PENDING_VALIDATION' && validation.length === 0)
50
- return false;
51
- return { arn, status: cert.Status ?? 'UNKNOWN', validation };
52
- });
53
- }
54
- export async function waitCertificateIssued(ctx, arn, timeoutMs = 15 * 60_000) {
55
- await waitFor(`certificate ${arn} issued`, async () => {
56
- const d = await ctx.clients.acm.send(new DescribeCertificateCommand({ CertificateArn: arn }));
57
- if (d.Certificate?.Status === 'FAILED')
58
- throw new Error(`certificate ${arn} failed validation`);
59
- return d.Certificate?.Status === 'ISSUED';
60
- }, { timeoutMs, intervalMs: 10_000 });
61
- }
62
- //# sourceMappingURL=acm.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"acm.js","sourceRoot":"","sources":["../../src/drivers/acm.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,0BAA0B,EAC1B,uBAAuB,EACvB,yBAAyB,GAC1B,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAsB,OAAO,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AASlE,mGAAmG;AACnG,MAAM,CAAC,KAAK,UAAU,iBAAiB,CACrC,GAAkB,EAClB,IAAwF;IAExF,MAAM,GAAG,GAAG,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC;IAC5B,MAAM,UAAU,GAAG,CAAC,GAAG,IAAI,GAAG,CAAC,CAAC,IAAI,CAAC,UAAU,EAAE,GAAG,CAAC,IAAI,CAAC,gBAAgB,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,CA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CAAC,CAAC,EAAE,CAAC;SAC9D,CAAC,CAAC,CAAC;QACN,IAAI,IAAI,CAAC,MAAM,KAAK,oBAAoB,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO,KAAK,CAAC;QAClF,OAAO,EAAE,GAAG,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,IAAI,SAAS,EAAE,UAAU,EAAE,CAAC;IAC/D,CAAC,CAAC,CAAC;AACL,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,qBAAqB,CACzC,GAAkB,EAClB,GAAW,EACX,SAAS,GAAG,EAAE,GAAG,MAAM;IAEvB,MAAM,OAAO,CACX,eAAe,GAAG,SAAS,EAC3B,KAAK,IAAI,EAAE;QACT,MAAM,CAAC,GAAG,MAAM,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,0BAA0B,CAAC,EAAE,cAAc,EAAE,GAAG,EAAE,CAAC,CAAC,CAAC;QAC9F,IAAI,CAAC,CAAC,WAAW,EAAE,MAAM,KAAK,QAAQ;YAAE,MAAM,IAAI,KAAK,CAAC,eAAe,GAAG,oBAAoB,CAAC,CAAC;QAChG,OAAO,CAAC,CAAC,WAAW,EAAE,MAAM,KAAK,QAAQ,CAAC;IAC5C,CAAC,EACD,EAAE,SAAS,EAAE,UAAU,EAAE,MAAM,EAAE,CAClC,CAAC;AACJ,CAAC"}
@@ -1,52 +0,0 @@
1
- import { type CachePolicyConfig, type DistributionConfig } from '@aws-sdk/client-cloudfront';
2
- import { type EngineContext } from '../util.ts';
3
- /** AWS managed origin request policy `Managed-AllViewerExceptHostHeader` (Web Function origins need it). */
4
- export declare const ALL_VIEWER_EXCEPT_HOST_HEADER = "b689b0a8-53d0-40ab-baf2-68738e2966ac";
5
- /** Route 53 hosted zone id for every CloudFront alias target. */
6
- export declare const CLOUDFRONT_HOSTED_ZONE_ID = "Z2FDTNDATAQYW2";
7
- export declare function ensureKeyValueStore(ctx: EngineContext, spec: {
8
- name: string;
9
- comment?: string;
10
- }): Promise<{
11
- arn: string;
12
- id: string;
13
- }>;
14
- /** Create/update a CloudFront Function (runtime 2.0) and publish it to LIVE. Returns the function ARN. */
15
- export declare function ensureRouterFunction(ctx: EngineContext, spec: {
16
- name: string;
17
- code: string;
18
- kvsArn?: string;
19
- comment?: string;
20
- }): Promise<string>;
21
- export declare function ensureOriginAccessControl(ctx: EngineContext, spec: {
22
- name: string;
23
- originType: 's3' | 'lambda';
24
- signingBehavior?: 'always' | 'always-amz-auth';
25
- }): Promise<string>;
26
- export declare function ensureCachePolicy(ctx: EngineContext, config: CachePolicyConfig): Promise<string>;
27
- /** The platform router's cache policy: origins decide caching; the host is part of the key. */
28
- export declare function routerCachePolicy(name: string): CachePolicyConfig;
29
- export interface DistributionState {
30
- id: string;
31
- arn: string;
32
- domainName: string;
33
- status: string;
34
- }
35
- /**
36
- * A distribution identified by its `Comment` (CloudFront has no names).
37
- * `config` is the full desired DistributionConfig minus CallerReference.
38
- */
39
- export declare function ensureDistribution(ctx: EngineContext, spec: {
40
- comment: string;
41
- config: Omit<DistributionConfig, 'CallerReference' | 'Comment'>;
42
- tags?: Record<string, string>;
43
- }): Promise<DistributionState>;
44
- export declare function findDistribution(ctx: EngineContext, comment: string): Promise<DistributionState | undefined>;
45
- /**
46
- * Overlay `patch` on `base`: objects merge key by key, equal-length arrays
47
- * merge element by element (CloudFront lists like Origins keep their order),
48
- * anything else is replaced. Undefined patch values keep the base value.
49
- */
50
- export declare function deepMerge(base: unknown, patch: unknown): unknown;
51
- /** Paths where two normalized values differ, e.g. `DefaultCacheBehavior.Compress`. */
52
- export declare function diffPaths(a: unknown, b: unknown, path?: string): string[];