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

Add platform_group_members resource #187

Merged
merged 6 commits into from
Jan 3, 2025
Merged

Conversation

alexhung
Copy link
Member

@alexhung alexhung commented Jan 2, 2025

This allows independent management of users in group.

Add use_group_members_resource attribute to platform_group resource to control if members attribute is used.

Closes #169

@alexhung alexhung added the enhancement Automatically generated release notes label Jan 2, 2025
@alexhung alexhung marked this pull request as ready for review January 2, 2025 22:31
@alexhung alexhung requested a review from danielmkn as a code owner January 2, 2025 22:31
@alexhung alexhung merged commit e520a9a into main Jan 3, 2025
2 checks passed
@alexhung alexhung deleted the GH-169-add-group-member-resource branch January 3, 2025 17:01
@bakito
Copy link

bakito commented Jan 6, 2025

@alexhung Are there any plans on allowing an import of theses members?

When I add a member in Artifactory, it is not shown as diff in the terraform state.

@alexhung
Copy link
Member Author

alexhung commented Jan 6, 2025

@bakito Changes from Artifactory should reflect in Terraform state. I'll take a look.

@alexhung
Copy link
Member Author

alexhung commented Jan 6, 2025

@bakito I add an user, a group, and a group-membership resource to my local dev Artifactory:

alexh@alexh-mac terraform-provider-platform % terraform apply

Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
  + create

Terraform will perform the following actions:

  # artifactory_managed_user.test-user will be created
  + resource "artifactory_managed_user" "test-user" {
      + admin                      = false
      + disable_ui_access          = true
      + email                      = "[email protected]"
      + groups                     = (known after apply)
      + id                         = (known after apply)
      + internal_password_disabled = false
      + name                       = "test"
      + password                   = (sensitive value)
      + profile_updatable          = true
    }

  # platform_group.test-group will be created
  + resource "platform_group" "test-group" {
      + admin_privileges           = false
      + auto_join                  = true
      + description                = "Test group"
      + name                       = "test-group"
      + realm                      = (known after apply)
      + realm_attributes           = (known after apply)
      + use_group_members_resource = true
    }

  # platform_group_members.test-group will be created
  + resource "platform_group_members" "test-group" {
      + members = [
          + "admin",
          + "anonymous",
          + "test",
        ]
      + name    = "test-group"
    }

Plan: 3 to add, 0 to change, 0 to destroy.

Do you want to perform these actions?
  Terraform will perform the actions described above.
  Only 'yes' will be accepted to approve.

  Enter a value: yes

platform_group.test-group: Creating...
artifactory_managed_user.test-user: Creating...
platform_group.test-group: Creation complete after 3s [name=test-group]
artifactory_managed_user.test-user: Creation complete after 2s [id=test]
platform_group_members.test-group: Creating...
platform_group_members.test-group: Creation complete after 1s [name=test-group]

Apply complete! Resources: 3 added, 0 changed, 0 destroyed.

Then I logged into Artifactory and manually removed the anonymous user from the test-group. When I ran terraform plan, I got the following:

alexh@alexh-mac terraform-provider-platform % terraform plan
platform_group.test-group: Refreshing state... [name=test-group]
artifactory_managed_user.test-user: Refreshing state... [id=test]
platform_group_members.test-group: Refreshing state... [name=test-group]

Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the following symbols:
  ~ update in-place

Terraform will perform the following actions:

  # platform_group_members.test-group will be updated in-place
  ~ resource "platform_group_members" "test-group" {
      ~ members = [
          + "anonymous",
            # (2 unchanged elements hidden)
        ]
        name    = "test-group"
    }

Plan: 0 to add, 1 to change, 0 to destroy.

─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────

Note: You didn't use the -out option to save this plan, so Terraform can't guarantee to take exactly these actions if you run "terraform apply" now.

Are you not seeing this plan update?

@bakito
Copy link

bakito commented Jan 7, 2025

@alexhung Thank you for the quick reply.

I tried the same again today, and everything works perfect.
I must have done something wrong yesterday.
Sorry for the inconvenience.

@alexhung
Copy link
Member Author

alexhung commented Jan 7, 2025

@bakito No problem! Glad it is working for you now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Automatically generated release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add a platform_group_assignment resource
5 participants