Skip to content
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

fix: define project_assignment block in mongodbatlas_project_api_key as required to avoid plugin crash #1663

Merged
merged 1 commit into from
Nov 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 2 additions & 1 deletion mongodbatlas/resource_mongodbatlas_project_api_key.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ func resourceMongoDBAtlasProjectAPIKey() *schema.Resource {
},
"project_assignment": {
Type: schema.TypeSet,
Optional: true,
Required: true,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is it useful to create/modify a test?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All tests/examples are already defining at least on project_assignment. Don't see much value in testing empty project_assignment as it is validated by schema + makes no real sense.

MinItems: 1,
Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
"project_id": {
Expand Down
2 changes: 1 addition & 1 deletion website/docs/r/project_api_key.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ resource "mongodbatlas_project_api_key" "test" {
~> **NOTE:** Project created by API Keys must belong to an existing organization.

### project_assignment
List of Project roles that the Programmatic API key needs to have. `project_assignment` attribute is optional.
List of Project roles that the Programmatic API key needs to have. At least one `project_assignment` block must be defined.

* `project_id` - (Required) Project ID to assign to Access Key
* `role_names` - (Required) List of Project roles that the Programmatic API key needs to have. Ensure you provide: at least one role and ensure all roles are valid for the Project. You must specify an array even if you are only associating a single role with the Programmatic API key. The [MongoDB Documentation](https://www.mongodb.com/docs/atlas/reference/user-roles/#project-roles) describes the valid roles that can be assigned.
Expand Down