gpt4 book ai didi

Node aws sdk step function client is not picking up any configuration(Node AWS SDK STEP Function客户端未获取任何配置)

转载 作者:bug小助手 更新时间:2023-10-25 18:10:58 27 4
gpt4 key购买 nike



I am trying to write some Node code to create and execute a step function, but I have a problem in the way configuration is passed into the middleware that manages requests.

我正在尝试编写一些节点代码来创建和执行STEP函数,但在将配置传递到管理请求的中间件的方式上遇到了问题。


At its simplest, I can run stepfunctions-local in docker with the defaults

在最简单的情况下,我可以运行Step函数--默认设置为docker中的本地函数


docker run -p 8083:8083 amazon/aws-stepfunctions-local

Docker Run-p 8083:8083 Amazon/AWS-Steftions-Local


which means it is now running on port 8083. If I set up a dummy profile, I can then create a state machine from the CLI with

这意味着它现在在端口8083上运行。如果我设置了一个虚拟配置文件,则可以使用以下命令从CLI创建状态机


aws stepfunctions --endpoint http://localhost:8083 create-state-machine --definition "$(cat test.json)" --name test --role-arn "arn:aws:iam::012345678901:role/DummyRole" --region eu-west-1 --profile dummy

Aws步骤函数--端点http://localhost:8083创建状态机--定义“$(cat test.json)”--名称测试--角色-arn“arn:aws:iam::012345678901:角色/哑巴角色”--区域EU-West-1--配置文件哑元


(my ~/.aws/credentials has the following entry)

(我的~/.aws/凭据有以下条目)


[dummy]
aws_access_key_id = dummy
aws_secret_access_key = dummy

If I do the equivalent from node

如果我从节点执行等效项


    sfnLocalClient = new SFNClient([{
endpoint: `http://localhost:8083`,
region: 'eu-west-1',
credentials: {
accessKeyId: 'dummy',
secretAccessKey: 'dummy',
},
}]);

stateMachine = await sfnLocalClient.send(
new CreateStateMachineCommand({
name: 'TestStateMachine',
roleArn: 'arn:aws:iam::012345678901:role/DummyRole',
definition: readFileSync('test.json', 'utf8'),
}));

It first fails due to missing region. If I set the region as an env variable it fails with no credentials provided. If I set the dummy profile as an env variable then it fails due to The security token included in the request is invalid.

它首先由于缺少区域而失败。如果我将区域设置为env变量,它将失败,并且没有提供凭据。如果我将虚拟配置文件设置为环境变量,则它会失败,因为请求中包含的安全令牌无效。


Debugging a bit, I find the requests are going to a default state machine endpoint states.eu-west-1.amazonaws.com, so it seems like again my config is being ignored. Looking into this, I find various code to pull information out of the config ready to use in a stack of middleware implementations (defined in the SFNClient constructor in @aws-sdk/client-sfn).

稍加调试后,我发现请求将发送到默认状态机端点states.eu-west-1.amazonaws.com,因此似乎又一次忽略了我的配置。对此,我发现了从配置中提取信息的各种代码,以便在一堆中间件实现中使用(在@AWS-SDK/CLIENT-SFN中的SFNClient构造函数中定义)。


I'm guessing they all have the same problem, but looking at the endpoint resolution in particular (@smithy/middleware-endpoint) the resolveEndpointConfig function tries to get configured endpoint as const { endpoint } = input; but when I look at input I see that my endpoint config is nested inside a property called o in the input hence it doesn't find it.

我猜想它们都有相同的问题,但特别是查看端点解析(@smithy/Middleware-Endpoint)时,解决方案Endpoint配置函数试图将配置的端点设置为Const{Endpoint}=Input;但是当我查看输入时,我发现我的端点配置嵌套在输入中名为o的属性中,因此找不到它。


If I tamper with the code and change it to const endpoint = 'http://localhost:8080' then it successfully creates the state machine.

如果我篡改代码并将其更改为Const Endpoint=‘http://localhost:8080’,则它成功创建了状态机。


Does anyone know if I'm hitting a bug or if I'm doing something obviously wrong? I'm more of a Java engineer so please let me know if I've left out important information in this question that I can look up and add.

有谁知道我是撞到了窃听器还是做错了什么?我更像是一个Java工程师,所以如果我在这个问题中遗漏了重要的信息,请告诉我,我可以查找并添加。


I'm specifying ^3.398.0 as the @aws-sdk/client-sfn version. I can dig into package-lock if it helps to find versions of the aws and smithy libraries.

我将^3.398.0指定为@AWS-SDK/CLIENT-SFN版本。如果有助于找到AWS和Smithy库的版本,我可以深入研究Package-lock。


UPDATE

更新


It seems that runtimeConfig.js doesn't expect a tuple of config, but the SFNClient constructor does. I don't quite get the syntax, maybe that is my problem - SFNClient code looks like

似乎runtimeConfig.js不需要配置元组,但SFNClient构造函数需要。我不太了解语法,也许这就是我的问题-SFNClient代码看起来像


constructor(...[configuration]: __CheckOptionalClientConfig<SFNClientConfig>);

@aws-sdk/client-sfn getRuntimConfig function puts together the config with

@AWS-SDK/CLIENT-SFN getRuntimConfig函数将配置与


return {

...clientSharedValues,
...config,

which seems to include the first tuple entry as an object whereas it looks like it expects to just include the properties

它似乎将第一个元组条目作为对象包含在内,而它看起来似乎只希望包含属性


更多回答
优秀答案推荐

Seems like the issue is with the IDE (Webstorm) that prompts me to include an array of Config objects. If I pass in just an object

问题似乎出在IDE(WebStorm)上,它提示我包含一组配置对象。如果我只传入一个对象


    sfnLocalClient = new SFNClient({
endpoint: `http://localhost:8083`,
region: 'eu-west-1',
credentials: {
accessKeyId: 'dummy',
secretAccessKey: 'dummy',
},
});


it gives me compilation error Argument type {endpoint: string, credentials: {accessKeyId: string, secretAccessKey: string}, region: string} is not assignable to parameter type __CheckOptionalClientConfig<SFNClientConfig>

它为我提供了编译错误参数类型{ENDPOINT:STRING,Credentials:{accesKeyID:STRING,iciAccessKey:STRING},REGION:STRING}不能分配给参数类型__CheckOptionalClientConfig


But if I just run it, it all works perfectly.

但如果我运行它,一切都很完美。


This is a new world for me - in Java, I can't run code with compilation errors!

这对我来说是一个新的世界-在Java中,我不能运行带有编译错误的代码!


更多回答

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com