Skip to content
Closed
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
22 changes: 11 additions & 11 deletions examples/migrate_team_project_assignment/v2/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,20 @@ locals {
}
}

# Ignore the deprecated teams block in mongodbatlas_project
resource "mongodbatlas_project" "this" {
name = "this"
org_id = var.org_id
lifecycle {
ignore_changes = [teams]
}
}
# If you are managing your project you need to ignore the deprecated teams block in mongodbatlas_project
Copy link
Collaborator

Choose a reason for hiding this comment

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

Not sure I follow the why of this. The purpose of the example is to show how "before" a project resource was also handling teams and then "after" it uses an assignment resource.

If we remove the project resource from the configuration, what is the value for a real-world scenario? The v2 part of this example should still have the project resource in the configuration, otherwise this would be equivalent to "destroy" the project.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Fair point. I think we have two options:

  1. Close this PR
  2. Update the example to be more explicit or simply have a before/after in the readme instead of a separate v2 directory.

I think I vote for closing it

Copy link
Collaborator

Choose a reason for hiding this comment

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

I am ok to close it. But can you remind me what was the reason why we opened it?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

https://docs.google.com/document/d/1MfqGWzucnyexm0bexrVuAb73oV6WYIAvjzPnuvP0C2M/edit?disco=AAABq9eHqWo
image

tl;dr: The example is not runnable in v2 unless v1 has been run first

Copy link
Collaborator

Choose a reason for hiding this comment

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

Thanks @EspenAlbert that helps. Unless I am missing something, that is the exact journey this example wants to cover:

  1. customer is using project resource and has teams in it while using 1.x
  2. customer moves to 2.0.0 and starts seeing the deprecated message
  3. customer applies the changes like following this example.

Have you encountered an issue using this flow?

# resource "mongodbatlas_project" "this" {
# name = "this"
# org_id = var.org_id
# lifecycle {
# ignore_changes = [teams]
# }
# }

# Use the new mongodbatlas_team_project_assignment resource
resource "mongodbatlas_team_project_assignment" "this" {
for_each = local.team_map

project_id = mongodbatlas_project.this.id
project_id = var.project_id
team_id = each.key
role_names = each.value
}
Expand All @@ -32,7 +32,7 @@ resource "mongodbatlas_team_project_assignment" "this" {
import {
for_each = local.team_map
to = mongodbatlas_team_project_assignment.this[each.key]
id = "${mongodbatlas_project.this.id}/${each.key}"
id = "${var.project_id}/${each.key}"
}

# Example outputs showing team assignments in various formats
Expand All @@ -57,7 +57,7 @@ output "team_project_assignments_map" {

# Data source to read current team assignments for the project
data "mongodbatlas_team_project_assignment" "this" {
project_id = mongodbatlas_project.this.id
project_id = var.project_id
team_id = var.team_id_1 # Example for one team; repeat for others as needed
}

Expand Down
11 changes: 6 additions & 5 deletions examples/migrate_team_project_assignment/v2/variables.tf
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
variable "org_id" {
description = "The ID of the MongoDB Atlas organization"
type = string
}

variable "team_id_1" {
description = "The ID of the first team"
type = string
Expand Down Expand Up @@ -33,3 +28,9 @@ variable "private_key" {
type = string
default = ""
}

variable "project_id" {
description = "Atlas project ID"
type = string

}