procuring_credentials.rst 8.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  1. Procuring access credentials
  2. ============================
  3. To initialize a connection to a cloud and get a provider object, you will need
  4. to provide the cloud's access credentials to CloudBridge. This page will walk
  5. you through the process of procuring credentials on different providers. For
  6. more information on using the obtained credentials with CloudBridge, see
  7. `Connection and Authentication Setup <setup.html>`_ page.
  8. .. _azure-creds:
  9. Microsoft Azure
  10. ---------------
  11. The page linked below from the Microsoft documentation was used to create this
  12. section, and can be followed instead of this CloudBridge-specific documentation
  13. to procure Azure credentials
  14. https://docs.microsoft.com/en-us/azure/azure-resource-manager/resource-group-create-service-principal-portal.
  15. In order to follow the instructions below, one needs a Microsoft Azure account
  16. and an active Subscription, as well as web portal access:
  17. https://portal.azure.com/ The following section will walk you through the
  18. process of creating an application, which is required for API access, as well
  19. as help you locate all required Azure credentials for API access via
  20. CloudBridge.
  21. Azure credentials require a `Subscription ID` which can be procured through
  22. `Subscriptions` in the Azure portal.
  23. .. figure:: captures/az-sub-1.png
  24. :alt: Azure Subscriptions 1
  25. Subscriptions can be accessed by searching, or by choosing `Subscriptions`
  26. in the `All Services` window
  27. .. figure:: captures/az-sub-2.png
  28. :alt: Azure Subscriptions 2
  29. The `Subscription ID` will be found in the list of subscriptions
  30. Another piece of credentials that already exists on any Azure account is a
  31. `Tenant ID` which will correspond to the `Active Directory ID`, which can be
  32. procured through the Azure Active Directory's `Properties`.
  33. .. figure:: captures/az-dir-1.png
  34. :alt: Azure Directory 1
  35. The `Azure Active Directory` can be access by searching, or by choosing
  36. `Azure Active Directory` in the `All Services` window.
  37. `Azure Active Directory` is also a default favorite on the sidebar.
  38. .. figure:: captures/az-dir-2.png
  39. :alt: Azure Directory 2
  40. The `Directory ID` will be found in the Directory's `Properties` section
  41. In order to access the API, an application needs to be registered and a key
  42. needs to be created. After creating an application through the
  43. `App Registrations` window under the `Active Directory`, the `Application ID`
  44. of the app will correspond to the `Client ID` in CloudBridge, and the
  45. generated value of its key, will correspond to the `Secret`.
  46. .. figure:: captures/az-app-1.png
  47. :alt: Azure App 1
  48. `App Registrations` can be access by searching, or through choosing
  49. `App Registrations` under `Azure Active Directory`.
  50. .. figure:: captures/az-app-2.png
  51. :alt: Azure App 2
  52. The `New Application Registration` button will allow users to create a
  53. new application
  54. .. figure:: captures/az-app-3.png
  55. :alt: Azure App 3
  56. The `Name` has to be unique within the subscription and will be used to
  57. identify the `Application` later on. The `Sign-on URL` can be any
  58. URL-looking string. It does not have to point towards anything.
  59. .. figure:: captures/az-app-4.png
  60. :alt: Azure App 4
  61. After creating the application, one must select it, after which the
  62. `Application ID` will map to the `Client ID` in CloudBridge.
  63. .. figure:: captures/az-app-5.png
  64. :alt: Azure App 5
  65. In the application's `Settings` panel, under the `Keys` section, one will
  66. be able to create a new `Secret`.
  67. .. figure:: captures/az-app-6.png
  68. :alt: Azure App 6
  69. Any name can be given to the key, and any expiration date, after which
  70. the `Save` button will generate the `Key` which will correspond to the
  71. `Secret` in CloudBridge.
  72. .. figure:: captures/az-app-7.png
  73. :alt: Azure App 7
  74. The value of the key will correspond to the `Secret` in CloudBridge and
  75. needs to be saved at creation-time.
  76. Finally, in order to have appropriate permissions, you must assign an
  77. appropriate role to the newly created application. Permissions can be
  78. assigned at the level of the Subscription, or at the level of each Resource
  79. Group. `Contributor` access is recommended for general use in order to have
  80. sufficient permissions to create and manage all types of resources, but
  81. specific roles can also be assigned for more limited access.
  82. .. figure:: captures/az-role-1.png
  83. :alt: Azure Roles 1
  84. Subscription-level access will allow the application to access resources
  85. from multiple resource groups.
  86. .. figure:: captures/az-role-2.png
  87. :alt: Azure Roles 2
  88. When roles are set at the level of the Resource Group, one must specify
  89. this Resource Group as part of the credentials, as the application will
  90. not have enough permissions to create a Resource Group.
  91. .. figure:: captures/az-role-3.png
  92. :alt: Azure Roles 3
  93. Adding a role assignment to the application will give it appropriate
  94. permissions to manage resources.
  95. .. _google-creds:
  96. Google Cloud Platform (GCP)
  97. ---------------------------
  98. For Google Cloud Platform (GCP), create a service account followed by creating
  99. and downloading a key. Additional instructions are available at this link
  100. https://cloud.google.com/iam/docs/creating-managing-service-accounts#creating_a_service_account.
  101. Start off by clicking on the `Create Service Account` button on the
  102. IAM & admin section of the Google Cloud Console:
  103. https://console.cloud.google.com/iam-admin/serviceaccounts.
  104. .. figure:: captures/gcp-sa-1.png
  105. :alt: GCP Service Account 1
  106. Next, we provide a name for the service account and an informative description.
  107. Note that the supplied name is used to create an email address for the service
  108. account. Once created, this email cannot be changed.
  109. .. figure:: captures/gcp-sa-2.png
  110. :alt: GCP Service Account 2
  111. We then assign a role to the service account. Depending on what you will be
  112. doing with the service account, and CloudBridge, you can set granular access
  113. roles for the service account. The `Editor` role on the project is very broad
  114. and will allow you to exercise all of the CloudBridge capabilities.
  115. .. figure:: captures/gcp-sa-3.png
  116. :alt: GCP Service Account 3
  117. After a service account has been created, we need to add a key to it.
  118. .. figure:: captures/gcp-sa-4.png
  119. :alt: GCP Service Account key 1
  120. Finally, choose the JSON format for the key when prompted. The file that is
  121. downloaded will be used with CloudBridge through the variables shown
  122. on the `Connection and Authentication Setup <setup.html>`_ page. Note that you
  123. may have multiple keys associated with the same service account.
  124. .. figure:: captures/gcp-sa-5.png
  125. :alt: GCP Service Account key 2
  126. The JSON credentials file will have a similar form to the example shown
  127. below, and can either be passed through an absolute path to the file, or
  128. through a variable containing the JSON dictionary itself.
  129. .. code-block:: json
  130. {
  131. "type": "service_account",
  132. "project_id": "my-project",
  133. "private_key_id": "b12321312441245gerg245245g42c245g254t425",
  134. "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-----",
  135. "client_email": "service-name@my-project.iam.gserviceaccount.com",
  136. "client_id": "13451345134513451345",
  137. "auth_uri": "https://accounts.google.com/o/oauth2/auth",
  138. "token_uri": "https://oauth2.googleapis.com/token",
  139. "auth_provider_x509_cert_url": "https://www.googleapis.com/oauth2/v1/certs",
  140. "client_x509_cert_url": "https://www.googleapis.com/robot/v1/metadata/x509/service-name%40my-project.iam.gserviceaccount.com"
  141. }
  142. To pass in the values as a properly escaped multi-line environment variable, use
  143. the following:
  144. .. code-block:: shell
  145. export GCP_SERVICE_CREDS_DICT=`cat ~/path/to/gcp-creds.json`
  146. .. Comments for documentation authors:
  147. .. When uploading pictures, process them using sips, as follows:
  148. .. sips -s format png -Z 1500 img-name.png