Why i got an error when i execute cdktf deploy?

i code in python to manage aws stuff (i'm a beginner) i got this problem when i cdktf deploy :

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

i think the problem is from the file called cdk.tf.json and more specifically from those lines :

20."provider": {
21.    "aws": [
22.        {
23.            "region": "us-east-1"
24.        }
25.    ]
26.}

but i'm not sure because when i run this code (i want to create a s3 bucket) :

import boto3
# Create an S3 resource
s3 = boto3.resource('s3')
# Create a bucket
s3.create_bucket(Bucket='mybucket')

i got this :

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.

i already tried to aws configure because i use aws academy so i must update my aws_access_key_id and my aws_secret_access_key. i use an environment pipenv so i tried pipenv lock to update Pipfile.lock.

Upvotes: 0

Views: 293

Answers (1)

i resolved the first problem (i forgot to put my token in the credential file in .aws folder) and for the second one another error appears : ClientError: An error occurred (AccessDenied) when calling the PutObject operation: Access Denied

Upvotes: 0

Related Questions