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

fixed #1031 adds provision on demand #1032

Merged
merged 3 commits into from
May 9, 2024

Conversation

iwarapter
Copy link
Contributor

Hey @manicminer,

I have tested this with an AWS SSO configured app and it worked well, however I don't have access to an Azure tenant I can test the providers functional tests on. Not sure how best to proceed atm.

Terraform will perform the following actions:

  # azuread_synchronization_job_provision_on_demand.example will be created
  + resource "azuread_synchronization_job_provision_on_demand" "example" {
      + id                   = (known after apply)
      + job_id               = "aWSSingleSignon.hidden"
      + service_principal_id = "hidden"

      + parameters {
          + rule_id = "hidden"

          + subjects {
              + object_id        = "hidden"
              + object_type_name = "Group"
            }
        }
    }

Plan: 1 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

azuread_synchronization_job_provision_on_demand.example: Creating...
azuread_synchronization_job_provision_on_demand.example: Creation complete after 4s [id=d66c068e-2711-409e-068d-8b55b8bb852e]

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

Contains existing PR changes for reference only, will rebase once they are merged.

Copy link
Member

@manicminer manicminer left a comment

Choose a reason for hiding this comment

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

@iwarapter Thanks for working on this. If you aren't able to run acceptance tests that's no problem, we can run them in our testing tenant. I'm happy to make small fixes to the tests as needed and I can report test results back to you for potentially larger fixes.

On the whole this is looking good. We will need to rewrite the doc as the format/style produced by tfplugindocs unfortunately is different to the provider docs - I recommend copying an existing doc and changing it as needed. Additionally if you can look at the comments below, and finish up the Read, Update and Delete funcs, then I'll be happy to take another look. Thanks!

@iwarapter
Copy link
Contributor Author

hey @manicminer, thanks for the feedback. I have addressed all the parts you raised. For the acceptance test i'd need to know what the rule_id are available in the databricks schema in order for it to run. We could also do with a data source for this, but didnt see it in the graph api lib - https://learn.microsoft.com/en-us/graph/api/synchronization-synchronizationschema-get?view=graph-rest-beta&tabs=http

@iwarapter
Copy link
Contributor Author

@manicminer is there anything further I can do to help with this?

@iwarapter iwarapter marked this pull request as ready for review March 14, 2023 12:09
@manicminer manicminer linked an issue Apr 24, 2023 that may be closed by this pull request
@manicminer manicminer modified the milestone: v2.38.0 Apr 24, 2023
@manicminer
Copy link
Member

manicminer commented Apr 27, 2023

@iwarapter Thanks, and apologies for the delayed reply. At this time I don't have the bandwidth to create tests for this, so if you could have a go at writing some acceptance tests that will help enormously. I don't mind kicking the tires and tweaking existing tests to get them working reliably, but this will be waiting a little while if I have to write the tests. Thanks!

@iwarapter
Copy link
Contributor Author

hey @manicminer i had a quick stab - iwarapter@9da78c0 there are a few //TODO which i need extra info for

@github-actions github-actions bot added size/XL and removed size/L labels Apr 28, 2023
@iwarapter
Copy link
Contributor Author

@manicminer have pushed the tests - from what i can see the databricks integration used for acctests isnt fully integrated so this can't be tested e2e with it (im just testing config and then the expected failure). is there another app the acctests can use to test full e2e provisioning?

service_principal_id = azuread_service_principal.test.id
synchronization_job_id = trimprefix(azuread_synchronization_job.test.id, "${azuread_service_principal.test.id}/job/")
parameter {
rule_id = "03f7d90d-bf71-41b1-bda6-aaf0ddbee5d8" //no api to check this so assuming the rule id is the same globally :finger_crossed:

Choose a reason for hiding this comment

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

FWIW, this ID is the same in my tenant

Copy link
Member

@manicminer manicminer left a comment

Choose a reason for hiding this comment

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

@iwarapter Apologies for the delay in re-reviewing this. I was originally anticipating the resource would have Read and Delete functions, but on closer inspection of the API and provisioning process, I see that there is no way to track a single "provision".

This makes it impossible to track state in Terraform for this operation, as this is more of a fire and forget task than a resource having some sort of lifecycle. With that in mind, I'm unsure whether this would be a good fit for Terraform unless we can find some other way to track state here? Alternatively, if the primary use case is to provision users, this could possibly make sense as an optional block in the azuread_user resource instead? That way, we'd have some tangible state to track after the sync job has been triggered. WDYT?

@iwarapter
Copy link
Contributor Author

Hi @manicminer, thanks for getting back to this. Thats correct, but there is prior art for this style of resource - mainly the aws lambda invocation resource.

The only way you could check if the resource has been provisioned currently is by calling the provision api and checking the response code - but this is definitely not what we want in the READ part 😄. I certainly wouldn't bundle this into any other resources as the closest one is the azuread_synchronization_job.

I disagree that it's not a good fit for terraform as it enables a key part of fully managing resources across azuread and a given service provider. Here's a quick example use case:

Add a group to a azure application (all covered with this provider)
GAP
Assign a SCIM managed group to a given permission set within AWS (all covered with the AWS provider)

This resource solves the gap between the two where the group won't exist in AWS as you at the mercy of the SCIM scheduler. I deploy many hundreds of groups/role bindings and this is quite painful.

@manicminer
Copy link
Member

@iwarapter Thanks for the context, I see now that the sync can happen in either direction and the resulting object(s) are not likely to be directly managed anyway. In which case this seems like a reasonable way to implement this. Do you think it's worth adding a triggers faux-meta argument (which is conventionally a map) to enable programmatic reprovisioning?

@iwarapter
Copy link
Contributor Author

its not a bad shout, i cant think of any (personal) use cases for it. But simple enough to just add a map trigger

@iwarapter
Copy link
Contributor Author

I'll try add this tomorrow morning

@iwarapter
Copy link
Contributor Author

@manicminer lifted straight from the aws provider 😂

Copy link
Member

@manicminer manicminer left a comment

Choose a reason for hiding this comment

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

@iwarapter Thanks, I pushed some minor style fixes and also a crash fix in expandSynchronizationJobApplicationParameters(). LGTM! 👍

@iwarapter
Copy link
Contributor Author

cool glad to see this getting merged :)

@manicminer
Copy link
Member

Test result

Screenshot 2024-05-09 at 12 49 18

@manicminer manicminer merged commit 5c41f28 into hashicorp:main May 9, 2024
28 checks passed
@github-actions github-actions bot added this to the v2.49.0 milestone May 9, 2024
manicminer added a commit that referenced this pull request May 9, 2024
dduportal referenced this pull request in jenkins-infra/azure May 10, 2024
<Actions>
<action
id="6d17e7acdb2f3311576150379e22805f2f9b4aa72ff00ec136aceee45cae4b98">
        <h3>Bump Terraform `azuread` provider version</h3>
<details
id="1d9343c012f5434ac9fe8a98135bae3667b399259be16d9b14302ea3bd424a24">
            <summary>Update Terraform lock file</summary>
<p>changes detected:&#xA;&#x9;&#34;hashicorp/azuread&#34; updated from
&#34;2.48.0&#34; to &#34;2.49.0&#34; in file
&#34;.terraform.lock.hcl&#34;</p>
            <details>
                <summary>2.49.0</summary>
<pre>Changelog retrieved
from:&#xA;&#x9;https://github.com/hashicorp/terraform-provider-azuread/releases/tag/v2.49.0&#xA;FEATURES:&#xA;&#xA;*
**New Data Source:** `azuread_group_role_management_policy`
([#1327](https://github.com/hashicorp/terraform-provider-azuread/issues/1327))&#xA;*
**New Resource:** `azuread_group_role_management_policy`
([#1327](https://github.com/hashicorp/terraform-provider-azuread/issues/1327))&#xA;*
**New Resource:** `azuread_privileged_access_group_assignment_schedule`
([#1327](https://github.com/hashicorp/terraform-provider-azuread/issues/1327))&#xA;*
**New Resource:** `azuread_privileged_access_group_eligibility_schedule`
([#1327](https://github.com/hashicorp/terraform-provider-azuread/issues/1327))&#xA;*
**New Resource:** `azuread_synchronization_job_provision_on_demand`
([#1032](https://github.com/hashicorp/terraform-provider-azuread/issues/1032))&#xA;&#xA;ENHANCEMENTS:&#xA;&#xA;*
`data.azuread_group` - support for the `include_transitive_members`
property
([#1300](https://github.com/hashicorp/terraform-provider-azuread/issues/1300))&#xA;*
`azuread_application` - relax validation for the `identifier_uris`
property to allow more values
([#1351](https://github.com/hashicorp/terraform-provider-azuread/issues/1351))&#xA;*
`azuread_application_identifier_uri` - relax validation for the
`identifier_uri` property to allow more values
([#1351](https://github.com/hashicorp/terraform-provider-azuread/issues/1351))&#xA;*
`azuread_group` - support the `SkipExchangeInstantOn` value for the
`behaviors` property
([#1370](https://github.com/hashicorp/terraform-provider-azuread/issues/1370))&#xA;*
`azuread_user` - relax validation for the `employee_type` property to
allow more values
([#1328](https://github.com/hashicorp/terraform-provider-azuread/issues/1328))&#xA;&#xA;BUG
FIXES:&#xA;&#xA;* `azuread_application_pre_authorized` - fix a
destroy-time bug that could prevent deletion of the resource
([#1299](https://github.com/hashicorp/terraform-provider-azuread/issues/1299))&#xA;&#xA;&#xA;</pre>
            </details>
        </details>
<a
href="https://infra.ci.jenkins.io/job/updatecli/job/azure/job/main/158/">Jenkins
pipeline link</a>
    </action>
</Actions>

---

<table>
  <tr>
    <td width="77">
<img src="https://www.updatecli.io/images/updatecli.png" alt="Updatecli
logo" width="50" height="50">
    </td>
    <td>
      <p>
Created automatically by <a
href="https://www.updatecli.io/">Updatecli</a>
      </p>
      <details><summary>Options:</summary>
        <br />
<p>Most of Updatecli configuration is done via <a
href="https://www.updatecli.io/docs/prologue/quick-start/">its
manifest(s)</a>.</p>
        <ul>
<li>If you close this pull request, Updatecli will automatically reopen
it, the next time it runs.</li>
<li>If you close this pull request and delete the base branch, Updatecli
will automatically recreate it, erasing all previous commits made.</li>
        </ul>
        <p>
Feel free to report any issues at <a
href="https://github.com/updatecli/updatecli/issues">github.com/updatecli/updatecli</a>.<br
/>
If you find this tool useful, do not hesitate to star <a
href="https://github.com/updatecli/updatecli/stargazers">our GitHub
repository</a> as a sign of appreciation, and/or to tell us directly on
our <a
href="https://matrix.to/#/#Updatecli_community:gitter.im">chat</a>!
        </p>
      </details>
    </td>
  </tr>
</table>

Co-authored-by: Jenkins Infra Bot (updatecli) <60776566+jenkins-infra-bot@users.noreply.github.com>
BrendanThompson pushed a commit to BrendanThompson/terraform-provider-azuread that referenced this pull request Jun 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support synchronization provision on demand
3 participants