什么是正确的Route 53 CloudFormation配置,以将子域名别名为Elastic Beanstalk环境ELB?
我已将HostedZoneIds从Amazon Route 53 Hosted Zone ID表复制到映射:
"Beanstalk2Route53HostedZoneId" : {
"us-east-1" : { "HostedZoneId": "Z117KPS5GTRQ2G" },
"us-west-1" : { "HostedZoneId": "Z1LQECGX5PH1X" },
"us-west-2" : { "HostedZoneId": "Z38NKT9BP95V3O" },
"eu-west-1" : { "HostedZoneId": "Z2NYPWQ7DFZAZH" },
"eu-central-1" : { "HostedZoneId": "Z1FRNW7UH4DEZJ" },
"ap-northeast-1" : { "HostedZoneId": "Z1R25G3KIG2GBW" },
"ap-northeast-2" : { "HostedZoneId": "Z3JE5OI70TWKCP" },
"ap-southeast-1" : { "HostedZoneId": "Z16FZ9L249IFLT" },
"ap-southeast-2" : { "HostedZoneId": "Z2PCDNR3VC2G1N" },
"sa-east-1" : { "HostedZoneId": "Z10X7K2B4QSOFV" }
}
Run Code Online (Sandbox Code Playgroud)
我的资源有两个Beanstalk环境:
"MyBeanstalkConfig": …Run Code Online (Sandbox Code Playgroud) amazon-web-services aws-cloudformation amazon-route53 amazon-elastic-beanstalk
如何为 AWS Glue 作业实施可选参数?
我创建了一个当前具有字符串参数(ISO 8601 日期字符串)作为 ETL 作业中使用的输入的作业。我想将此参数设为可选,以便作业在未提供时使用默认值(例如,在我的情况下使用datetime.now和datetime.isoformat)。我曾尝试使用getResolvedOptions:
import sys
from awsglue.utils import getResolvedOptions
args = getResolvedOptions(sys.argv, ['ISO_8601_STRING'])
Run Code Online (Sandbox Code Playgroud)
但是,当我没有传递--ISO_8601_STRING作业参数时,我看到以下错误:
awsglue.utils.GlueArgumentError:需要参数 --ISO_8601_STRING
使用 lerna 和本地依赖项的正确方法是什么?
我在单声道存储库中配置了两个模块以使用具有本地依赖项的 lerna。我期望
$ lerna bootstrap
$ lerna run test
Run Code Online (Sandbox Code Playgroud)
足以下载所有外部依赖项,链接本地依赖项并执行并通过所有模块中的所有测试。
根据lerna bootstrap文档:
- 将所有相互依赖的 Lerna 包符号链接在一起。
因此,我希望这lerna bootstrap会在module-b/node_modules下面创建一个指向的符号链接module-a(然后将允许执行并通过测试)。
没有发生链接,这会导致测试失败:
勒纳错了!纱线运行测试在 'module-b' 中退出 1 lerna ERR!yarn run test stdout:yarn run v1.19.1 $ jest info 访问https://yarnpkg.com/en/docs/cli/run获取有关此命令的文档。
勒纳错了!纱线运行测试标准错误:失败 ./import.test.js ? 测试套件无法运行
Run Code Online (Sandbox Code Playgroud)Cannot find module 'module-a' from 'import.test.js' > 1 | const moduleA = require('module-a'); | ^ 2 | 3 | test('should import module-a', () => { 4 | moduleA(); …
如何轻松分离在同一请求中发送的JSON值?
鉴于我将JSON发布到我的服务器:
{"first":"A","second":"B"}
Run Code Online (Sandbox Code Playgroud)
如果我在Controller中实现以下方法:
@RequestMapping(value = "/path", method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE)
public void handleRequest(@RequestBody String input) {
// ...
}
Run Code Online (Sandbox Code Playgroud)
那么该input参数将构成一个包含整个JSON对象的String {"first":"A","second":"B"}.我真正想要的是两个单独的字符串(或者一个字符串和一个适合特定请求的int),只有两个值(客户端可能发送的其他键/值对应该被忽略).
如果字符串是作为请求参数而不是JSON请求体发送的,那么它很简单:
@RequestMapping(value = "/path", method = RequestMethod.POST)
public void handleRequest(@RequestParam("first") String first,
@RequestParam("second") String second) {
// ...
}
Run Code Online (Sandbox Code Playgroud)
我知道我可以创建一个简单的bean类,它可以与@RequestBody包含两者A和B使用时的注释一起使用,但它似乎是一个绕道而行,因为它们在Web应用程序中有不同的用途.
依赖关系:org.springframework:spring-web:3.1.0.RELEASE org.codehaus.jackson:jackson-mapper-asl:1.9.3
根据我看到的示例,代码断言是预期的 json cf 模板与 cdk 合成器生成的模板。
我们如何设置预期的 json cf 模板?
话虽如此,对 CDK 代码进行单元测试是否有目的?也许我在这里错过了这个想法。请务必指出。
我有一些命令在磁盘上创建一个文件.因为必须在其中创建文件的文件夹是动态的,所以我有一个catch(FileNotFoundException e).在同一个try块中,我已经有了一个catch(Exception e)块.出于某种原因,当我运行我的代码并且该文件夹尚不存在时,使用了catch(Exception e)块,而不是FileNotFoundException块.
调试器很清楚(至少对我来说),显示一个FileNotFoundException:java.io.FileNotFoundException:c:\ mydata\2F8890C2-13B9-4D65-987D-5F447FF0DDA7\filename.png(系统找不到指定的路径)
知道它为什么不进入FileNotFoundException块吗?谢谢;
码:
import java.io.FileNotFoundException;
try{
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
Rectangle screenRectangle = new Rectangle(screenSize);
Robot robot = new Robot();
BufferedImage image = robot.createScreenCapture(screenRectangle);
ImageIO.write(image, "png", new File(fileName));
}
catch (FileNotFoundException e){
// do stuff here..
return false;
}
catch(Exception e){
// do stuff here..
return = false;
}
Run Code Online (Sandbox Code Playgroud) 如何Task将AWS Step Functions中的状态输入传递给输出?
阅读AWS文档中的输入和输出处理页面后,我使用了各种组合InputPath,ResultPath和OutputPath.
州定义:
"First State": {
"Type": "Task",
"Resource": "[My Lambda ARN]",
"Next": "Second State",
"InputPath": "$.someKey",
"OutputPath": "$"
}
Run Code Online (Sandbox Code Playgroud)
输入:
{
"someKey": "someValue"
}
Run Code Online (Sandbox Code Playgroud)
预期结果
我希望输出First State(以及输入Second State)
{
"someKey": "someValue"
}
Run Code Online (Sandbox Code Playgroud)
实际结果
[empty]
Run Code Online (Sandbox Code Playgroud)
如果输入更复杂,例如
{
"firstKey": "firstValue",
"secondKey": "secondValue"
}
Run Code Online (Sandbox Code Playgroud)
我想转发所有这些而不用担心(子)路径.
我正在使用第三方库来注册 MessageListener,当发生某些事件时,它们会调用注册的侦听器 onMessage 方法
public interface MessageListener {
// third party code, it auto-scans for all MessageListeners and registers them
void onMessage(Message message);
}
public class SimpleMessageListener implements MessageListener {
public void onMessage(Message message) {
//do something non blocking
//is it possible to 'transmit' to messagePublisher
}
public Flux<Message> messagePublisher() {
// a method to which to subscribeOn
}
}
Run Code Online (Sandbox Code Playgroud)
所以我的问题是将其转变为 Flux 的最佳方法是什么
最后我希望能够做这样的事情
messagePublisher().subscribe(System.out::println);
Run Code Online (Sandbox Code Playgroud)
************** 编辑 我的第一次尝试是这样的
private List<FluxSink<Message>> handlers = new ArrayList<>();
public void onMessage(Message message) {
handlers.forEach(han …Run Code Online (Sandbox Code Playgroud) 如何在 AWS 环境中自动化 Kibana 保存对象的版本控制?
我在 AWS 上托管了一个 Elasticsearch 域,并且我已经配置了 Kibana 来可视化数据。现在,出于以下几个原因,我想对 Kibana 配置进行版本控制:
到目前为止,我发现的唯一解决方案包括几个手动步骤:
备份:
Saved Objects在 Kibana 管理控制台中选择选项卡Export Everything按钮恢复:
Index Patterns在 Kibana 管理控制台中选择选项卡Saved Objects在 Kibana 管理控制台中选择选项卡Import按钮并上传受版本控制的 .json 文件amazon-web-services elasticsearch kibana elasticsearch-6 kibana-6
如何为第三方类创建 Lombok 构建器(即我无法修改其源代码)?
我有一个无法更改的现有课程:
public class ThirdPartyPojo {
// one of many properties
private String name;
public ThirdPartyPojo() {
// default no-args constructor
}
String getName() {
return this.name;
}
void setName(String name) {
this.name = name;
}
// many more getters and setters
}
Run Code Online (Sandbox Code Playgroud)
现在我想创建一个@Builder,以便获得流畅的构建器 API 来简化ThirdPartyPojo默认值的实例化。
这是我尝试过的:
@Builder
public class ThirdPartyPojoBuilder extends ThirdPartyPojo {
@Default
private String name = "default name";
// many more default values for other properties
}
Run Code Online (Sandbox Code Playgroud)
代码编译,我可以引用构建器,例如
ThirdPartyPojo pojoWithDefaultName = …Run Code Online (Sandbox Code Playgroud)