我一直在努力通过aws提供的回调url(https://******.execute-api.us-east-1.amazonaws.com/test/@connections)向连接的客户端发送响应。
在我的后端中有以下代码来发送响应,这是一种单向通信。
AwsClientBuilder.EndpointConfiguration config =
new AwsClientBuilder.EndpointConfiguration("https://*********.execute-api.us-east-1.amazonaws.com/test", "us-east-1");
AmazonApiGatewayManagementApi client = AmazonApiGatewayManagementApiClientBuilder.standard()
.withEndpointConfiguration(config).build();
PostToConnectionRequest request = new PostToConnectionRequest();
request.withConnectionId("bGYcWek5oAMCKwA=");
Charset charset = Charset.forName("UTF-8");
CharsetEncoder encoder = charset.newEncoder();
ByteBuffer buff = null;
try {
buff = encoder.encode(CharBuffer.wrap("Hello from lambda"));
} catch (CharacterCodingException e) {
log.error("Error while encoding", e);
}
request.withData(buff);
PostToConnectionResult result = client.postToConnection(request);
log.info("Result of websocket send:\n" + result);
Run Code Online (Sandbox Code Playgroud)
获取服务:AmazonApiGatewayManagementApi;状态代码:403;错误代码:InvalidSignatureException异常。
注意:我已经设置了所有内容,例如证书和 aws 访问密钥。
正如 aws 文档中提到的,我尝试过使用awscurl,它有效。我可以在 websocket 连接的客户端上看到响应。 https://docs.amazonaws.cn/en_us/apigateway/latest/developerguide/apigateway-how-to-call-websocket-api-connections.html
目前还没有专门集成 API 网关和 Codebuild 的实际指南,因此我正在研究几个并尝试适应。
我已根据本文档设置了我的角色和策略,并且已成功设置并运行了我的 CodeBuild 项目。
我已经设置了一个 POST 端点,参考CodeBuild API 文档中的操作:
我正在使用端点的测试选项卡来发送
{ "project": "my-project" }
但我得到了这个回应
{
"Output": {
"__type": "com.amazon.coral.service#UnknownOperationException",
"message": null
},
"Version": "1.0"
}
Run Code Online (Sandbox Code Playgroud)
日志
Execution log for request b0ee0d54-c1d0-11e9-9ff3-e9448aaf711c
Sun Aug 18 15:56:07 UTC 2019 : Starting execution for request: b0ee0d54-c1d0-11e9-9ff3-e9448aaf711c
Sun Aug 18 15:56:07 UTC 2019 : HTTP Method: POST, Resource Path: /vegankit/stage
Sun Aug 18 15:56:07 UTC 2019 : Method request path: {}
Sun Aug 18 15:56:07 UTC …Run Code Online (Sandbox Code Playgroud) amazon-web-services aws-api-gateway aws-codebuild api-gateway
如何设置time-outa spring cloud gateway?
routeLocatorBuilder.routes()
.route("test-api", r -> r.path("/api/**")).uri(apiLb))
.route("test-doc", r -> r.path("/doc/**")).uri(docLb));
Run Code Online (Sandbox Code Playgroud)
有没有办法只为一个人设置一个超时ROUTE- doc.
我一直在尝试跨多个 SAM 模板使用单个 APIGateway。为此,我尝试从其他 SAM 模板上的基本模板导入 RestApiId,并在 lambda 的事件部分下使用它。但 SAM 有限制说
RestApiId 必须是对同一模板中“AWS::Serverless::Api”资源的有效引用。
经过3个小时的研究,我了解到我们可以通过在基础模板中定义API网关并创建角色/策略/定义来实现它,以便允许调用所需的功能。将 Lambda 拆分为多个仅 Lambda 的 SAM 文件,但在其下不定义任何 Api 类型事件。这样,我们就可以创建彼此独立的 Lambda 和 API Gateway,并使用 Swagger/OpenAPI 进行集成并分别安排权限。
以下是推荐上述方法的有用链接。
我觉得这种方法有点复杂,如果 API 在 swagger 文件上得到更多,这可能会超出基本模板的 CFN 200 限制。如果有人建议一种更简单的方法来跨不同模板导入 apiGateway,我将不胜感激。
amazon-web-services aws-lambda aws-api-gateway api-gateway serverless-application-model
我已成功在以前版本的 NextJS 中使用页面/api 路由连接到 AWS API Gateway。我正在尝试使用新的应用程序路由器在 app/api/route 中执行相同的操作。但我无法让aws-amplify图书馆工作,即
const {Auth: ssrAuth} = withSSRContext({ req: request }); //works
const user = await ssrAuth.currentAuthenticatedUser(); //fails
Run Code Online (Sandbox Code Playgroud)
这与页面路由器配合得很好,我能够获取用户令牌以将授权者附加到 API 网关请求。
知道为什么吗?请求就在那里,我可以看到带有用户令牌的 cookie。我究竟做错了什么?
非常感谢任何反馈/提示
api-gateway aws-amplify aws-amplify-sdk-js nextjs-dynamic-routing next.js13
我正在尝试使用 API Gateway,但无法启用 apigateway.googleapis.com API。它没有显示在 中gcloud services list。我正在尝试遵循 gcp doc 的说明。https://cloud.google.com/api-gateway/docs/configure-dev-env#enabling_required_services
当尝试在 gcloud 中启用它时,它返回错误,如下所示。
gcloud services enable apigateway.googleapis.com ERROR: (gcloud.services.enable) PERMISSION_DENIED: The caller does not have permission
我无法附加角色,因为我无法找到哪个角色与 apigateway 相关。由于没有相关政策,我无法创建自定义角色。
我有什么办法可以解决这个问题吗?
我正在尝试在本地开发环境上运行大使 API 网关,以便模拟我最终在生产中得到的结果 - 不同之处在于,在生产中我的解决方案将在 Kubernetes 中运行。为此,我将 Ambassador 安装到 Docker Desktop 中,并添加所需的配置以将请求路由到我的微服务。不幸的是,它对我不起作用,我收到以下错误:
upstream connect error or disconnect/reset before headers. reset reason: connection failure
我认为这是由于映射文件中的问题造成的,如下所示:
apiVersion: ambassador/v2
kind: Mapping
name: institutions_mapping
prefix: /ins/
service: localhost:44332
Run Code Online (Sandbox Code Playgroud)
所以我基本上想做的是重写所有发送到http://{ambassador_url}/insIIS Express(通过 Visual Studio)在 port 上本地运行的服务的请求44332。
我缺少什么?
所以,我遇到了很多线索,但没有一个能解决我的问题。我正在尝试使用现有的 DEV-Stage 将 Lambda 函数部署到现有的 RestApi。我的 API 是这样构建的:
this.RestAPIDev = new gw.RestApi(this, 'StagingGatewayDev', {
restApiName: 'gateway-DEV',
deploy: true,
deployOptions: {
stageName: 'DEV',
description: 'DEV Stage',
variables: { ALIAS: 'DEV' },
}
});
Run Code Online (Sandbox Code Playgroud)
Lambda Stack 独立于其自己的存储库中,包括管道和 lambda 代码。我尝试通过添加资源和方法将这些 Lambda 函数部署到此现有网关,并假设因为我在deploy:true网关上设置,所以它将自行部署。这是 Lambda 堆栈:
const restApi = gw.RestApi.fromRestApiAttributes(this, 'RestApi', {
restApiId: props.restApiId,
rootResourceId: props.restApiRoot,
});
const authenticate = new lambda.Function(this, 'AuthenticateFunction', {
code: this.lambdaCode, // is a property
runtime: lambda.Runtime.NODEJS_12_X,
handler: 'src/api/authenticate.handler',
description: 'API: Authenticates the token',
role: <executionRole>, // is …Run Code Online (Sandbox Code Playgroud) 我使用AWS API GateWay和HTTPIntegration将请求映射到外部 API,在映射的请求标头中注入外部 API 密钥。我知道我可以根据请求或字符串提供“映射自”参数来提供 API 密钥,但我也可以从 AWS Secrets Manager 映射标头值吗?在下面的控制台示例中,我使用了原始字符串。

我有一个 HTTP API 网关,它有一个自定义域,其中包含类似映射和一条触发 Lambda 的https://api.example.com/myapi路由。POST /
问题是https://api.example.com/myapi抛出{"message": "Not Found"}并且它仅适用于尾部斜杠https://api.example.com/myapi/。
我怎样才能使它在有斜线和没有斜线的情况下都可以工作,或者在最坏的情况下只在没有斜线的情况下工作?
以下是CloudFormation供参考:
{
"Resources": {
"Webhoook6917ABA8": {
"Type": "AWS::Lambda::Function",
"Properties": {...}
},
"DomainNameEC95A6E9": {
"Type": "AWS::ApiGatewayV2::DomainName",
"Properties": {
"DomainName": "api.example.com",
"DomainNameConfigurations": [
{
"CertificateArn": "arn:***",
"EndpointType": "REGIONAL"
}
]
}
},
"ApiA2E3A7D3": {
"Type": "AWS::ApiGatewayV2::Api",
"Properties": {
"Name": "Api",
"ProtocolType": "HTTP"
}
},
"ApiDefaultStageE05BC5D1": {
"Type": "AWS::ApiGatewayV2::Stage",
"Properties": {
"ApiId": {
"Ref": "ApiA2E3A7D3"
},
"StageName": "$default",
"AutoDeploy": true
},
"DependsOn": [ …Run Code Online (Sandbox Code Playgroud) api-gateway ×10
java ×2
ambassador ×1
aws-amplify ×1
aws-cdk ×1
aws-lambda ×1
docker ×1
kubernetes ×1
next.js13 ×1
serverless-application-model ×1
spring ×1
spring-boot ×1
typescript ×1
websocket ×1