- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
AWS API Gateway(相对)最近允许将端点配置设置为区域性而非边缘优化。我正在使用 .NET 创建无服务器 lambda 函数。
据我了解,我需要添加以下值来设置端点类型:
"EndpointConfiguration": { "Types" : [ "REGIONAL" ] }
serverless.template 是否接受这个键值对,我应该把它放在哪里?
编辑:我没有使用无服务器框架。我在 Visual Studio 2017 中使用 AWS 工具包
最佳答案
当您说您在 Visual Studio 2017 中使用 AWS 工具包时,我假设您正在使用 AWS SAM 并构建 CloudFormation 模板(正如您提到的 serverless.template
所推断的那样)。
目前 AWS SAM 不支持使用区域终端节点设置 API 网关。这是当前正在跟踪它的 GitHub issue
但是,如果您使用的是自定义域,则有一个合理的解决方法。
即使您的 API 网关是在 Endpoint 设置为 Edge Optimized 的情况下创建的,您也可以创建 Endpoint 设置为 Regional 的 AWS::ApiGateway::DomainName
资源。
下面是我如何在我的 AWS SAM 模板中实现这一点的示例(我使用 YAML 而不是 JSON,因为它更容易处理多行值)。
注意:AWS::ApiGateway::DomainName
目前不提供有关区域端点的信息,因此我包含了一个能够检索我们需要的信息的自定义资源。
MyApiGateway:
Type: 'AWS::Serverless::Api'
Properties:
StageName: 'prod'
ApiCertificate:
Type: 'AWS::CertificateManager::Certificate'
Properties:
DomainName: 'api.example.com'
DomainValidationOptions:
- DomainName: 'api.example.com'
ValidationDomain: 'example.com'
CustomResourceLambdaExecutionRole:
Type: AWS::IAM::Role
Properties:
AssumeRolePolicyDocument:
Version: '2012-10-17'
Statement:
- Action: 'sts:AssumeRole'
Effect: Allow
Principal:
Service: 'lambda.amazonaws.com'
Path: /
ManagedPolicyArns:
- 'arn:aws:iam::aws:policy/service-role/AWSLambdaBasicExecutionRole'
Policies:
- PolicyName: ApiGateway
PolicyDocument:
Version: '2012-10-17'
Statement:
- Action:
- 'apigateway:*'
Effect: Allow
Resource: '*'
DomainNameInfoCustomResourceFunction:
Type: 'AWS::Lambda::Function'
Properties:
Handler: index.handler
Role: !GetAtt CustomResourceLambdaExecutionRole.Arn
Runtime: 'nodejs6.10'
Timeout: 300
Code:
ZipFile: |
const AWS = require('aws-sdk');
const response = require('cfn-response');
exports.handler = function(event, context) {
const ApiGateway = new AWS.APIGateway();
ApiGateway.getDomainName({
domainName: event.ResourceProperties.DomainName
}, (err, data) => {
if (err != null) {
response.send(event, context, response.FAILED, undefined);
} else {
response.send(event, context, response.SUCCESS, {
DomainName: data.domainName,
RegionalDomainName: data.regionalDomainName,
RegionalHostedZoneId: data.regionalHostedZoneId,
DistributionDomainName: data.distributionDomainName,
DistributionHostedZoneId: data.distributionHostedZoneId
});
}
});
}
ApiDomainName:
Type: 'AWS::ApiGateway::DomainName'
Properties:
DomainName: 'api.example.com'
EndpointConfiguration:
Types:
- REGIONAL
RegionalCertificateArn: !Ref ApiCertificate
ApiBasePathMapping:
Type: 'AWS::ApiGateway::BasePathMapping'
DependsOn: [MyApiGatewayprodStage, ApiDomainName]
Properties:
DomainName: 'api.example.com'
RestApiId: !Ref MyApiGateway
Stage: 'prod'
ApiDomainNameInfo:
Type: 'Custom::DomainNameInfo'
DependsOn: [ApiDomainName, ApiBasePathMapping]
Properties:
ServiceToken: !GetAtt DomainNameInfoCustomResourceFunction.Arn
DomainName: !Ref ApiDomainName
ApiRecordSet:
Type: 'AWS::Route53::RecordSet'
DependsOn: [ApiDomainNameInfo]
Properties:
HostedZoneId: '0123456789' # ENTER YOUR DOMAINS HOSTED ZONE ID
Name: 'api.example.com'
ResourceRecords:
- !GetAtt ApiDomainNameInfo.RegionalDomainName
Type: CNAME
TTL: 60
关于c# - 在 AWS Lambda serverless.template 文件中设置 EndpointConfiguration,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48326029/
在我的 serverless.yml 中,我使用 serverless-tscpaths 插件来解析 tsconfig 中定义的路径,并使用 serverless-plugin-optimize 来缩
我阅读了这个文档:https://serverless.com/framework/docs/providers/google/guide/services/ users/ serverless.
使用 Serverless framework ,我希望能够从环境变量更改 AWS 区域。 provider: name: aws region: ${env:AWS_REGION} 然后,A
我想开始使用无服务器框架来管理我公司的 lambda 部署,但我们处理 PHI 的安全性非常严格。我们的合规总监和 CTO 担心将我们的 AWS key 和 secret 传递给另一家公司。 当做 s
这是我的 serverless.yml 文件中的一个片段: Resources: LogGroupInfo: Type: 'AWS::Logs::LogGroup' Propert
我正在使用 AWS Aurora serverless 设置一个新数据库,并且需要启用 binlog。我想我已经按原样遵循了文档,但无法使其正常工作。我该如何设置? 按照文档,以下是我尝试启用 bin
我不想在 serverless.yml 中手动定义服务名称,而是想从 package.json 中读取 name 最佳答案 为了实现基于 package.json 应用程序名称的动态服务名称,我利用了
我将以下内容用作自定义 serverless-dotenv-plugin 插件配置: 风俗: dotenv: 路径:.env-${opt:stage, 'local'} 但我真正想得到的是当我不提供任
我正在使用无服务器模板并且一切正常,直到突然我的所有部署开始忽略 .env文件。 我搜索了documentation它说如果我想使用 .env 文件中的环境变量,我现在必须添加 useDotenv:
我正在使用新的无服务器 TypeScript monorepo 启动一个新项目!用过 aws-nodejs-typescript模板,它给出了 serverless.ts配置文件。几周后,我现在在命令
https://serverless.com/framework/docs/providers/aws/guide/serverless.yml/ provider: stackTags:
各位 我正在尝试设置我的第一个 NestJS 应用程序。它由 AWS 上的无服务器提供支持。 我创建了一个简单的 Controller ,它有一个服务作为依赖项。当我使用 HTTP 客户端访问端点时,
AWS::Serverless::Api 和 AWS::Serverless::HttpApi 之间有什么区别? 据我了解,AWS::Serverless::HttpApi 似乎配置了 HTTP AP
我正在尝试使用 serverless.yml 替换 @vendia/serverless-express v2 示例中的默认 sam-template,以便通过无服务器部署进行部署 https://g
I am new to using serverless framework ,I wanted to create three different environments dev,Qa,pr
我希望向本地运行的无服务器框架 Node 应用程序添加状态。我遇到了官方的 DynamoDb docker 镜像,我想使用无服务器框架以及在 localhost:8000 公开的 docker 上运行
我有一个 AWS CodeBuild 项目,它尝试安装无服务器框架,但在标题中返回错误,但它说框架已成功安装。我的理解是这无法安装 snappy 模块。为什么会这样?我该如何解决? 我在 builds
无服务器是云原生的子集或属性吗?或者是另一种方式——云原生是无服务器的子集或属性吗? Nathan Aw(新加坡) 最佳答案 云原生 是一种更通用的方法来构建和运行利用云计算的应用程序。 无服务器 更
Serverless 架构演进 Serverless架构风格挑战了软件设计和软件部署基础的现状,以实现最佳开发、最优运营和最优的管理开销。虽然它继承了微服务架构MSA的基本概念,但它已被赋予了新的
前言 当您第一次接触 Serverless 的时候,有一个不那么明显的新使用方式:与传统的基于服务器的方法相比,Serverless 服务平台可以使您的应用快速水平扩展,并行处理的工作更加有效。这
我是一名优秀的程序员,十分优秀!