-
Notifications
You must be signed in to change notification settings - Fork 42
feat: Update Database User Resource #1543
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
cfn-resources/database-user/test/contract-testing/cfn-test-create.sh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,16 @@ | ||
| #!/usr/bin/env bash | ||
|
|
||
| # This tool generates the resources and json files in the inputs/ for `cfn test`. | ||
| set -o errexit | ||
| set -o nounset | ||
| set -o pipefail | ||
|
|
||
| projectName="cfn-test-bot-$(date +%s)-$RANDOM" | ||
|
|
||
| # create project | ||
| projectId=$(atlas projects create "${projectName}" --output=json | jq -r '.id') | ||
|
|
||
| echo "projectId: $projectId" | ||
| echo "projectName: $projectName" | ||
|
|
||
| ./test/cfn-test-create-inputs.sh "$projectName" |
15 changes: 15 additions & 0 deletions
15
cfn-resources/database-user/test/contract-testing/cfn-test-delete.sh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| #!/usr/bin/env bash | ||
|
|
||
| # This tool deletes the mongodb resources used for `cfn test` as inputs. | ||
| set -o errexit | ||
| set -o nounset | ||
| set -o pipefail | ||
|
|
||
| projectId=$(jq -r '.ProjectId' ./inputs/inputs_1_create.json) | ||
|
|
||
| # delete project | ||
| if atlas projects delete "$projectId" --force; then | ||
| echo "$projectId project deletion OK" | ||
| else | ||
| (echo "Failed cleaning project: $projectId" && exit 1) | ||
| fi |
28 changes: 28 additions & 0 deletions
28
cfn-resources/database-user/test/inputs_3_create.template.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,28 @@ | ||
| { | ||
| "Username": "DataUser3", | ||
| "Password": "MongoDB12345%", | ||
| "ProjectId": "${MONGODB_ATLAS_PROJECT_ID}", | ||
| "Profile": "${MONGODB_ATLAS_PROFILE}", | ||
| "DatabaseName": "admin", | ||
| "Description": "User with Labels to test OIDCAuthType field", | ||
| "OIDCAuthType": "NONE", | ||
| "Roles": [ | ||
| { | ||
| "RoleName": "readWrite", | ||
| "DatabaseName": "testdb", | ||
| "CollectionName": "col1" | ||
| } | ||
| ], | ||
| "Scopes": [ | ||
| { | ||
| "Type": "CLUSTER", | ||
| "Name": "testdb" | ||
| } | ||
| ], | ||
| "Labels": [ | ||
| { | ||
| "Key": "testType", | ||
| "Value": "oidc-field-validation" | ||
| } | ||
| ] | ||
| } |
31 changes: 31 additions & 0 deletions
31
cfn-resources/database-user/test/inputs_3_update.template.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,31 @@ | ||
| { | ||
| "Username": "DataUser3", | ||
| "Password": "MongoDB12345%", | ||
| "ProjectId": "${MONGODB_ATLAS_PROJECT_ID}", | ||
| "Profile": "${MONGODB_ATLAS_PROFILE}", | ||
| "DatabaseName": "admin", | ||
| "Description": "Updated user with modified Labels", | ||
| "OIDCAuthType": "NONE", | ||
| "Roles": [ | ||
| { | ||
| "RoleName": "readWriteAnyDatabase", | ||
| "DatabaseName": "admin" | ||
| } | ||
| ], | ||
| "Scopes": [ | ||
| { | ||
| "Type": "CLUSTER", | ||
| "Name": "testdb2" | ||
| } | ||
| ], | ||
| "Labels": [ | ||
| { | ||
| "Key": "testType", | ||
| "Value": "oidc-field-validation" | ||
| }, | ||
| { | ||
| "Key": "updated", | ||
| "Value": "true" | ||
| } | ||
| ] | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,87 @@ | ||
| { | ||
| "AWSTemplateFormatVersion": "2010-09-09", | ||
| "Description": "This template creates a database user with OIDC (OpenID Connect) federated authentication. OIDC authentication requires federation settings to be configured in your MongoDB Atlas organization. OIDCAuthType supports USER (individual users) and IDP_GROUP (identity provider groups).", | ||
| "Parameters": { | ||
| "ProjectId": { | ||
| "Type": "String", | ||
| "Description": "Unique 24-hexadecimal digit string that identifies your project" | ||
| }, | ||
| "Profile": { | ||
| "Type": "String", | ||
| "Description": "Secret Manager Profile that contains the Atlas Programmatic keys", | ||
| "ConstraintDescription": "", | ||
| "Default": "default" | ||
| }, | ||
| "DatabaseName": { | ||
| "Type": "String", | ||
| "Description": "Database against which the database user authenticates. For OIDC authentication, this must be $external", | ||
| "Default": "$external" | ||
| }, | ||
| "Username": { | ||
| "Type": "String", | ||
| "Description": "Username for OIDC authentication. Format: <federation_settings_id>/<username> (e.g., 6489e4f0bebcb4b0dbd8e7b3/john.doe). The federation_settings_id can be found in your Atlas organization's federation settings." | ||
| }, | ||
| "Description": { | ||
| "Type": "String", | ||
| "Description": "Description of this database user.", | ||
| "Default": "OIDC federated authentication user" | ||
| } | ||
| }, | ||
| "Mappings": {}, | ||
| "Resources": { | ||
| "OidcUser": { | ||
| "Type": "MongoDB::Atlas::DatabaseUser", | ||
| "Metadata": { | ||
| "Comment": "Remember to update the \"Roles\" field with a list of roles that you want to assign to the user. OIDC authentication requires federation settings to be configured in your Atlas organization. The username must follow the format: <federation_settings_id>/<username>. For group-based authentication, use OIDCAuthType: IDP_GROUP and format: <federation_settings_id>/<group_name>" | ||
| }, | ||
| "Properties": { | ||
| "Username": { | ||
| "Ref": "Username" | ||
| }, | ||
| "OIDCAuthType": "USER", | ||
| "ProjectId": { | ||
| "Ref": "ProjectId" | ||
| }, | ||
| "DatabaseName": { | ||
| "Ref": "DatabaseName" | ||
| }, | ||
| "Profile": { | ||
| "Ref": "Profile" | ||
| }, | ||
| "Description": { | ||
| "Ref": "Description" | ||
| }, | ||
| "Roles": [ | ||
| { | ||
| "RoleName": "readWriteAnyDatabase", | ||
| "DatabaseName": "admin" | ||
| } | ||
| ], | ||
| "Labels": [ | ||
| { | ||
| "Key": "authType", | ||
| "Value": "oidc" | ||
| }, | ||
| { | ||
| "Key": "environment", | ||
| "Value": "production" | ||
| } | ||
| ] | ||
| } | ||
| } | ||
| }, | ||
| "Outputs": { | ||
| "MongoDBOidcUsername": { | ||
| "Description": "Unique identifier for the OIDC database user", | ||
| "Value": { | ||
| "Fn::GetAtt": ["OidcUser", "UserCFNIdentifier"] | ||
| } | ||
| }, | ||
| "Username": { | ||
| "Description": "Username of the OIDC database user", | ||
| "Value": { | ||
| "Ref": "Username" | ||
| } | ||
| } | ||
| } | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good catch!