Hi I am trying to create a workspace using boto3
def awsWorkspaceCreation(event, context):
client = boto3.client('workspaces')
response = client.create_workspaces(
Workspaces=[
{
'DirectoryId': 'd-9067b1946c',
'UserName': 'hhsjhdhtest',
'BundleId': 'wsb-cys0c7ctl',
'WorkspaceProperties': {
'RunningMode': 'AUTO_STOP'
}
},
]
)
return {"status":"success"}
I am getting the below error. Now sure whats the problem
{
"errorMessage": "Could not connect to the endpoint URL: \"https://workspaces.us-east-2.amazonaws.com/\"",
"errorType": "EndpointConnectionError",
"stackTrace": [
" File \"/var/task/handler.py\", line 73, in awsWorkspaceCreation\n 'Value': 'CallCentreProvisioned'\n",
" File \"/var/task/botocore/client.py\", line 316, in _api_call\n return self._make_api_call(operation_name, kwargs)\n",
" File \"/var/task/botocore/client.py\", line 622, in _make_api_call\n operation_model, request_dict, request_context)\n",
" File \"/var/task/botocore/client.py\", line 641, in _make_request\n return self._endpoint.make_request(operation_model, request_dict)\n",
" File \"/var/task/botocore/endpoint.py\", line 102, in make_request\n return self._send_request(request_dict, operation_model)\n",
" File \"/var/task/botocore/endpoint.py\", line 137, in _send_request\n success_response, exception):\n",
" File \"/var/task/botocore/endpoint.py\", line 256, in _needs_retry\n caught_exception=caught_exception, request_dict=request_dict)\n",
" File \"/var/task/botocore/hooks.py\", line 356, in emit\n return self._emitter.emit(aliased_event_name, **kwargs)\n",
" File \"/var/task/botocore/hooks.py\", line 228, in emit\n return self._emit(event_name, kwargs)\n",
" File \"/var/task/botocore/hooks.py\", line 211, in _emit\n response = handler(**kwargs)\n",
" File \"/var/task/botocore/retryhandler.py\", line 183, in __call__\n if self._checker(attempts, response, caught_exception):\n",
" File \"/var/task/botocore/retryhandler.py\", line 251, in __call__\n caught_exception)\n",
" File \"/var/task/botocore/retryhandler.py\", line 277, in _should_retry\n return self._checker(attempt_number, response, caught_exception)\n",
" File \"/var/task/botocore/retryhandler.py\", line 317, in __call__\n caught_exception)\n",
" File \"/var/task/botocore/retryhandler.py\", line 223, in __call__\n attempt_number, caught_exception)\n",
" File \"/var/task/botocore/retryhandler.py\", line 359, in _check_caught_exception\n raise caught_exception\n",
" File \"/var/task/botocore/endpoint.py\", line 200, in _do_get_response\n http_response = self._send(request)\n",
" File \"/var/task/botocore/endpoint.py\", line 269, in _send\n return self.http_session.send(request)\n",
" File \"/var/task/botocore/httpsession.py\", line 283, in send\n raise EndpointConnectionError(endpoint_url=request.url, error=e)\n"
]
}
As the exception indicates, your code is unable to establish a connection to the Workspace's API Endpoint.
This is primarily due to your Elastic Network Interface being situated within a private subnet.
While you haven't specified where your code is running (e.g., on an EC2 instance or within a Lambda function with VPC Access), the core issue and its solutions remain consistent across all environments.
There are three potential solutions to address this: