google / cloud-forensics-utils

Python library to carry out DFIR analysis on the Cloud
Apache License 2.0
453 stars 89 forks source link

AWS startvm fails if there is no default VPC #316

Closed ramo-j closed 3 years ago

ramo-j commented 3 years ago

If an account has no default VPC, there is currently no way to specify one when creating a VM. This results in an error:

$ cloudforensics aws ap-southeast-2a startvm ramojlcftest 
[2021-06-10 05:37:08,940] [tools.aws_cli       ] INFO     Starting analysis VM...
[2021-06-10 05:37:08,946] [libcloudforensics.providers.aws.forensics] INFO     No AMI provided, fetching one for Ubuntu 18.04
[2021-06-10 05:37:09,588] [libcloudforensics.providers.aws.forensics] INFO     Starting analysis VM ramojlcftest
[2021-06-10 05:37:09,990] [libcloudforensics.providers.aws.internal.ec2] ERROR    Could not create instance ramojlcftest: An error occurred (VPCIdNotSpecified) when calling the RunInstances operation: No default VPC for this user. GroupName is only supported for EC2-Classic and default VPC.
Traceback (most recent call last):
  File "/home/ramoj_google_com/.local/lib/python3.7/site-packages/libcloudforensics-20210531-py3.7.egg/libcloudforensics/providers/aws/internal/ec2.py", line 413, in GetOrCreateAnalysisVm
    instance = client.run_instances(**vm_args)
  File "/home/ramoj_google_com/.local/lib/python3.7/site-packages/botocore/client.py", line 357, in _api_call
    return self._make_api_call(operation_name, kwargs)
  File "/home/ramoj_google_com/.local/lib/python3.7/site-packages/botocore/client.py", line 676, in _make_api_call
    raise error_class(parsed_response, operation_name)
botocore.exceptions.ClientError: An error occurred (VPCIdNotSpecified) when calling the RunInstances operation: No default VPC for this user. GroupName is only supported for EC2-Classic and default VPC.

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/ramoj_google_com/.local/bin/cloudforensics", line 11, in <module>
    load_entry_point('libcloudforensics==20210531', 'console_scripts', 'cloudforensics')()
  File "/home/ramoj_google_com/.local/lib/python3.7/site-packages/libcloudforensics-20210531-py3.7.egg/tools/cli.py", line 422, in Main
    parsed_args.func(parsed_args)
  File "/home/ramoj_google_com/.local/lib/python3.7/site-packages/libcloudforensics-20210531-py3.7.egg/tools/aws_cli.py", line 167, in StartAnalysisVm
    dst_profile=args.dst_profile)
  File "/home/ramoj_google_com/.local/lib/python3.7/site-packages/libcloudforensics-20210531-py3.7.egg/libcloudforensics/providers/aws/forensics.py", line 279, in StartAnalysisVm
    tags=tags)
  File "/home/ramoj_google_com/.local/lib/python3.7/site-packages/libcloudforensics-20210531-py3.7.egg/libcloudforensics/providers/aws/internal/ec2.py", line 425, in GetOrCreateAnalysisVm
    __name__) from exception
libcloudforensics.errors.ResourceCreationError: Could not create instance ramojlcftest: An error occurred (VPCIdNotSpecified) when calling the RunInstances operation: No default VPC for this user. GroupName is only supported for EC2-Classic and default VPC.