Skip to content

Commit

Permalink
docs: fix links and format for mongodbatlas secrets (#28688)
Browse files Browse the repository at this point in the history
  • Loading branch information
fairclothjm authored Oct 14, 2024
1 parent fd96ac7 commit 945d0f7
Showing 1 changed file with 29 additions and 21 deletions.
50 changes: 29 additions & 21 deletions website/content/docs/secrets/mongodbatlas.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,19 @@
layout: docs
page_title: MongoDB Atlas - Secrets Engines
description: |-
The MongoDB Atlas Secrets Engine for Vault generates MongoDB Atlas
The MongoDB Atlas secrets engine for Vault generates MongoDB Atlas
Programmatic API Keys dynamically.
---

# MongoDB atlas secrets engine

The MongoDB Atlas Secrets Engine generates Programmatic API keys. The created MongoDB Atlas secrets are
The MongoDB Atlas secrets engine generates Programmatic API keys. The created MongoDB Atlas secrets are
time-based and are automatically revoked when the Vault lease expires, unless renewed.

Vault will create a Programmatic API key for each lease that provide appropriate access to the defined MongoDB Atlas
project or organization with appropriate role(s). The MongoDB Atlas Programmatic API Key Public and
Private Keys are returned to the caller. To learn more about Programmatic API Keys visit the
[Programmatic API Keys Doc](https://docs.atlas.mongodb.com/reference/api-docs/apiKeys/).
[Programmatic API Keys Doc](https://www.mongodb.com/docs/atlas/configure-api-access/#programmatic-api-keys).

<Note>

Expand All @@ -27,37 +27,37 @@ Private Keys are returned to the caller. To learn more about Programmatic API Ke

## Setup

Most Secrets Engines must be configured in advance before they can perform their functions. These
Most secrets engines must be configured in advance before they can perform their functions. These
steps are usually completed by an operator or configuration management tool.

1. Enable the MongoDB Atlas Secrets Engine:
1. Enable the MongoDB Atlas secrets engine:

```bash
```shell-session
$ vault secrets enable mongodbatlas
Success! Enabled the mongodbatlas Secrets Engine at: mongodbatlas/
Success! Enabled the mongodbatlas secrets engine at: mongodbatlas/
```

By default, the Secrets Engine will mount at the name of the engine. To
enable the Secrets Engine at a different path, use the `-path` argument.
By default, the secrets engine will mount at the name of the engine. To
enable the secrets engine at a different path, use the `-path` argument.

1. It's necessary to generate and configure a MongoDB Atlas Programmatic API Key for your organization
or project that has sufficient permissions to allow Vault to create other Programmatic API Keys.

In order to grant Vault programmatic access to an organization or project using only the
[API](https://docs.atlas.mongodb.com/api-docs/) you need to create a MongoDB Atlas Programmatic API
[API](https://www.mongodb.com/docs/atlas/reference/api-resources-spec/v2/) you need to create a MongoDB Atlas Programmatic API
Key with the appropriate roles if you have not already done so. A Programmatic API Key consists
of a public and private key, so ensure you have both. Regarding roles, the Organization Owner and
Project Owner roles should be sufficient for most needs, however be sure to check what each role
grants in the [MongoDB Atlas Programmatic API Key User Roles documentation](https://docs.atlas.mongodb.com/reference/user-roles/).
grants in the [MongoDB Atlas Programmatic API Key User Roles documentation](https://www.mongodb.com/docs/atlas/reference/user-roles/).
It is recommended to set an IP Network Access list when creating the key.

For more detailed instructions on how to create a Programmatic API Key in the Atlas UI, including
available roles, visit the [Programmatic API Key documentation](https://docs.atlas.mongodb.com/configure-api-access/#programmatic-api-keys).
available roles, visit the [Programmatic API Key documentation](https://www.mongodb.com/docs/atlas/configure-api-access/#programmatic-api-keys).

1. Once you have a MongoDB Atlas Programmatic Key pair, as created in the previous step, Vault can now
be configured to use it with MongoDB Atlas:

```bash
```shell-session
$ vault write mongodbatlas/config \
public_key=yhltsvan \
private_key=2c130c23-e6b6-4da8-a93f-a8bf33218830
Expand All @@ -67,8 +67,12 @@ steps are usually completed by an operator or configuration management tool.
these credentials must be a superset of any policies which might be granted
on API Keys.

~> **Note:** It is highly recommended to _not_ use your MongoDB Atlas root account credentials.
Generate a dedicated Programmatic API key with appropriate roles instead.
<Note>

It is highly recommended to _not_ use your MongoDB Atlas root account credentials.
Generate a dedicated Programmatic API key with appropriate roles instead.

</Note>

## Programmatic API keys

Expand All @@ -90,10 +94,14 @@ Create a Vault role for a MongoDB Atlas Programmatic API Key by mapping appropri
organization or project designated:

- Organization API Key: Set `organization_id` argument with the appropriate
[Organization Level Roles](https://docs.atlas.mongodb.com/reference/user-roles/#organization-roles).
- Project API Key: Set `project_id` with the appropriate [Project Level Roles](https://docs.atlas.mongodb.com/reference/user-roles/#project-roles).
[Organization Level Roles](https://www.mongodb.com/docs/atlas/reference/user-roles/#organization-roles).
- Project API Key: Set `project_id` with the appropriate [Project Level Roles](https://www.mongodb.com/docs/atlas/reference/user-roles/#project-roles).

<Note>

Programmatic API keys can belong to only one Organization but can belong to one or more Projects.

~> **Note:** Programmatic API keys can belong to only one Organization but can belong to one or more Projects.
</Note>

Examples:

Expand All @@ -113,13 +121,13 @@ $ vault write mongodbatlas/roles/test \

~> **Note:** MongoDB Atlas has deprecated whitelists, and the API will be disabled in June 2021. It is replaced by a
similar access list API which is live now. If you specify CIDR blocks or IP addresses to allow, you need to run **Vault
1.6.3 or greater** to avoid interruption. See [MongoDB Atlas documentation](https://docs.atlas.mongodb.com/reference/api-docs/access-lists/)
1.6.3 or greater** to avoid interruption. See [MongoDB Atlas documentation](https://www.mongodb.com/docs/atlas/reference/api-resources-spec/v2/#tag/Project-IP-Access-List)
for further details.

Programmatic API Key access can and should be limited with a IP Network Access list. In the following example both a CIDR
block and IP address are added to the IP Network Access list for Keys generated with this Vault role:

```bash
```shell-session
$ vault write atlas/roles/test \
project_id=5cf5a45a9ccf6400e60981b6 \
roles=GROUP_CLUSTER_MANAGER \
Expand All @@ -129,7 +137,7 @@ block and IP address are added to the IP Network Access list for Keys generated

Verify the created Programmatic API Key Vault role has the added CIDR block and IP address by running:

```bash
```shell-session
$ vault read atlas/roles/test
Key Value
Expand Down

0 comments on commit 945d0f7

Please sign in to comment.