gpt4 book ai didi

python - AWS CDK Python(未找到凭证)

转载 作者:行者123 更新时间:2023-12-04 04:21:24 25 4
gpt4 key购买 nike

在使用 AWS CDK 设置虚拟环境后,我尝试使用命令 CDK Bootstrap。这是我的应用程序的代码,上面的命令从中提取凭据。

#!/usr/bin/env python3

from aws_cdk import core

from hello.hello_stack import MyStack


app = core.App()
MyStack(app, "hello-cdk-1", env={'account':'IDHERE','region': 'us-east-2'})
MyStack(app, "hello-cdk-2", env={'account':'IDHERE','region': 'us-west-2'})

app.synth()

很明显我已经把accountID拿出来了。使用命令 CDK Bootstrap 时,这里是我的错误输出

 ❌  Environment aws://ACCOUNTIDHERE/us-west-2 failed bootstrapping: Error: Need to perform AWS calls for account ACCOUNTIDHERE, but no credentials found. Tried: default credentials.
at CredentialsCache.getCredentials (/usr/local/lib/node_modules/aws-cdk/lib/api/util/sdk.ts:261:11)
at CredentialsCache.get (/usr/local/lib/node_modules/aws-cdk/lib/api/util/sdk.ts:223:25)
at SDK.cloudFormation (/usr/local/lib/node_modules/aws-cdk/lib/api/util/sdk.ts:117:20)
at Object.deployStack (/usr/local/lib/node_modules/aws-cdk/lib/api/deploy-stack.ts:56:15)
at Object.bootstrapEnvironment (/usr/local/lib/node_modules/aws-cdk/lib/api/bootstrap-environment.ts:93:10)
at /usr/local/lib/node_modules/aws-cdk/bin/cdk.ts:270:24
at async Promise.all (index 1)
Need to perform AWS calls for account ACCOUNTIDHERE, but no credentials found. Tried: default credentials.

最佳答案

您是否首先运行了 aws configure?尝试 cat ~/.aws/credentials,如果您看到类似于一切正常的内容:

[default]
region = us-east-1
aws_access_key_id = *********************
aws_secret_access_key = ******************************************

或者您在 [default] 部分中没有 aws_access_key_id/aws_secret_access_key。您可以在此处阅读所有这些信息 - https://cdkworkshop.com/15-prerequisites/200-account.html (官方 CDK 研讨会)。

关于python - AWS CDK Python(未找到凭证),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59217828/

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