taskcat icon indicating copy to clipboard operation
taskcat copied to clipboard

Taskcat Does Not Read Credentials From Environmental Variables

Open evanottinger opened this issue 1 year ago • 0 comments

Describe the bug Taskcat does not read credentials from environmental variables.

To Reproduce Steps to reproduce the behavior:

  1. Export AWS credentials to environmental variables.
  2. Run taskcat.
  3. Taskcat reports error: botocore.exceptions.ClientError: An error occurred (AccessDenied) when calling the ListObjectsV2 operation: Access Denied

Stack Trace:

[ERROR  ] : ClientError An error occurred (AccessDenied) when calling the ListObjectsV2 operation: Access Denied
Traceback (most recent call last):
  File "/home/evan/.local/lib/python3.10/site-packages/taskcat/_cli.py", line 46, in main
    cli.run()
  File "/home/evan/.local/lib/python3.10/site-packages/taskcat/_cli_core.py", line 316, in run
    return getattr(command(), subcommand)(**args)
  File "/home/evan/.local/lib/python3.10/site-packages/taskcat/_cli_modules/test.py", line 167, in run
    with test:
  File "/home/evan/.local/lib/python3.10/site-packages/taskcat/testing/base_test.py", line 58, in __enter__
    raise ex
  File "/home/evan/.local/lib/python3.10/site-packages/taskcat/testing/base_test.py", line 55, in __enter__
    self.run()
  File "/home/evan/.local/lib/python3.10/site-packages/taskcat/testing/_cfn_test.py", line 104, in run
    stage_in_s3(
  File "/home/evan/.local/lib/python3.10/site-packages/taskcat/_s3_stage.py", line 40, in stage_in_s3
    pool.map(func, distinct_buckets.values())
  File "/usr/lib/python3.10/multiprocessing/pool.py", line 367, in map
    return self._map_async(func, iterable, mapstar, chunksize).get()
  File "/usr/lib/python3.10/multiprocessing/pool.py", line 774, in get
    raise self._value
  File "/usr/lib/python3.10/multiprocessing/pool.py", line 125, in worker
    result = (True, func(*args, **kwds))
  File "/usr/lib/python3.10/multiprocessing/pool.py", line 48, in mapstar
    return list(map(*args))
  File "/home/evan/.local/lib/python3.10/site-packages/taskcat/_s3_stage.py", line 49, in _sync_wrap
    S3Sync(
  File "/home/evan/.local/lib/python3.10/site-packages/taskcat/_s3_sync.py", line 53, in __init__
    s3_file_list = self._get_s3_file_list(bucket, prefix)
  File "/home/evan/.local/lib/python3.10/site-packages/taskcat/_s3_sync.py", line 130, in _get_s3_file_list
    resp = self.s3_client.list_objects_v2(Bucket=bucket, Prefix=prefix)
  File "/home/evan/.local/lib/python3.10/site-packages/botocore/client.py", line 530, in _api_call
    return self._make_api_call(operation_name, kwargs)
  File "/home/evan/.local/lib/python3.10/site-packages/botocore/client.py", line 960, in _make_api_call
    raise error_class(parsed_response, operation_name)
botocore.exceptions.ClientError: An error occurred (AccessDenied) when calling the ListObjectsV2 operation: Access Denied

Expected behavior taskcat should inherit config precedence of boto3 when initializing clients.

Screenshots N/A

**Version (Please make sure you are running the latest version of taskcat)

  • Taskcat Version: 0.9.36

Note: Python Version 3.10.6

To find versions: Via taskcat: taskcat -V Via pip3: pip3 show taskcat

Note: both version should match

To update taskcat run: for docker : docker pull taskcat/taskcat for pip3: pip3 install --upgrade taskcat

Additional context Validated that both the aws-cli and boto3 within the Python3 REPL were able to execute the the commands from the stack trace. I was able to get taskcat to run properly by adding a new profile to the credentials file and placing my credentials there. This was not a necessary step for aws-cli or for boto3.

evanottinger avatar Mar 17 '23 00:03 evanottinger