Skip to content

Conversation

@kyle-damas
Copy link

sys.argv array needs to be incremented by 1 for each input variable. Looks like sys.argv[0] is the script name and sys.argv[1] is the region when running this command via AWS CloudShell:

python s3_inventory_file_import.py us-east-1 <account> 80aadb37-7af0-4adb-a0f3-07ce4d8e60a2.csv s3auditor-object-activity s3_inventory_file_import-2024_10_09.log

With the original code, I added a print command of the region and account and it displayed this:

[cloudshell-user@ip-10-138-169-122 ~]$ python s3_inventory_file_import.py us-east-1 <account> 80aadb37-7af0-4adb-a0f3-07ce4d8e60a2.csv s3auditor-object-activity s3_inventory_file_import-2024_10_09.log
s3_inventory_file_import.py
us-east-1
Traceback (most recent call last):
  File "/home/cloudshell-user/s3_inventory_file_import.py", line 19, in <module>
    sqs = boto3.resource('sqs', region_name=region)
  File "/home/cloudshell-user/.local/lib/python3.9/site-packages/boto3/__init__.py", line 101, in resource
    return _get_default_session().resource(*args, **kwargs)
  File "/home/cloudshell-user/.local/lib/python3.9/site-packages/boto3/session.py", line 446, in resource
    client = self.client(
  File "/home/cloudshell-user/.local/lib/python3.9/site-packages/boto3/session.py", line 299, in client
    return self._session.create_client(
  File "/home/cloudshell-user/.local/lib/python3.9/site-packages/botocore/session.py", line 924, in create_client
    region_name = self._resolve_region_name(region_name, config)
  File "/home/cloudshell-user/.local/lib/python3.9/site-packages/botocore/session.py", line 1023, in _resolve_region_name
    validate_region_name(region_name)
  File "/home/cloudshell-user/.local/lib/python3.9/site-packages/botocore/utils.py", line 1320, in validate_region_name
    raise InvalidRegionError(region_name=region_name)
botocore.exceptions.InvalidRegionError: Provided region_name 's3_inventory_file_import.py' doesn't match a supported format.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

sys.argv array needs to be incremented by 1. Looks like sys.argv[0] is the script name and sys.argv[1] is the region when running this command via AWS CloudShell:
python s3_inventory_file_import.py us-east-1 <account> 80aadb37-7af0-4adb-a0f3-07ce4d8e60a2.csv s3auditor-object-activity s3_inventory_file_import-2024_10_09.log
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant