我正在尝试在单个堆栈中部署 S3 静态网站和 API 网关/lambda。
S3 静态站点中的 javascript 调用 lambda 来填充 HTML 列表,但它需要知道用于 lambda 集成的 API 网关 URL。
目前,我像这样生成了一个 RestApi ......
const handler = new lambda.Function(this, "TestHandler", {
runtime: lambda.Runtime.NODEJS_10_X,
code: lambda.Code.asset("build/test-service"),
handler: "index.handler",
environment: {
}
});
this.api = new apigateway.RestApi(this, "test-api", {
restApiName: "Test Service"
});
const getIntegration = new apigateway.LambdaIntegration(handler, {
requestTemplates: { "application/json": '{ "statusCode": "200" }' }
});
const apiUrl = this.api.url;
Run Code Online (Sandbox Code Playgroud)
但是在 cdk 部署上,apiUrl =
"https://${Token[TOKEN.39]}.execute-api.${Token[AWS::Region.4]}.${Token[AWS::URLSuffix.1]}/${Token[TOKEN.45]}/"
因此,直到静态站点需要该值之后,才会解析/生成 url。
如何计算/查找/获取 API 网关 URL 并更新 cdk …
我在elasticsearch中有一个大型文档存储,并希望检索不同的过滤器值以便在HTML下拉列表中显示.
一个例子就是这样的
[ { "name": "John Doe", "deparments": [ { "name": "Accounts" }, { "name": "Management" } ] }, { "name": "Jane Smith", "deparments": [ { "name": "IT" }, { "name": "Management" } ] } ]
下拉列表应包含一系列部门,即IT,帐户和管理.
有些人请指出我正确的方向从弹性搜索中检索一个独特的部门列表?
谢谢