@stacksjs/cloud 0.66.0 → 0.68.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.
- package/{src/cloud/ai.ts → dist/ai.d.ts} +5 -9
- package/{src/cloud/cdn.ts → dist/cdn.d.ts} +9 -28
- package/dist/cli.d.ts +12 -0
- package/{src/cloud/compute.ts → dist/compute.d.ts} +13 -37
- package/{src/cloud/database.ts → dist/database.d.ts} +5 -10
- package/{src/cloud/deployment.ts → dist/deployment.d.ts} +5 -16
- package/{src/cloud/dns.ts → dist/dns.d.ts} +4 -11
- package/dist/docs.d.ts +34 -0
- package/{src/cloud/email.ts → dist/email.d.ts} +9 -29
- package/{src/cloud/file-system.ts → dist/file-system.d.ts} +6 -9
- package/dist/helpers.d.ts +50 -50
- package/dist/index.d.ts +2 -2
- package/dist/index.js +20 -23
- package/{src/cloud/jump-box.ts → dist/jump-box.d.ts} +7 -12
- package/{src/cloud/network.ts → dist/network.d.ts} +5 -8
- package/dist/origin-request.d.ts +5 -0
- package/dist/origin-request.js +6 -6
- package/{src/cloud/permissions.ts → dist/permissions.d.ts} +5 -13
- package/{src/cloud/queue.ts → dist/queue.d.ts} +9 -29
- package/{src/cloud/redirects.ts → dist/redirects.d.ts} +7 -14
- package/{src/cloud/security.ts → dist/security.d.ts} +5 -128
- package/{src/cloud/storage.ts → dist/storage.d.ts} +7 -15
- package/dist/types.d.ts +26 -25
- package/package.json +30 -32
- package/dist/cloud/ai.d.ts +0 -6
- package/dist/cloud/cache.d.ts +0 -0
- package/dist/cloud/cdn.d.ts +0 -34
- package/dist/cloud/cli.d.ts +0 -6
- package/dist/cloud/compute.d.ts +0 -17
- package/dist/cloud/dashboard.d.ts +0 -0
- package/dist/cloud/database.d.ts +0 -11
- package/dist/cloud/deployment.d.ts +0 -17
- package/dist/cloud/dns.d.ts +0 -7
- package/dist/cloud/docs.d.ts +0 -8
- package/dist/cloud/email.d.ts +0 -10
- package/dist/cloud/file-system.d.ts +0 -12
- package/dist/cloud/index.d.ts +0 -42
- package/dist/cloud/jump-box.d.ts +0 -12
- package/dist/cloud/network.d.ts +0 -8
- package/dist/cloud/permissions.d.ts +0 -6
- package/dist/cloud/queue.d.ts +0 -22
- package/dist/cloud/redirects.d.ts +0 -8
- package/dist/cloud/search-engine.d.ts +0 -0
- package/dist/cloud/security.d.ts +0 -15
- package/dist/cloud/storage.d.ts +0 -21
- package/dist/edge/origin-request.d.ts +0 -1
- package/dist/index.js.map +0 -1867
- package/src/cloud/cache.ts +0 -0
- package/src/cloud/cli.ts +0 -14
- package/src/cloud/dashboard.ts +0 -85
- package/src/cloud/docs.ts +0 -50
- package/src/cloud/index.ts +0 -141
- package/src/cloud/router-layer/nodejs/package.json +0 -15
- package/src/cloud/search-engine.ts +0 -108
- package/src/edge/origin-request.ts +0 -55
- package/src/helpers.ts +0 -800
- package/src/index.ts +0 -2
- package/src/types.ts +0 -28
package/src/cloud/cache.ts
DELETED
|
File without changes
|
package/src/cloud/cli.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import type { Construct } from 'constructs'
|
|
2
|
-
import type { NestedCloudProps } from '../types'
|
|
3
|
-
import { CfnOutput as Output } from 'aws-cdk-lib'
|
|
4
|
-
|
|
5
|
-
export interface CliStackProps extends NestedCloudProps {}
|
|
6
|
-
|
|
7
|
-
export class CliStack {
|
|
8
|
-
constructor(scope: Construct, props: CliStackProps) {
|
|
9
|
-
new Output(scope, 'CliSetupUrl', {
|
|
10
|
-
value: `https://api.${props.domain}/install`,
|
|
11
|
-
description: 'URL to trigger the CLI setup function',
|
|
12
|
-
})
|
|
13
|
-
}
|
|
14
|
-
}
|
package/src/cloud/dashboard.ts
DELETED
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
// // TODO: finish this cloudwatch dashboard
|
|
2
|
-
// // import type { aws_lambda as lambda } from 'aws-cdk-lib'
|
|
3
|
-
// import { Aws, CfnOutput as Output, aws_cloudwatch as cloudwatch } from 'aws-cdk-lib'
|
|
4
|
-
// import type { Construct } from 'constructs'
|
|
5
|
-
// import type { NestedCloudProps } from '../types'
|
|
6
|
-
//
|
|
7
|
-
// export interface DashboardStackProps extends NestedCloudProps {
|
|
8
|
-
// dashboardName?: string
|
|
9
|
-
// }
|
|
10
|
-
//
|
|
11
|
-
// export class DashboardStack {
|
|
12
|
-
// // lambdaFunction: lambda.Function
|
|
13
|
-
// dashboard: cloudwatch.Dashboard
|
|
14
|
-
//
|
|
15
|
-
// constructor(scope: Construct, props: DashboardStackProps) {
|
|
16
|
-
// const dashboardName = props.dashboardName || 'StacksDashboard'
|
|
17
|
-
//
|
|
18
|
-
// // Create Sample Lambda Function which will create metrics
|
|
19
|
-
// // this.lambdaFunction = new Function(this, 'SampleLambda', {
|
|
20
|
-
// // handler: 'lambda-handler.handler',
|
|
21
|
-
// // runtime: Runtime.PYTHON_3_7,
|
|
22
|
-
// // code: new AssetCode(`./lambda`),
|
|
23
|
-
// // memorySize: 512,
|
|
24
|
-
// // timeout: Duration.seconds(10),
|
|
25
|
-
// // })
|
|
26
|
-
//
|
|
27
|
-
// // Create CloudWatch Dashboard
|
|
28
|
-
// this.dashboard = new cloudwatch.Dashboard(scope, 'SampleLambdaDashboard', {
|
|
29
|
-
// dashboardName,
|
|
30
|
-
// })
|
|
31
|
-
//
|
|
32
|
-
// // Create Title for Dashboard
|
|
33
|
-
// this.dashboard.addWidgets(new cloudwatch.TextWidget({
|
|
34
|
-
// markdown: `# Dashboard: `,
|
|
35
|
-
// // markdown: `# Dashboard: ${this.lambdaFunction.functionName}`,
|
|
36
|
-
// height: 1,
|
|
37
|
-
// width: 24,
|
|
38
|
-
// }))
|
|
39
|
-
//
|
|
40
|
-
// // Create CloudWatch Dashboard Widgets: Errors, Invocations, Duration, Throttles
|
|
41
|
-
// this.dashboard.addWidgets(new cloudwatch.GraphWidget({
|
|
42
|
-
// title: 'Invocations',
|
|
43
|
-
// left: [this.lambdaFunction.metricInvocations()],
|
|
44
|
-
// width: 24,
|
|
45
|
-
// }))
|
|
46
|
-
//
|
|
47
|
-
// this.dashboard.addWidgets(new cloudwatch.GraphWidget({
|
|
48
|
-
// title: 'Errors',
|
|
49
|
-
// left: [this.lambdaFunction.metricErrors()],
|
|
50
|
-
// width: 24,
|
|
51
|
-
// }))
|
|
52
|
-
//
|
|
53
|
-
// this.dashboard.addWidgets(new cloudwatch.GraphWidget({
|
|
54
|
-
// title: 'Duration',
|
|
55
|
-
// left: [this.lambdaFunction.metricDuration()],
|
|
56
|
-
// width: 24,
|
|
57
|
-
// }))
|
|
58
|
-
//
|
|
59
|
-
// this.dashboard.addWidgets(new cloudwatch.GraphWidget({
|
|
60
|
-
// title: 'Throttles',
|
|
61
|
-
// left: [this.lambdaFunction.metricThrottles()],
|
|
62
|
-
// width: 24,
|
|
63
|
-
// }))
|
|
64
|
-
//
|
|
65
|
-
// // Create Widget to show last 20 Log Entries
|
|
66
|
-
// this.dashboard.addWidgets(new cloudwatch.LogQueryWidget({
|
|
67
|
-
// logGroupNames: [this.lambdaFunction.logGroup.logGroupName],
|
|
68
|
-
// queryLines: [
|
|
69
|
-
// 'fields @timestamp, @message',
|
|
70
|
-
// 'sort @timestamp desc',
|
|
71
|
-
// 'limit 20',
|
|
72
|
-
// ],
|
|
73
|
-
// width: 24,
|
|
74
|
-
// }))
|
|
75
|
-
//
|
|
76
|
-
// // Generate Output
|
|
77
|
-
// const cloudwatchDashboardURL = `https://${Aws.REGION}.console.aws.amazon.com/cloudwatch/home?region=${Aws.REGION}#dashboards:name=${dashboardName}`
|
|
78
|
-
//
|
|
79
|
-
// new Output(scope, 'DashboardOutput', {
|
|
80
|
-
// value: cloudwatchDashboardURL,
|
|
81
|
-
// description: 'The CloudWatch Dashboard URL',
|
|
82
|
-
// exportName: 'StacksDashboardURL',
|
|
83
|
-
// })
|
|
84
|
-
// }
|
|
85
|
-
// }
|
package/src/cloud/docs.ts
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import type { CfnResource } from 'aws-cdk-lib'
|
|
2
|
-
import type { Construct } from 'constructs'
|
|
3
|
-
import type { NestedCloudProps } from '../types'
|
|
4
|
-
import { config } from '@stacksjs/config'
|
|
5
|
-
import { path as p } from '@stacksjs/path'
|
|
6
|
-
import { storage } from '@stacksjs/storage'
|
|
7
|
-
import { originRequestFunctionHash } from '@stacksjs/utils'
|
|
8
|
-
import { AssetHashType, aws_lambda as lambda, CfnOutput as Output, RemovalPolicy } from 'aws-cdk-lib'
|
|
9
|
-
|
|
10
|
-
export interface DocsStackProps extends NestedCloudProps {
|
|
11
|
-
//
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export class DocsStack {
|
|
15
|
-
originRequestFunction: lambda.Function
|
|
16
|
-
|
|
17
|
-
constructor(scope: Construct, props: DocsStackProps) {
|
|
18
|
-
// if docsPrefix is not set, then we know we are in docsMode and the documentation lives at the root of the domain
|
|
19
|
-
const docsPrefix = 'docs'
|
|
20
|
-
|
|
21
|
-
// this edge function ensures pretty docs urls
|
|
22
|
-
// soon to be reused for our Meema features
|
|
23
|
-
this.originRequestFunction = new lambda.Function(scope, 'OriginRequestFunction', {
|
|
24
|
-
// this needs to have timestamp to ensure uniqueness. Since Origin Request (Lambda@Edge) functions are replicated functions, the
|
|
25
|
-
// deletion process takes a "long time". This way, the function is always unique in cases of quick recreations.
|
|
26
|
-
functionName: `${props.slug}-${props.appEnv}-origin-request-${props.timestamp}`,
|
|
27
|
-
description: 'The Stacks Origin Request function that prettifies URLs by removing the .html extension',
|
|
28
|
-
runtime: lambda.Runtime.NODEJS_20_X,
|
|
29
|
-
handler: 'dist/origin-request.handler',
|
|
30
|
-
code: lambda.Code.fromAsset(p.cloudPath('dist.zip'), {
|
|
31
|
-
assetHash: originRequestFunctionHash(),
|
|
32
|
-
assetHashType: AssetHashType.CUSTOM,
|
|
33
|
-
}),
|
|
34
|
-
})
|
|
35
|
-
|
|
36
|
-
// applying this is a workaround for failing deployments due to the following DELETE_FAILED error:
|
|
37
|
-
// > Resource handler returned message: "Lambda was unable to delete arn:aws:lambda:us-east-1:92330274019:function:stacks-cloud-production-OriginRequestFunction4FA39-XQadJcSWY8Lz:1 because it is a replicated function. Please see our documentation for Deleting Lambda@Edge Functions and Replicas. (Service: Lambda, Status Code: 400, Request ID: 83bd3112-aaa4-4980-bfcf-3ee2052a0435)" (RequestToken: c91aed31-1a62-9425-c25d-4fc0fccfa45f, HandlerErrorCode: InvalidRequest)
|
|
38
|
-
// if we do not delete this resource, then it circumvents trying to delete the function and the deployment succeeds
|
|
39
|
-
// buddy cloud:cleanup is what will be suggested running after user ensured no more sensitive data is in the buckets
|
|
40
|
-
const cfnOriginRequestFunction = this.originRequestFunction.node.defaultChild as CfnResource
|
|
41
|
-
cfnOriginRequestFunction.applyRemovalPolicy(RemovalPolicy.RETAIN)
|
|
42
|
-
|
|
43
|
-
if (!config.app.docMode && storage.hasFiles(p.projectPath('docs'))) {
|
|
44
|
-
new Output(scope, 'DocsUrl', {
|
|
45
|
-
value: `https://${docsPrefix}.${props.domain}`,
|
|
46
|
-
description: 'The URL of the deployed documentation',
|
|
47
|
-
})
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
}
|
package/src/cloud/index.ts
DELETED
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
import type { Construct } from 'constructs'
|
|
2
|
-
import type { CloudOptions } from '../types'
|
|
3
|
-
import { config } from '@stacksjs/config'
|
|
4
|
-
import { Stack } from 'aws-cdk-lib'
|
|
5
|
-
import { AiStack } from './ai'
|
|
6
|
-
import { CdnStack } from './cdn'
|
|
7
|
-
import { CliStack } from './cli'
|
|
8
|
-
import { ComputeStack } from './compute'
|
|
9
|
-
import { DeploymentStack } from './deployment'
|
|
10
|
-
import { DnsStack } from './dns'
|
|
11
|
-
import { DocsStack } from './docs'
|
|
12
|
-
import { EmailStack } from './email'
|
|
13
|
-
import { FileSystemStack } from './file-system'
|
|
14
|
-
import { JumpBoxStack } from './jump-box'
|
|
15
|
-
import { NetworkStack } from './network'
|
|
16
|
-
import { PermissionsStack } from './permissions'
|
|
17
|
-
import { QueueStack } from './queue'
|
|
18
|
-
import { RedirectsStack } from './redirects'
|
|
19
|
-
import { SecurityStack } from './security'
|
|
20
|
-
import { StorageStack } from './storage'
|
|
21
|
-
|
|
22
|
-
// import { DashboardStack } from './dashboard'
|
|
23
|
-
|
|
24
|
-
export class Cloud extends Stack {
|
|
25
|
-
dns: DnsStack
|
|
26
|
-
security: SecurityStack
|
|
27
|
-
storage: StorageStack
|
|
28
|
-
network: NetworkStack
|
|
29
|
-
fileSystem: FileSystemStack
|
|
30
|
-
jumpBox: JumpBoxStack
|
|
31
|
-
docs: DocsStack
|
|
32
|
-
email: EmailStack
|
|
33
|
-
redirects: RedirectsStack
|
|
34
|
-
permissions: PermissionsStack
|
|
35
|
-
ai: AiStack
|
|
36
|
-
cli: CliStack
|
|
37
|
-
api?: ComputeStack
|
|
38
|
-
cdn!: CdnStack
|
|
39
|
-
queue?: QueueStack
|
|
40
|
-
deployment!: DeploymentStack
|
|
41
|
-
scope: Construct
|
|
42
|
-
props: CloudOptions
|
|
43
|
-
|
|
44
|
-
constructor(scope: Construct, id: string, props: CloudOptions) {
|
|
45
|
-
super(scope, id, props)
|
|
46
|
-
this.scope = scope
|
|
47
|
-
this.props = props
|
|
48
|
-
|
|
49
|
-
// please beware: be careful changing the order of the stack creations below
|
|
50
|
-
this.dns = new DnsStack(this, props)
|
|
51
|
-
this.security = new SecurityStack(this, {
|
|
52
|
-
...props,
|
|
53
|
-
zone: this.dns.zone,
|
|
54
|
-
})
|
|
55
|
-
|
|
56
|
-
this.storage = new StorageStack(this, {
|
|
57
|
-
...props,
|
|
58
|
-
kmsKey: this.security.kmsKey,
|
|
59
|
-
originAccessIdentity: this.security.originAccessIdentity,
|
|
60
|
-
})
|
|
61
|
-
|
|
62
|
-
this.network = new NetworkStack(this, props)
|
|
63
|
-
|
|
64
|
-
this.fileSystem = new FileSystemStack(this, {
|
|
65
|
-
...props,
|
|
66
|
-
vpc: this.network.vpc,
|
|
67
|
-
})
|
|
68
|
-
|
|
69
|
-
this.jumpBox = new JumpBoxStack(this, {
|
|
70
|
-
...props,
|
|
71
|
-
vpc: this.network.vpc,
|
|
72
|
-
fileSystem: this.fileSystem.fileSystem,
|
|
73
|
-
})
|
|
74
|
-
|
|
75
|
-
this.docs = new DocsStack(this, props)
|
|
76
|
-
|
|
77
|
-
this.email = new EmailStack(this, {
|
|
78
|
-
...props,
|
|
79
|
-
zone: this.dns.zone,
|
|
80
|
-
})
|
|
81
|
-
|
|
82
|
-
this.redirects = new RedirectsStack(this, props)
|
|
83
|
-
|
|
84
|
-
this.permissions = new PermissionsStack(this)
|
|
85
|
-
|
|
86
|
-
// new DashboardStack(this)
|
|
87
|
-
|
|
88
|
-
this.ai = new AiStack(this, props)
|
|
89
|
-
|
|
90
|
-
this.cli = new CliStack(this, props)
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
// we use an async init() method here because we need to wait for the
|
|
94
|
-
|
|
95
|
-
async init(): Promise<void> {
|
|
96
|
-
const props = this.props
|
|
97
|
-
|
|
98
|
-
if (this.shouldDeployApi()) {
|
|
99
|
-
this.api = new ComputeStack(this, {
|
|
100
|
-
...props,
|
|
101
|
-
vpc: this.network.vpc,
|
|
102
|
-
fileSystem: this.fileSystem.fileSystem,
|
|
103
|
-
zone: this.dns.zone,
|
|
104
|
-
certificate: this.security.certificate,
|
|
105
|
-
})
|
|
106
|
-
|
|
107
|
-
this.queue = new QueueStack(this, {
|
|
108
|
-
...props,
|
|
109
|
-
cluster: this.api.cluster,
|
|
110
|
-
taskDefinition: this.api.taskDefinition,
|
|
111
|
-
})
|
|
112
|
-
|
|
113
|
-
await this.queue.init()
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
this.cdn = new CdnStack(this, {
|
|
117
|
-
...props,
|
|
118
|
-
publicBucket: this.storage.publicBucket,
|
|
119
|
-
docsBucket: this.storage.docsBucket,
|
|
120
|
-
logBucket: this.storage.logBucket,
|
|
121
|
-
certificate: this.security.certificate,
|
|
122
|
-
firewall: this.security.firewall,
|
|
123
|
-
originRequestFunction: this.docs.originRequestFunction,
|
|
124
|
-
zone: this.dns.zone,
|
|
125
|
-
lb: this.api?.lb,
|
|
126
|
-
})
|
|
127
|
-
|
|
128
|
-
this.deployment = new DeploymentStack(this, {
|
|
129
|
-
...props,
|
|
130
|
-
publicBucket: this.storage.publicBucket,
|
|
131
|
-
privateBucket: this.storage.privateBucket,
|
|
132
|
-
docsBucket: this.storage.docsBucket,
|
|
133
|
-
mainDistribution: this.cdn.mainDistribution,
|
|
134
|
-
docsDistribution: this.cdn.docsDistribution,
|
|
135
|
-
})
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
shouldDeployApi(): boolean {
|
|
139
|
-
return config.cloud.api?.deploy ?? false
|
|
140
|
-
}
|
|
141
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "stacks-router-layer",
|
|
3
|
-
"version": "0.66.0",
|
|
4
|
-
"description": "",
|
|
5
|
-
"author": "",
|
|
6
|
-
"license": "MIT",
|
|
7
|
-
"keywords": [],
|
|
8
|
-
"main": "index.js",
|
|
9
|
-
"scripts": {
|
|
10
|
-
"test": "echo \"Error: no test specified\" && exit 1"
|
|
11
|
-
},
|
|
12
|
-
"dependencies": {
|
|
13
|
-
"@stacksjs/router": "^0.64.6"
|
|
14
|
-
}
|
|
15
|
-
}
|
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
// async manageSearchEngine() {
|
|
2
|
-
// const vpc = this.vpc
|
|
3
|
-
|
|
4
|
-
// // Security Group
|
|
5
|
-
// const bastionSecurityGroup = new ec2.SecurityGroup(this, 'BastionSecurityGroup', {
|
|
6
|
-
// vpc,
|
|
7
|
-
// allowAllOutbound: true,
|
|
8
|
-
// securityGroupName: `${this.appName}-${appEnv}-bastion-sg`,
|
|
9
|
-
// })
|
|
10
|
-
|
|
11
|
-
// const opensearchSecurityGroup = new ec2.SecurityGroup(this, 'OpenSearchSecurityGroup', {
|
|
12
|
-
// vpc,
|
|
13
|
-
// securityGroupName: `${this.appName}-${appEnv}-opensearch-sg`,
|
|
14
|
-
// })
|
|
15
|
-
|
|
16
|
-
// opensearchSecurityGroup.addIngressRule(bastionSecurityGroup, ec2.Port.tcp(443))
|
|
17
|
-
|
|
18
|
-
// // Service-linked role that Amazon OpenSearch Service will use
|
|
19
|
-
// const iamClient = new IAMClient({})
|
|
20
|
-
// const response = await iamClient.send(
|
|
21
|
-
// new ListRolesCommand({
|
|
22
|
-
// PathPrefix: '/aws-service-role/opensearchservice.amazonaws.com/',
|
|
23
|
-
// }),
|
|
24
|
-
// )
|
|
25
|
-
|
|
26
|
-
// // Only if the role for OpenSearch Service doesn't exist, it will be created.
|
|
27
|
-
// if (response.Roles && response.Roles?.length === 0) {
|
|
28
|
-
// new iam.CfnServiceLinkedRole(this, 'OpenSearchServiceLinkedRole', {
|
|
29
|
-
// awsServiceName: 'es.amazonaws.com',
|
|
30
|
-
// })
|
|
31
|
-
// }
|
|
32
|
-
|
|
33
|
-
// // Bastion host to access Opensearch Dashboards
|
|
34
|
-
// new ec2.BastionHostLinux(this, 'BastionHost', {
|
|
35
|
-
// vpc,
|
|
36
|
-
// securityGroup: bastionSecurityGroup,
|
|
37
|
-
// machineImage: ec2.MachineImage.latestAmazonLinux2023(),
|
|
38
|
-
// blockDevices: [
|
|
39
|
-
// {
|
|
40
|
-
// deviceName: '/dev/xvda',
|
|
41
|
-
// volume: ec2.BlockDeviceVolume.ebs(10, {
|
|
42
|
-
// encrypted: true,
|
|
43
|
-
// }),
|
|
44
|
-
// },
|
|
45
|
-
// ],
|
|
46
|
-
// })
|
|
47
|
-
|
|
48
|
-
// // OpenSearch domain
|
|
49
|
-
// const domain = new opensearch.Domain(this, 'OpenSearchDomain', {
|
|
50
|
-
// version: opensearch.EngineVersion.OPENSEARCH_2_9,
|
|
51
|
-
// nodeToNodeEncryption: true,
|
|
52
|
-
// enforceHttps: true,
|
|
53
|
-
// encryptionAtRest: {
|
|
54
|
-
// enabled: true,
|
|
55
|
-
// },
|
|
56
|
-
// vpc,
|
|
57
|
-
// // unsure if there are "better" ways to do this
|
|
58
|
-
// vpcSubnets: [
|
|
59
|
-
// { subnetGroupName: `${this.appName}-${appEnv}-private-subnet-1` },
|
|
60
|
-
// { subnetGroupName: `${this.appName}-${appEnv}-private-subnet-2` },
|
|
61
|
-
// ],
|
|
62
|
-
|
|
63
|
-
// capacity: {
|
|
64
|
-
// masterNodes: 2,
|
|
65
|
-
// dataNodes: 2,
|
|
66
|
-
// multiAzWithStandbyEnabled: true,
|
|
67
|
-
// },
|
|
68
|
-
// ebs: {
|
|
69
|
-
// volumeSize: 10,
|
|
70
|
-
// volumeType: ec2.EbsDeviceVolumeType.GP3, // or opensearch.EbsVolumeType.IO1
|
|
71
|
-
// },
|
|
72
|
-
// removalPolicy: RemovalPolicy.DESTROY,
|
|
73
|
-
// zoneAwareness: {
|
|
74
|
-
// enabled: true,
|
|
75
|
-
// availabilityZoneCount: 2,
|
|
76
|
-
// },
|
|
77
|
-
// securityGroups: [opensearchSecurityGroup],
|
|
78
|
-
// })
|
|
79
|
-
|
|
80
|
-
// domain.addAccessPolicies(
|
|
81
|
-
// new iam.PolicyStatement({
|
|
82
|
-
// principals: [new iam.AnyPrincipal()],
|
|
83
|
-
// actions: ['es:ESHttp*'],
|
|
84
|
-
// resources: [`${domain.domainArn}/*`],
|
|
85
|
-
// }),
|
|
86
|
-
// )
|
|
87
|
-
|
|
88
|
-
// // // Lambda
|
|
89
|
-
// // const dataIndexFunction = PythonFunction(this, 'DataIndex', {
|
|
90
|
-
// // runtime: lambda.Runtime.PYTHON_3_10,
|
|
91
|
-
// // entry: 'lambda',
|
|
92
|
-
// // vpc,
|
|
93
|
-
// // environment: {
|
|
94
|
-
// // OPENSEARCH_HOST: domain.domainEndpoint,
|
|
95
|
-
// // },
|
|
96
|
-
// // })
|
|
97
|
-
|
|
98
|
-
// // domain.connections.allowFrom(dataIndexFunction, Port.tcp(443))
|
|
99
|
-
|
|
100
|
-
// // Outputs
|
|
101
|
-
// new Output(this, 'OpenSearchDomainHost', {
|
|
102
|
-
// value: domain.domainEndpoint,
|
|
103
|
-
// })
|
|
104
|
-
|
|
105
|
-
// // new Output(this, 'IndexingFunctionName', {
|
|
106
|
-
// // value: dataIndexFunction.functionName,
|
|
107
|
-
// // })
|
|
108
|
-
// }
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
const config = {
|
|
2
|
-
suffix: '.html',
|
|
3
|
-
removeTrailingSlash: false,
|
|
4
|
-
}
|
|
5
|
-
|
|
6
|
-
const regexSuffixless = /\/[^/.]+$/ // e.g. "/some/page" but not "/", "/some/" or "/some.jpg"
|
|
7
|
-
const regexTrailingSlash = /.+\/$/ // e.g. "/some/" or "/some/page/" but not root "/"
|
|
8
|
-
|
|
9
|
-
// TODO: narrow types here
|
|
10
|
-
export function handler(event: any, context: any, callback: any): void {
|
|
11
|
-
const { request } = event.Records[0].cf
|
|
12
|
-
const { uri } = request
|
|
13
|
-
const { suffix } = config
|
|
14
|
-
|
|
15
|
-
if (uri === '/') {
|
|
16
|
-
request.uri = '/index.html'
|
|
17
|
-
callback(null, request)
|
|
18
|
-
return
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
// Append ".html" to origin request
|
|
22
|
-
if (uri.match(regexSuffixless)) {
|
|
23
|
-
request.uri = uri + suffix
|
|
24
|
-
callback(null, request)
|
|
25
|
-
return
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
// Remove trailing slash and append ".html" to origin request
|
|
29
|
-
if (uri.match(regexTrailingSlash)) {
|
|
30
|
-
request.uri = `${uri.slice(0, -1)}.html`
|
|
31
|
-
callback(null, request)
|
|
32
|
-
return
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
// Redirect (301) non-root requests ending in "/" to URI without trailing slash
|
|
36
|
-
// if (removeTrailingSlash && uri.match(/.+\/$/)) {
|
|
37
|
-
// const response = {
|
|
38
|
-
// // body: '',
|
|
39
|
-
// // bodyEncoding: 'text',
|
|
40
|
-
// headers: {
|
|
41
|
-
// location: [{
|
|
42
|
-
// key: 'Location',
|
|
43
|
-
// value: uri.slice(0, -1),
|
|
44
|
-
// }],
|
|
45
|
-
// },
|
|
46
|
-
// status: '301',
|
|
47
|
-
// statusDescription: 'Moved Permanently',
|
|
48
|
-
// }
|
|
49
|
-
// callback(null, response)
|
|
50
|
-
// return
|
|
51
|
-
// }
|
|
52
|
-
|
|
53
|
-
// If nothing matches, return request unchanged
|
|
54
|
-
callback(null, request)
|
|
55
|
-
}
|