为什么我执行cdktf部署时出现错误?

问题描述 投票:0回答:1
我用Python编写代码来管理AWS的东西(我是初学者) 我在 cdktf 部署时遇到了这个问题:

Error: Retrieving AWS account details: validating provider credentials: retrieving caller identity from STS: operation error STS: GetCallerIdentity, https response error StatusCode: 403, RequestID: 6a476124-3d9a-4bc8-b369-6e0db1ed9636, api error InvalidClientTokenId: The security token included in the request is invalid. │ │ with provider["registry.terraform.io/hashicorp/aws"], │ on cdk.tf.json line 23, in provider.aws[0]: │ 23: } 0 Stacks deploying 1 Stack done 0 Stacks waiting Invoking Terraform CLI failed with exit code 1
我认为问题出在名为 cdk.tf.json 的文件中,更具体地说是来自这些行:

20."provider": { 21. "aws": [ 22. { 23. "region": "us-east-1" 24. } 25. ] 26.}
但我不确定,因为当我运行此代码时(我想创建一个 s3 存储桶):

import boto3 # Create an S3 resource s3 = boto3.resource('s3') # Create a bucket s3.create_bucket(Bucket='mybucket')
我明白了:

Traceback (most recent call last): File "/home/ensai/cloud computing/testbo.py", line 5, in <module> s3.create_bucket(Bucket='mybucket') File "/home/ensai/.local/share/virtualenvs/cloud_computing-FHWF7rEK/lib/python3.10/site-packages/boto3/resources/factory.py", line 581, in do_action response = action(self, *args, **kwargs) File "/home/ensai/.local/share/virtualenvs/cloud_computing-FHWF7rEK/lib/python3.10/site-packages/boto3/resources/action.py", line 88, in __call__ response = getattr(parent.meta.client, operation_name)(*args, **params) File "/home/ensai/.local/share/virtualenvs/cloud_computing-FHWF7rEK/lib/python3.10/site-packages/botocore/client.py", line 565, in _api_call return self._make_api_call(operation_name, kwargs) File "/home/ensai/.local/share/virtualenvs/cloud_computing-FHWF7rEK/lib/python3.10/site-packages/botocore/client.py", line 1021, in _make_api_call raise error_class(parsed_response, operation_name) botocore.exceptions.ClientError: An error occurred (InvalidAccessKeyId) when calling the CreateBucket operation: The AWS Access Key Id you provided does not exist in our records.
我已经尝试过 aws configure,因为我使用 aws academy,所以我必须更新我的 aws_access_key_id 和 aws_secret_access_key。
我使用环境pipenv,所以我尝试使用pipenv lock来更新Pipfile.lock。

python amazon-web-services deployment terraform-cdk
1个回答
0
投票
我解决了第一个问题(我忘记将我的令牌放入 .aws 文件夹中的凭证文件中) 对于第二个,出现另一个错误:

ClientError: An error occurred (AccessDenied) when calling the PutObject operation: Access Denied


    

© www.soinside.com 2019 - 2024. All rights reserved.