procuring_credentials.rst 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. Procuring access credentials
  2. ----------------------------
  3. To initialize a connection to a cloud and get a provider object, you will
  4. need to provide the cloud's access credentials to CloudBridge. This page
  5. will walk you through the process of procuring credentials. For more
  6. information on providing these credentials to CloudBridge, see
  7. `Providing Access Credentials <setup.html>`_.
  8. **Microsoft Azure**
  9. The page linked below from the Microsoft Documentation was used to create this
  10. section, and can be followed instead of this CloudBridge-specific documentation
  11. to procure Azure credentials for other purposes.
  12. https://docs.microsoft.com/en-us/azure/azure-resource-manager/resource-group-create-service-principal-portal
  13. In order to follow the isntructions below, one needs a Microsoft Azure
  14. account and Subscription, as well as portal access.
  15. The following section will walk you through the process of creating an
  16. application, which is required for API access, as well as help you locate
  17. all required Azure credentials for CloudBridge.
  18. Azure credentials require a `Subscription ID` which can be procured through
  19. `Subscriptions` in the Azure portal.
  20. .. figure:: captures/az-sub-1.png
  21. :alt: Azure Subscriptions 1
  22. Subscriptions can be accessed by searching, or by choosing `Subscriptions`
  23. in the `All Services` window
  24. .. figure:: captures/az-sub-2.png
  25. :alt: Azure Subscriptions 2
  26. The `Subscription ID` will be found in the list of subscriptions
  27. Another piece of credentials that already exists on any Azure account is a
  28. `Tenant ID` which will correspond to the `Active Directory ID`, which can be
  29. procured through the Azure Active Directory's `Properties`.
  30. .. figure:: captures/az-dir-1.png
  31. :alt: Azure Directory 1
  32. The `Azure Active Directory` can be access by searching, or by choosing
  33. `Azure Active Directory` in the `All Services` window. `Azure Active
  34. Directory` is also a default favorite on the sidebar
  35. .. figure:: captures/az-dir-2.png
  36. :alt: Azure Directory 2
  37. The `Directory ID` will be found in the Directory's `Properties` section
  38. In order to access the API, an application needs to be registered and a key
  39. needs to be created. After creating an application through the
  40. `App Registrations` window under the `Active Directory`, the `Application
  41. ID` of the app will correspond to the `Client ID` in CloudBridge, and the
  42. generated value of its key, will correspond to the `Secret`.
  43. .. figure:: captures/az-app-1.png
  44. :alt: Azure App 1
  45. `App Registrations` can be access by searching, or through choosing `App
  46. Registrations` under `Azure Active Directory`
  47. .. figure:: captures/az-app-2.png
  48. :alt: Azure App 2
  49. The `New Application Registration` button will allow users to create a
  50. new application
  51. .. figure:: captures/az-app-3.png
  52. :alt: Azure App 3
  53. The `Name` has to be unique within the subscription and will be used to
  54. identify the `Application` later on. The `Sign-on URL` can be any
  55. URL-looking string. It does not have to point towards anything.
  56. .. figure:: captures/az-app-4.png
  57. :alt: Azure App 4
  58. After creating the application, one must select it, after which the
  59. `Application ID` will map to the `Client ID` in CloudBridge
  60. .. figure:: captures/az-app-5.png
  61. :alt: Azure App 5
  62. In the application's `Settings` panel, under the `Keys` section, one will
  63. be able to create a new `Secret`
  64. .. figure:: captures/az-app-6.png
  65. :alt: Azure App 6
  66. Any name can be given to the key, and any expiration date, after which
  67. the `Save` button will generate the `Key` which will correspond to the
  68. `Secret` in CloudBridge
  69. .. figure:: captures/az-app-7.png
  70. :alt: Azure App 7
  71. The value of the key will correspond to the `Secret` in CloudBridge and
  72. needs to be saved at creation-time
  73. Finally, in order to have appropriate permissions, you must assign an
  74. appropriate role to the newly created application. Permissions can be
  75. assigned at the level of the Subscription, or at the level of each Resource
  76. Group. `Contributor` access is recommended for general use in order to have
  77. sufficient permissions to create and manage all types of resources, but
  78. specific roles can also be assigned for more limited access.
  79. .. figure:: captures/az-role-1.png
  80. :alt: Azure Roles 1
  81. Subscription-level access will allow the application to access resources
  82. from multiple resource groups
  83. .. figure:: captures/az-role-2.png
  84. :alt: Azure Roles 2
  85. When roles are set at the level of the Resource Group, one must specify
  86. this Resource Group as part of the credentials, as the application will
  87. not have enough permissions to create a Resource Group
  88. .. figure:: captures/az-role-3.png
  89. :alt: Azure Roles 3
  90. Adding a role assignment to the application will give it appropriate
  91. permissions to manage resources
  92. **Google**
  93. For Google Compute Engine, create a service account following instructions
  94. from the link below:
  95. https://cloud.google.com/iam/docs/creating-managing-service-accounts#creating_a_service_account
  96. Once created, grant the account appropriate permissions for your use through
  97. roles, and create a key, choosing JSON format, when prompted. These
  98. credentials can then be used with CloudBridge through the variables shown
  99. in the sections below.
  100. The JSON credentials file will have a similar form to the example shown
  101. below, and can either be passed through an absolute path to the file, or
  102. through a variable containing the JSON dictionary itself.
  103. .. code-block:: json
  104. {
  105. "type": "service_account",
  106. "project_id": "my-project",
  107. "private_key_id": "b12321312441245gerg245245g42c245g254t425",
  108. "private_key": "-----BEGIN PRIVATE KEY-----\nMIICWgIBAAKBgE1EJDPKM/2wck/CZYCS7F2cXoHXDBhXYtdeV+h70Nk+ABs6scAV\nApYoobJAVpDeL+lutYAwtbscNz5K915DiNEkBf48LhfBWc5ea07OnClOGC9zASja\nif6ujIdhbITaNat9rdG939gQWqyaDW4wzYfvurhfmxICNgZA1YpWco1HAgMBAAEC\ngYAc+vLtLelEPNsTSWGS0Qiwr8bOwl75/kTHbM5iF5ak9NlLXT9wQTEgKwtC9VjC\nq2OjFXAkLaDsFlAuICYaCBCXn1nUqNoYhaSEQNwGnWIz376letXg/mX+BALSPMFR\nhE6mbdmaL4OV1X8j8uf2VcrLfVFCCZfhPu/TM5D6bVFYoQJBAJRHNKYU/csAB/NE\nzScJBv7PltOAoYpxbyFZb1rWcV9mAn34382b0YBXbp3Giqvifs/teudUbRpAzzLm\n5gr8tzECQQCFZh4tNIzeZZYUqkQxrxgqnnONey1hX7K+BlGyC6n2o26sE+I7cLij\n2kbuWoSFMAIdM2Hextv9k+ZrwUas4V33AkAfi9Korvib0sLeP7oB3wrM9W9aShiU\nMrP4/WUSh2MRb8uB74v123vD+VYAXTgtf3+JTzYBt1WK61TpuHQizEdRAkBjt8hL\nBoNfJBUicXz0nuyzvyql0jREG+NjhRnAvFNbGSR74Yk14bdEVMC9IFD7tr190pEQ\nlRqR3eNbHWmVhgpVAkBgveeM73R1tFXS6UosBtfDI1zut44Ce0RoADOIxjXqgjOi\nXSrevYvoKCl09yhLNAnKD+QvT/YbshW/jibYXwdj\n-----END PRIVATE KEY-----",
  109. "client_email": "service-name@my-project.iam.gserviceaccount.com",
  110. "client_id": "13451345134513451345",
  111. "auth_uri": "https://accounts.google.com/o/oauth2/auth",
  112. "token_uri": "https://oauth2.googleapis.com/token",
  113. "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
  114. "client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/service-name%40my-project.iam.gserviceaccount.com"
  115. }