Skip to content

Using the AWS command line interface

This page describes how to create a VM using Amazon's EC2 API.

Please refer to the online documentation for a full description of the AWS command line interface. Please note that this client is provided "as-is", and that the CERN Cloud team have not tested its features against the CERN Cloud service.

Installation the client software

The AWS command is installed on centrally managed Linux clusters such as lxplus8.cern.ch.

To install it on your own CentOS machine, run:

# yum install awscli -y

Obtain your EC2 access keys using the openstack client:

$ openstack ec2 credentials list
+----------------------------------+----------------------------------+--------------------------------------+----------+
| Access                           | Secret                           | Project ID                           | User ID  |
+----------------------------------+----------------------------------+--------------------------------------+----------+
| jhsd884b2234tsdftsuejsdfhtsgd932 | 90832495jsdfasdfawe5g3935ismdf89 | e4611b65-2743-4a7f-ad08-585231e32d34 | my-name  |
+----------------------------------+----------------------------------+--------------------------------------+----------+

Create the configuration file for AWS cli in your home directory ~/.aws/config with the ec2 credentials and endpoint:

[default]
aws_access_key_id = jhsd884b2234tsdftsuejsdfhtsgd932
aws_secret_access_key = 90832495jsdfasdfawe5g3935ismdf89
region = cern

Testing the credentials

$ aws --endpoint-url https://openstack.cern.ch:8772 ec2 describe-images --output table --no-verify-ssl
/usr/lib/python3.6/site-packages/urllib3/connectionpool.py:1004: InsecureRequestWarning: Unverified HTTPS request is being made. Adding certificate verification is strongly advised. See: https://urllib3.readthedocs.io/en/latest/advanced-usage.html#ssl-warnings
  InsecureRequestWarning,
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
|                                                                                                                         DescribeImages                                                                                                                          |
+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
||                                                                                                                            Images                                                                                                                             ||
|+--------------+-----------------------+---------------+-------------------------------------------------------+------------+------------------------------------------------+---------------------------------------+---------+------------------+-------------+|
|| Architecture |     CreationDate      |    ImageId    |                     ImageLocation                     | ImageType  |                     Name                       |                OwnerId                | Public  | RootDeviceType   |    State    ||
|+--------------+-----------------------+---------------+-------------------------------------------------------+------------+------------------------------------------------+---------------------------------------+---------+------------------+-------------+|
||  x86_64      |  2021-01-06T13:45:41Z |  ami-10acf1a6 |  None (CC7 - x86_64 [2021-01-06])                     |  machine   |  CC7 - x86_64 [2021-01-06]                     |  8e35e961-f888-4622-bf7d-5fe9eb8cf563 |  True   |  instance-store  |  available  ||
||  x86_64      |  2021-01-06T13:36:03Z |  ami-5f01145d |  None (C8 - x86_64 [2021-01-06])                      |  machine   |  C8 - x86_64 [2021-01-06]                      |  8e35e961-f888-4622-bf7d-5fe9eb8cf563 |  True   |  instance-store  |  available  ||
||              |  2020-04-09T14:30:28Z |  ami-8b92522a |  None (CernVM 4 - Bootloader v2020.04-1 [2020-04-09]) |  machine   |  CernVM 4 - Bootloader v2020.04-1 [2020-04-09] |  0f1e3a18-dbf0-489f-9731-ed873445789d |  True   |  instance-store  |  available  ||
||              |  2020-04-09T14:27:49Z |  ami-076c78d6 |  None (CernVM 3 - Bootloader v2020-04-1 [2020-04-09]) |  machine   |  CernVM 3 - Bootloader v2020-04-1 [2020-04-09] |  0f1e3a18-dbf0-489f-9731-ed873445789d |  True   |  instance-store  |  available  ||
||  x86_64      |  2019-04-10T13:43:12Z |  ami-3f2a8537 |  None (Windows 10 LTSC (locally managed only))        |  machine   |  Windows 10 LTSC (locally managed only)        |  7380e730-d36c-44dc-aa87-a2522ac5345d |  True   |  instance-store  |  available  ||
||  x86_64      |  2019-01-29T09:06:45Z |  ami-72cd523a |  None (Windows 2019 Standard)                         |  machine   |  Windows 2019 Standard                         |  7380e730-d36c-44dc-aa87-a2522ac5345d |  True   |  instance-store  |  available  ||
||  x86_64      |  2018-10-02T14:20:57Z |  ami-5e5da67f |  None (Windows 10 Professional)                       |  machine   |  Windows 10 Professional                       |  7380e730-d36c-44dc-aa87-a2522ac5345d |  True   |  instance-store  |  available  ||
||  x86_64      |  2018-01-23T08:49:14Z |  ami-832a2f09 |  None (Windows 2016 Standard)                         |  machine   |  Windows 2016 Standard                         |  7380e730-d36c-44dc-aa87-a2522ac5345d |  True   |  instance-store  |  available  ||
||  x86_64      |  2018-01-23T08:45:39Z |  ami-cf316b48 |  None (Windows 2012 Standard R2)                      |  machine   |  Windows 2012 Standard R2                      |  7380e730-d36c-44dc-aa87-a2522ac5345d |  True   |  instance-store  |  available  ||
|+--------------+-----------------------+---------------+-------------------------------------------------------+------------+------------------------------------------------+---------------------------------------+---------+------------------+-------------+|

Creating a VM instance

Launch instance creation with:

$ aws --endpoint-url https://openstack.cern.ch:8772 ec2 run-instances --image-id ami-10acf1a6 --count 1 --instance-type m2.small --key-name id_dsa

Last update: June 4, 2021