Skip to content
Merged
Show file tree
Hide file tree
Changes from 6 commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
dc87d3c
DOCSP-54251 -- 1ST draft of guide for using SA auth
xargom Oct 6, 2025
4895ec4
Apply suggestions from code review
xargom Oct 7, 2025
cd61fcf
Update docs/guides/migrate-to-service-accounts-authentication-guide.md
xargom Oct 7, 2025
56b31fb
DOCSP-54251 -- Addressed feedback
xargom Oct 7, 2025
d11783d
DOCSP-54251 -- Changed typos
xargom Oct 7, 2025
c7abf1a
DOCSP-54252 -- Additional lading page changes
xargom Oct 7, 2025
72bc941
Apply suggestions from code review
xargom Oct 8, 2025
232235e
DOCSP-54251 -- Additional corrections
xargom Oct 8, 2025
e96ef48
DOCSP-54251 & DOCSP-54252 -- Added detailed auth information by source
xargom Oct 8, 2025
437a40e
DOCSP-54251 -- Added mention of 10 tokens per minute limitation
xargom Oct 8, 2025
17dc6b2
rename guide file
lantoli Oct 9, 2025
da37e85
move Programmatic access to
lantoli Oct 10, 2025
42d5b92
remove Gov as it's already in index and not relevant here
lantoli Oct 10, 2025
00ce211
restructure info in index
lantoli Oct 10, 2025
a049841
access token
lantoli Oct 10, 2025
6443863
typos
lantoli Oct 10, 2025
d12bd52
doc warning about multiple credentials
lantoli Oct 10, 2025
9b187fe
fix important box
lantoli Oct 10, 2025
268e732
DOCSP-54251 & DOCSP-54252 -- Minor style adjustments
xargom Oct 10, 2025
7033ab7
DOCSP-54251 & DOCSP-54252 -- Adjusted links to specific sections
xargom Oct 10, 2025
e759fdc
DOCSP-54251 & DOCSP-54252 -- Adjusted links to specific sections 2
xargom Oct 10, 2025
8709fc8
DOCSP-54251 & DOCSP-54252 -- Adjusted links to specific sections 3
xargom Oct 10, 2025
63b4b8b
Merge branch 'CLOUDP-334161-service-accounts-dev' into DOCSP-54251
lantoli Oct 13, 2025
c7ac17b
provider configuration page with smaller index
lantoli Oct 13, 2025
8afc210
apply feedback
lantoli Oct 13, 2025
e6b80dc
make it more consistent
lantoli Oct 13, 2025
cac838c
more concise provider config
lantoli Oct 13, 2025
8d82228
reduce url help
lantoli Oct 13, 2025
61047b1
simplify AWS Secrets Manager
lantoli Oct 13, 2025
8f21d0f
fix example
lantoli Oct 13, 2025
a347147
remove link as it doesn't work anymore
lantoli Oct 13, 2025
134b0c4
revert versioning and last sections in index
lantoli Oct 14, 2025
71b04bb
apply feedback about authentication and gov
lantoli Oct 14, 2025
94f60e8
remove best practice section
lantoli Oct 14, 2025
eb4364b
AWS SM with provider attributes
lantoli Oct 14, 2025
7e633b2
doc: DOCSP-54251 -- Minimal style edits
xargom Oct 14, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 60 additions & 0 deletions docs/guides/migrate-to-service-accounts-authentication-guide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
---
page_title: "Migration Guide: Service Accounts Authentication"
---

# Migration Guide: Service Accounts Authentication

This guide helps you migrate from Programmatic Access Key (PAK) authentication to Service
Accounts (SA) authentication and viceversa without impacting your deployment.

**Note:** For more information on SA, see [Service Accounts Overview](https://www.mongodb.com/docs/atlas/api/service-accounts-overview/)
in the MongoDB documentation.

## Procedure

To migrate from Programmatic Access Key (PAK) authentication to Service
Accounts (SA) authentication, change your provider declaration variables. You can implement
this change by either:

- Providing a client ID and secret

- Providing a valid access token

### Provide a Client ID and Secret

The following example shows the variables for PAK authentication:

```terraform
provider "mongodbatlas" {
public_key = var.mongodbatlas_public_key
private_key = var.mongodbatlas_private_key
}
```

To change to SA, declare the `client_id` and `client_secret` variables as in the following example:

```terraform
provider "mongodbatlas" {
client_id = var.mongodbatlas_client_id
client_secret = var.mongodbatlas_client_secret
}
```

### Provide a Valid Access Token

The following example shows SA authentication set up through the ``access_token`` attribute:

```terraform
provider "mongodbatlas" {
access_token = var.mongodbatlas_access_token
[is_mongodbgov_cloud = true // optional]
}
```

Consider that the access token is **valid for one hour only**.

See [Generate Service Account Token](https://www.mongodb.com/docs/atlas/api/service-accounts/generate-oauth2-token/#std-label-generate-oauth2-token-atlas) for more details on creating an SA token.

**IMPORTANT:** Currently, the MongoDB Terraform provider does not support additional Token OAuth features.

**NOTE:** You can't use ``mongodbatlas_event_trigger`` with Service Accounts as the authentication method.
31 changes: 28 additions & 3 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,9 @@ See [CHANGELOG](https://github.com/mongodb/terraform-provider-mongodbatlas/blob/
```terraform
# Configure the MongoDB Atlas Provider
provider "mongodbatlas" {
public_key = var.mongodbatlas_public_key
private_key = var.mongodbatlas_private_key
client_id = var.mongodbatlas_client_id
client_secret = var.mongodbatlas_client_secret
}
# Create the resources
```

### Provider and terraform version constraints
Expand Down Expand Up @@ -50,6 +49,32 @@ Also see [`Atlas for Government Considerations`](https://www.mongodb.com/docs/at
The MongoDB Atlas provider offers a flexible means of providing credentials for authentication.
You can use any the following methods:

### Service Accounts

Service Accounts (SA) is the preferred authentication method for the MongoDB Atlas provider.
The [MongoDB Atlas documentation](https://www.mongodb.com/docs/atlas/configure-api-access/#grant-programmatic-access-to-an-organization) contains the most up-to-date instructions for creating your organization's SA and granting the required access.

To set up SA authentication, provide your credentials as in the following example:

```terraform
provider "mongodbatlas" {
client_id = var.mongodbatlas_client_id
client_secret = var.mongodbatlas_client_secret
}
```

Alternatively, you use an access token (valid for only one hour) as in the following example:

```terraform
provider "mongodbatlas" {
access_token = var.mongodbatlas_access_token
[is_mongodbgov_cloud = true // optional]
}
```

See [Migration Guide: Service Accounts Authentication](https://registry.terraform.io/providers/mongodb/mongodbatlas/latest/docs/guides/migrate-to-service-accounts-authentication-guide) for more
details on setting up SA authentication.

### Environment Variables

You can also provide your credentials via the environment variables,
Expand Down