Skip to content

Feat/ephemeral resource user - #14

Open
ocalzi wants to merge 29 commits into
SamuZad:mainfrom
ocalzi:feat/ephemeral_resource_user
Open

Feat/ephemeral resource user#14
ocalzi wants to merge 29 commits into
SamuZad:mainfrom
ocalzi:feat/ephemeral_resource_user

Conversation

@ocalzi

@ocalzi ocalzi commented Jul 1, 2025

Copy link
Copy Markdown

Created one day before the repo went on archive mode... hashicorp#523 (comment)
I guess some actions will be needed.

Changes:

bump go version
add ephemeral values support to write-only argument password_wo to resource_user
update documentation

Build locally and tested with sucess:

PLAN:

│ Warning: Provider development overrides are in effect
│ 
│ The following provider development overrides are set in the CLI configuration:
│  - hashicorp/googleworkspace in /Users/XY/Downloads/learn-terraform-google-workspace-main/bin
│ 
│ The behavior may therefore not match any released version of the provider and applying changes may cause the state to become incompatible with
│ published releases.
╵
ephemeral.random_password.db_password: Opening...
ephemeral.random_password.db_password: Opening complete after 0s
ephemeral.random_password.db_password: Closing...
ephemeral.random_password.db_password: Closing complete after 0s

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:

  # googleworkspace_user.users["Jim"] will be created
  + resource "googleworkspace_user" "users" {
      + agreed_to_terms                    = (known after apply)
      + creation_time                      = (known after apply)
      + customer_id                        = (known after apply)
      + deletion_time                      = (known after apply)
      + etag                               = (known after apply)
      + hash_function                      = "MD5"
      + id                                 = (known after apply)
      + include_in_global_address_list     = true
      + is_admin                           = (known after apply)
      + is_delegated_admin                 = (known after apply)
      + is_enforced_in_2_step_verification = (known after apply)
      + is_enrolled_in_2_step_verification = (known after apply)
      + is_mailbox_setup                   = (known after apply)
      + last_login_time                    = (known after apply)
      + non_editable_aliases               = (known after apply)
      + org_unit_path                      = (known after apply)
      + password_wo                        = (write-only attribute)
      + password_wo_version                = 1
      + primary_email                      = "jhalpert@example.com"
      + recovery_email                     = "jhalpert@gmail.com"
      + suspension_reason                  = (known after apply)
      + thumbnail_photo_etag               = (known after apply)
      + thumbnail_photo_url                = (known after apply)

      + languages (known after apply)

      + name {
          + family_name = "Halpert"
          + full_name   = (known after apply)
          + given_name  = "Jim"
        }

      + organizations {
          + department = "sales"
          + primary    = true
          + title      = "agent"
          + type       = "work"
        }
    }

  # googleworkspace_user.users["Michael"] will be created
  + resource "googleworkspace_user" "users" {
      + agreed_to_terms                    = (known after apply)
      + creation_time                      = (known after apply)
      + customer_id                        = (known after apply)
      + deletion_time                      = (known after apply)
      + etag                               = (known after apply)
      + hash_function                      = "MD5"
      + id                                 = (known after apply)
      + include_in_global_address_list     = true
      + is_admin                           = (known after apply)
      + is_delegated_admin                 = (known after apply)
      + is_enforced_in_2_step_verification = (known after apply)
      + is_enrolled_in_2_step_verification = (known after apply)
      + is_mailbox_setup                   = (known after apply)
      + last_login_time                    = (known after apply)
      + non_editable_aliases               = (known after apply)
      + org_unit_path                      = (known after apply)
      + password_wo                        = (write-only attribute)
      + password_wo_version                = 1
      + primary_email                      = "mscott@example.com"
      + recovery_email                     = "mscott@hotmail.com"
      + suspension_reason                  = (known after apply)
      + thumbnail_photo_etag               = (known after apply)
      + thumbnail_photo_url                = (known after apply)

      + languages (known after apply)

      + name {
          + family_name = "Scott"
          + full_name   = (known after apply)
          + given_name  = "Michael"
        }

      + organizations {
          + department = "sales"
          + primary    = true
          + title      = "manager"
          + type       = "work"
        }
    }

  # googleworkspace_user.users["Pam"] will be created
  + resource "googleworkspace_user" "users" {
      + agreed_to_terms                    = (known after apply)
      + creation_time                      = (known after apply)
      + customer_id                        = (known after apply)
      + deletion_time                      = (known after apply)
      + etag                               = (known after apply)
      + hash_function                      = "MD5"
      + id                                 = (known after apply)
      + include_in_global_address_list     = true
      + is_admin                           = (known after apply)
      + is_delegated_admin                 = (known after apply)
      + is_enforced_in_2_step_verification = (known after apply)
      + is_enrolled_in_2_step_verification = (known after apply)
      + is_mailbox_setup                   = (known after apply)
      + last_login_time                    = (known after apply)
      + non_editable_aliases               = (known after apply)
      + org_unit_path                      = (known after apply)
      + password_wo                        = (write-only attribute)
      + password_wo_version                = 1
      + primary_email                      = "pbeesly@example.com"
      + recovery_email                     = "pbeesly@gmail.com"
      + suspension_reason                  = (known after apply)
      + thumbnail_photo_etag               = (known after apply)
      + thumbnail_photo_url                = (known after apply)

      + languages (known after apply)

      + name {
          + family_name = "Beesly"
          + full_name   = (known after apply)
          + given_name  = "Pam"
        }

      + organizations {
          + department = "admin"
          + primary    = true
          + title      = "receptionist"
          + type       = "work"
        }
    }

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

Changes to Outputs:
  + user_email = [
      + "jhalpert@example.com",
      + "mscott@example.com",
      + "pbeesly@example.com",
    ]

APPLY:

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

ephemeral.random_password.db_password: Opening...
ephemeral.random_password.db_password: Opening complete after 0s
googleworkspace_user.users["Jim"]: Creating...
googleworkspace_user.users["Pam"]: Creating...
googleworkspace_user.users["Michael"]: Creating...
googleworkspace_user.users["Michael"]: Still creating... [00m10s elapsed]
googleworkspace_user.users["Jim"]: Still creating... [00m10s elapsed]
googleworkspace_user.users["Pam"]: Still creating... [00m10s elapsed]
googleworkspace_user.users["Michael"]: Still creating... [00m20s elapsed]
googleworkspace_user.users["Jim"]: Still creating... [00m20s elapsed]
googleworkspace_user.users["Pam"]: Still creating... [00m20s elapsed]
googleworkspace_user.users["Michael"]: Still creating... [00m30s elapsed]
googleworkspace_user.users["Pam"]: Still creating... [00m30s elapsed]
googleworkspace_user.users["Jim"]: Still creating... [00m30s elapsed]
googleworkspace_user.users["Jim"]: Still creating... [00m40s elapsed]
googleworkspace_user.users["Pam"]: Still creating... [00m40s elapsed]
googleworkspace_user.users["Michael"]: Still creating... [00m40s elapsed]
googleworkspace_user.users["Michael"]: Still creating... [00m50s elapsed]
googleworkspace_user.users["Pam"]: Still creating... [00m50s elapsed]
googleworkspace_user.users["Jim"]: Still creating... [00m50s elapsed]
googleworkspace_user.users["Jim"]: Still creating... [01m00s elapsed]
googleworkspace_user.users["Michael"]: Still creating... [01m00s elapsed]
googleworkspace_user.users["Pam"]: Still creating... [01m00s elapsed]
googleworkspace_user.users["Michael"]: Still creating... [01m10s elapsed]
googleworkspace_user.users["Pam"]: Still creating... [01m10s elapsed]
googleworkspace_user.users["Jim"]: Still creating... [01m10s elapsed]
googleworkspace_user.users["Jim"]: Still creating... [01m20s elapsed]
googleworkspace_user.users["Michael"]: Still creating... [01m20s elapsed]
googleworkspace_user.users["Pam"]: Still creating... [01m20s elapsed]
googleworkspace_user.users["Pam"]: Still creating... [01m30s elapsed]
googleworkspace_user.users["Michael"]: Still creating... [01m30s elapsed]
googleworkspace_user.users["Jim"]: Still creating... [01m30s elapsed]
googleworkspace_user.users["Michael"]: Still creating... [01m40s elapsed]
googleworkspace_user.users["Pam"]: Still creating... [01m40s elapsed]
googleworkspace_user.users["Jim"]: Still creating... [01m40s elapsed]
googleworkspace_user.users["Jim"]: Still creating... [01m50s elapsed]
googleworkspace_user.users["Michael"]: Still creating... [01m50s elapsed]
googleworkspace_user.users["Pam"]: Still creating... [01m50s elapsed]
googleworkspace_user.users["Pam"]: Creation complete after 1m50s [id=106731811473452596794]
googleworkspace_user.users["Michael"]: Still creating... [02m00s elapsed]
googleworkspace_user.users["Jim"]: Still creating... [02m00s elapsed]
googleworkspace_user.users["Jim"]: Creation complete after 2m1s [id=105919094940464869105]
googleworkspace_user.users["Michael"]: Still creating... [02m10s elapsed]
googleworkspace_user.users["Michael"]: Creation complete after 2m11s [id=104633277174626846250]
ephemeral.random_password.db_password: Closing...
ephemeral.random_password.db_password: Closing complete after 0s

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

Outputs:

user_email = [
      "jhalpert@example.com",
      "mscott@example.com",
       "pbeesly@example.com",
]

Resource definition:

ephemeral "random_password" "db_password" {
  length           = 16
  override_special = "!#$%&*()-_=+[]{}<>:?"
}

resource "googleworkspace_user" "users" {
  for_each = { for user in local.users : user.first_name => user }

  primary_email = each.value.email
  password_wo = md5(ephemeral.random_password.db_password.result)
  password_wo_version = 1
  hash_function = each.value.password_hash_function

  name {
    family_name = each.value.last_name
    given_name  = each.value.first_name
  }

  organizations {
    department = each.value.dept
    primary    = true
    title      = each.value.title
    type       = "work"
  }
  recovery_email = each.value.recovery_email
}

Please let me know if I need to add more details, it’s my first PR since a long time.

Regards,

hashicorp-tsccr Bot and others added 29 commits September 11, 2023 21:56
Co-authored-by: hashicorp-tsccr[bot] <hashicorp-tsccr[bot]@users.noreply.github.com>
…p#467)

Co-authored-by: hashicorp-tsccr[bot] <hashicorp-tsccr[bot]@users.noreply.github.com>
Co-authored-by: hashicorp-copywrite[bot] <110428419+hashicorp-copywrite[bot]@users.noreply.github.com>
…shicorp#477)

Bundle license file with TF provider release artifacts
…orp#480)

Adding LICENSE.txt file to Terraform Provider Release Archives
* Update CODEOWNERS

* Update CODEOWNERS

---------

Co-authored-by: Sarah French <15078782+SarahFrench@users.noreply.github.com>
Bumps [hashicorp/vault-action](https://github.com/hashicorp/vault-action) from 2.4.0 to 2.7.1.
- [Release notes](https://github.com/hashicorp/vault-action/releases)
- [Changelog](https://github.com/hashicorp/vault-action/blob/main/CHANGELOG.md)
- [Commits](hashicorp/vault-action@v2.4.0...v2.7.1)

---
updated-dependencies:
- dependency-name: hashicorp/vault-action
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
…orkflows/hashicorp.yml to v4.0.1 (hashicorp#487)

This patch bumps hashicorp/ghaction-terraform-provider-release/.github/workflows/hashicorp.yml to v4.0.1, with the intention of using the new runner labels format (see release notes in https://github.com/hashicorp/ghaction-terraform-provider-release/releases/tag/v4.0.1).

This change is necessary for a runner to pick up jobs using this action.
Bumps [hashicorp/vault-action](https://github.com/hashicorp/vault-action) from 2.7.1 to 3.3.0.
- [Release notes](https://github.com/hashicorp/vault-action/releases)
- [Changelog](https://github.com/hashicorp/vault-action/blob/main/CHANGELOG.md)
- [Commits](hashicorp/vault-action@v2.7.1...v3.3.0)

---
updated-dependencies:
- dependency-name: hashicorp/vault-action
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Bumps [actions/upload-artifact](https://github.com/actions/upload-artifact) from 3.1.3 to 4.6.1.
- [Release notes](https://github.com/actions/upload-artifact/releases)
- [Commits](actions/upload-artifact@a8a3f3a...4cec3d8)

---
updated-dependencies:
- dependency-name: actions/upload-artifact
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Bumps [actions/checkout](https://github.com/actions/checkout) from 3df4ab11eba7bda6032a0b82a6bb43b11571feac to 85e6279cec87321a52edac9c87bce653a07cf6c2.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](actions/checkout@3df4ab1...85e6279)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Bumps [actions/setup-go](https://github.com/actions/setup-go) from 4.1.0 to 5.3.0.
- [Release notes](https://github.com/actions/setup-go/releases)
- [Commits](actions/setup-go@93397be...f111f33)

---
updated-dependencies:
- dependency-name: actions/setup-go
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
hashicorp#500)

Bumps [hashicorp/ghaction-terraform-provider-release](https://github.com/hashicorp/ghaction-terraform-provider-release) from 4.0.1 to 5.0.0.
- [Release notes](https://github.com/hashicorp/ghaction-terraform-provider-release/releases)
- [Changelog](https://github.com/hashicorp/ghaction-terraform-provider-release/blob/main/CHANGELOG.md)
- [Commits](hashicorp/ghaction-terraform-provider-release@v4.0.1...v5.0.0)

---
updated-dependencies:
- dependency-name: hashicorp/ghaction-terraform-provider-release
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
…ashicorp#501)

Bumps [github.com/hashicorp/terraform-plugin-docs](https://github.com/hashicorp/terraform-plugin-docs) from 0.8.1 to 0.21.0.
- [Release notes](https://github.com/hashicorp/terraform-plugin-docs/releases)
- [Changelog](https://github.com/hashicorp/terraform-plugin-docs/blob/main/CHANGELOG.md)
- [Commits](hashicorp/terraform-plugin-docs@v0.8.1...v0.21.0)

---
updated-dependencies:
- dependency-name: github.com/hashicorp/terraform-plugin-docs
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Bumps [google.golang.org/api](https://github.com/googleapis/google-api-go-client) from 0.79.0 to 0.226.0.
- [Release notes](https://github.com/googleapis/google-api-go-client/releases)
- [Changelog](https://github.com/googleapis/google-api-go-client/blob/main/CHANGES.md)
- [Commits](googleapis/google-api-go-client@v0.79.0...v0.226.0)

---
updated-dependencies:
- dependency-name: google.golang.org/api
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
@SamuZad

SamuZad commented Aug 10, 2025

Copy link
Copy Markdown
Owner

Hi @ocalzi! I will review in the next week or so and provide feedback

@ocalzi

ocalzi commented Sep 1, 2025

Copy link
Copy Markdown
Author

Hi @SamuZad any news ? I guess it was hard finding time during summer.

@SamuZad

SamuZad commented Sep 8, 2025

Copy link
Copy Markdown
Owner

Hi @ocalzi - sorry, I was busy on projects and didn't have time. I do now. Could you resolve conflicts please?

@ocalzi

ocalzi commented Sep 8, 2025

Copy link
Copy Markdown
Author

Hi, Yes I’m going to have a look asap.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants