|
| 1 | +# MongoDB Atlas Provider -- Cloud Provider Access Role with AZURE |
| 2 | +This example shows how to perform authorization for a cloud provider Azure Service Principal. |
| 3 | + |
| 4 | +## Dependencies |
| 5 | + |
| 6 | +* Terraform MongoDB Atlas Provider v1.11.0 |
| 7 | +* A MongoDB Atlas account |
| 8 | +* An AZURE account |
| 9 | + |
| 10 | + |
| 11 | +``` |
| 12 | +Terraform v1.5.2 |
| 13 | ++ provider registry.terraform.io/terraform-providers/mongodbatlas v1.11.0 |
| 14 | +``` |
| 15 | + |
| 16 | +## Usage |
| 17 | + |
| 18 | +**1\. Ensure your Azure credentials are set up.** |
| 19 | + |
| 20 | +1. Install the Azure CLI by following the steps from the [official Azure documentation](https://docs.microsoft.com/en-us/cli/azure/install-azure-cli). |
| 21 | +2. Run the command `az login` and this will take you to the default browser and perform the authentication. |
| 22 | +3. Once authenticated, it will print the user details as below: |
| 23 | + |
| 24 | +``` |
| 25 | +⇒ az login |
| 26 | +You have logged in. Now let us find all the subscriptions to which you have access... |
| 27 | +The following tenants don't contain accessible subscriptions. Use 'az login --allow-no-subscriptions' to have tenant level access. |
| 28 | +XXXXX |
| 29 | +[ |
| 30 | + { |
| 31 | + "cloudName": "AzureCloud", |
| 32 | + "homeTenantId": "XXXXX", |
| 33 | + "id": "XXXXX", |
| 34 | + "isDefault": true, |
| 35 | + "managedByTenants": [], |
| 36 | + "name": "Pay-As-You-Go", |
| 37 | + "state": "Enabled", |
| 38 | + "tenantId": "XXXXX", |
| 39 | + "user": { |
| 40 | + |
| 41 | + "type": "user" |
| 42 | + } |
| 43 | + } |
| 44 | +] |
| 45 | +``` |
| 46 | + |
| 47 | +**2\. Ensure your MongoDB Atlas credentials are set up.** |
| 48 | + |
| 49 | +This can be done using environment variables: |
| 50 | + |
| 51 | +```bash |
| 52 | +export MONGODB_ATLAS_PUBLIC_KEY="xxxx" |
| 53 | +export MONGODB_ATLAS_PRIVATE_KEY="xxxx" |
| 54 | +``` |
| 55 | + |
| 56 | +... or follow as in the `variables.tf` file and create **terraform.tfvars** file with all the variable values, ex: |
| 57 | +```terraform |
| 58 | +public_key = "<MONGODB_ATLAS_PUBLIC_KEY>" |
| 59 | +private_key = "<MONGODB_ATLAS_PRIVATE_KEY>" |
| 60 | +``` |
| 61 | + |
| 62 | +**3\. Review the Terraform plan.** |
| 63 | + |
| 64 | +Execute the below command and ensure you are happy with the plan. |
| 65 | + |
| 66 | +``` bash |
| 67 | +$ terraform plan |
| 68 | +``` |
| 69 | +This project currently supports the below deployments: |
| 70 | + |
| 71 | +- An Azure Service Principal |
| 72 | +- Confiture Atlas to use your Azure Service Principal |
| 73 | + |
| 74 | +**5\. Execute the Terraform apply.** |
| 75 | + |
| 76 | +Now execute the plan to provision the resources. |
| 77 | + |
| 78 | +``` bash |
| 79 | +$ terraform apply |
| 80 | +``` |
| 81 | + |
| 82 | +**6\. Destroy the resources.** |
| 83 | + |
| 84 | +Once you are finished your testing, ensure you destroy the resources to avoid unnecessary Atlas charges. |
| 85 | + |
| 86 | +``` bash |
| 87 | +$ terraform destroy |
| 88 | +``` |
| 89 | + |
0 commit comments