Fix AWS dynamic cluster management service use of AWS credentials

This commit is contained in:
allegroai 2020-01-05 14:12:40 +02:00
parent d6cc2be653
commit 119ecaa2e3

View File

@ -315,12 +315,6 @@
" SpotInstanceRequestIds=[request_id]\n", " SpotInstanceRequestIds=[request_id]\n",
" )\n", " )\n",
" instance_id = response[\"SpotInstanceRequests\"][0][\"InstanceId\"]\n", " instance_id = response[\"SpotInstanceRequests\"][0][\"InstanceId\"]\n",
" instance = boto3.resource(\n",
" \"ec2\",\n",
" aws_access_key_id=CLOUD_CREDENTIALS_KEY or None,\n",
" aws_secret_access_key=CLOUD_CREDENTIALS_SECRET or None,\n",
" region_name=CLOUD_CREDENTIALS_REGION\n",
" ).Instance(instance_id)\n",
"\n", "\n",
" else:\n", " else:\n",
" # Create a new EC2 instance\n", " # Create a new EC2 instance\n",
@ -343,9 +337,13 @@
"\n", "\n",
" # Get the instance object for later use\n", " # Get the instance object for later use\n",
" instance_id = instances[\"Instances\"][0][\"InstanceId\"]\n", " instance_id = instances[\"Instances\"][0][\"InstanceId\"]\n",
" instance = boto3.resource(\"ec2\", region_name=CLOUD_CREDENTIALS_REGION).Instance(\n", "\n",
" instance_id\n", " instance = boto3.resource(\n",
" )\n", " \"ec2\",\n",
" aws_access_key_id=CLOUD_CREDENTIALS_KEY or None,\n",
" aws_secret_access_key=CLOUD_CREDENTIALS_SECRET or None,\n",
" region_name=CLOUD_CREDENTIALS_REGION\n",
" ).Instance(instance_id)\n",
"\n", "\n",
" # Wait until instance is in running state\n", " # Wait until instance is in running state\n",
" instance.wait_until_running()\n", " instance.wait_until_running()\n",