我在 ACM 中有一个证书,该证书以前用于在 API 网关上拥有自定义域。正如我在这里了解到的,AWS 在内部 AWS 账户中创建一些资源,例如 ELB,这些资源将附加到证书上。
问题是:我删除了自定义域名,甚至删除了 API 网关本身,并检查了是否没有附加其他资源。我仍然无法删除证书,因为它被标记为正在使用:
Associated resources
arn:aws:elasticloadbalancing:eu-central-1:<other-account-id>:loadbalancer/app/prod-fra-1-cdtls-1-2-108/8b1...
arn:aws:elasticloadbalancing:eu-central-1:<other-account-id>:loadbalancer/app/prod-fra-1-cdtls-1-2-120/fbc...
arn:aws:elasticloadbalancing:eu-central-1:<other-account-id>:loadbalancer/app/prod-fra-1-cdtls-1-2-139/6d4...
Run Code Online (Sandbox Code Playgroud)
AWS 论坛上有很多帖子,问题大部分已得到解决,因为自定义域名实际上并未被删除,而是被隐藏,因为 API 网关之前已被删除,因此无法看到侧边栏来访问自定义域名称。这里的情况并非如此。
除了联系 AWS Support 之外,还有什么技巧可以解决此问题吗?这个问题已经存在了好几天了,所以我想它不会自行解决。
我正在使用无服务器管理应用程序的 REST API,并希望使用同一区域中的 WebSockets API 扩展此设置。一切都应该使用相同的证书,但不同的子域来处理。
起初,我创建了一个新的自定义域sls create_domain --stage=...。然后我尝试将它添加到新的 WebSockets 堆栈中,但以这个错误结束:
错误:无法为...找到 CloudFormation 资源
我在 Github 上发现 CloudFormation 现在似乎不支持它,因此 Serverless 不支持它。
所以我尝试在 UI 中手动将我的舞台附加到自定义域名:
REST API 和 HTTP API 在同一个域名上的混合只能通过 API Gateway 的 V2 DomainName 接口来完成。目前,WebSocket API 只能与其他 WebSocket API 一起附加到域名。这也必须通过 API Gateway 的 V2 DomainName 接口发生。
出现了更多混淆,因为在这种情况下它甚至不是相同的域名。新域名sockets.<DOMAIN>.com和现有域名是api.<DOMAIN>.com. 还是不同的子域落入“同一个域名”?
尽管如此,我还是尝试通过 apigatewayv2 CLI 再次创建自定义域:
aws apigatewayv2 create-domain-name --domain-name <DOMAIN> --domain-name-configurations file://domain-configuration.json --region eu-west-1
Run Code Online (Sandbox Code Playgroud)
域配置.json:
[
{
"ApiGatewayDomainName": "<DOMAIN>",
"CertificateArn": "arn:aws:acm:us-east-1:<ACCOUNT_ID>:certificate/<CERT_ID>",
"CertificateName": "<DOMAIN>",
"DomainNameStatus": "AVAILABLE",
"EndpointType": …Run Code Online (Sandbox Code Playgroud) amazon-web-services websocket aws-api-gateway serverless-framework
由于与 REST 网关相比价格大幅降低,我对 HTTP 网关感到非常兴奋,但我坚持创建不会完全破坏我的serverless.yml文件的路由。
Serverless 的 HTTP 网关文档描述了这一点来定义路由:
functions:
params:
handler: handler.params
events:
- httpApi:
method: GET
path: /get/for/any/{param}
Run Code Online (Sandbox Code Playgroud)
支持'*',但这会导致问题,OPTIONS因为这些会覆盖创建的 CORS 策略(因此 OPTIONS 请求实际上会到达应用程序,这没有任何意义,尤其是在路由通过授权者保护的情况下)。
此外,不可能定义多个方法。
# does not work
method: GET,POST,DELETE
# also not possible
method:
- GET
- POST
- DELETE
Run Code Online (Sandbox Code Playgroud)
我发现的唯一配置是分别定义所有路由:
events:
- httpApi:
path: /someApi/{proxy+}
method: GET
- httpApi:
path: /someApi/{proxy+}
method: POST
- httpApi:
path: /someApi/{proxy+}
method: DELETE
Run Code Online (Sandbox Code Playgroud)
这很好用,用户界面甚至捆绑了路由,因为它们位于相同的前缀路径上:
但是有了这个,我必须为我的所有主要资源分别定义所有 HTTP 方法,包括附加的授权方。
有没有办法把它结合起来?
我在我的构建步骤中有一个巨大的依赖项列表package.json,它完全独立于其他步骤,我只需要解析一个依赖项,但是在package.json.
这可能吗?基于的解决方案npm也很好。
我认为yarn add package-name --force可以做到这一点,因为它将确定更改,但由于还没有 node_modules,它也会首先安装所有内容。
我已经为我的路线创建了一些自定义参数装饰器,但我没有找到任何有关如何为路线本身创建装饰器的有用文档。有一些描述如何将现有方法装饰器捆绑在一起,这对我没有帮助。
我想要实现的是一些简单的范围验证。范围已在请求上下文中设置。我目前所拥有的仅基于TypeScript 装饰器,但实际上无处可去:
控制器.ts
@RequiredScope(AuthScope.OWNER)
@Get('/some-route')
async get() {
...
}
Run Code Online (Sandbox Code Playgroud)
必需范围.ts
export function RequiredScope(...scopes: string[]) {
return (target: any, propertyKey: string, descriptor: PropertyDescriptor) => {
console.log(`Validation of scopes '${scopes.join(',')}' for input '${RequestContext.getScopes().join(',')}'`)
if (!scopes.map(s => RequestContext.hasOneOfTheScopes(s)).find(valid => !valid)) {
throw new HttpException(`Missing at least one scope of '${scopes.join(',')}'`, HttpStatus.FORBIDDEN)
}
}
}
Run Code Online (Sandbox Code Playgroud)
这里的问题是我的请求上下文甚至不可用,因为我的中间件设置了我的上下文还没有启动。请求立即失败。
有人能指出我正确的方向吗?
我正在尝试获取某些 LoadBalancer 的 ARN,但我只知道 DNS 名称的前缀。
例如,aws elbv2 describe-load-balancers --query 'LoadBalancers[].DNSName[]'将打印我:
[
"services-green-********.elb.eu-central-1.amazonaws.com",
"services-blue-********.elb.eu-central-1.amazonaws.com"
]
Run Code Online (Sandbox Code Playgroud)
就像是
aws elbv2 describe-load-balancers --query "LoadBalancers[?DNSName=='services-green-*']"
Run Code Online (Sandbox Code Playgroud)
不起作用,因为不接受通配符,并且无法使用像 at ec2 命令这样的过滤器。
如何在不使用 jq 的情况下获取 ARN?