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

Provider doesn't detect when the tenant domain has been deleted from RSC. #85

Open
DamaniN opened this issue Oct 3, 2023 · 2 comments
Labels
api-issue There is an issue with the backend API azure Microsoft Azure bug Something isn't working

Comments

@DamaniN
Copy link

DamaniN commented Oct 3, 2023

Expected Behavior

Using the Azure CNP integration, an update of polaris_azure_service_principal should detect if the Azure AD tenant still exists in RSC.

Current Behavior

I destroyed a Terraform script that removed the polaris_azure_subscription resource. This resource was linked to the last subscription in the tenant. This action also causes RSC to delete the last tenant. I then went to add the subscription back again by running a plan on the same resource. This resulted in the following error:

│ Error: failed to add subscription: failed to request addAzureCloudAccountWithoutOauth: graphql response body is an error (status code 200): NOT_FOUND: Failed to get service principal in the tenant. Azure may take some time to sync service principal. Please try after a minute (Azure error: [Unknown] Unknown service error) (code: 404, traceId: FWaZk7YsxjaRDF5NlWWsAw==)
│ 
│   with polaris_azure_subscription.polaris,
│   on main.tf line 84, in resource "polaris_azure_subscription" "polaris":
│   84: resource "polaris_azure_subscription" "polaris" {

I looked in RSC and noticed that the tenant domain was not there anymore. I then re-ran my TF script that creates the tenant domain in RSC via the polaris_azure_service_principal resource. Re-running the existing TF configuration resulted in the following message:

polaris_azure_service_principal.polaris: Refreshing state... [id=907a1235-8fb2-4670-943d-c478af52734f]

No changes. Your infrastructure matches the configuration.

Terraform has compared your real infrastructure against your configuration and found no differences, so no changes are needed.

This action should have resulted in TF finding that the tenant domain no longer existed and therefore putting it back. I was able to prove/workaround this by tainting the polaris_azure_service_principal.polaris resource and re-running the apply operation.

Failure Information (for bugs)

See text above

Steps to Reproduce

  1. Create an SP for a new Azure tenant domain with the polaris_azure_service_principal resource.
  2. Add a subscription to the tenant domain with the polaris_azure_subscription resource.
  3. Delete the subscription from RSC by destroying the polaris_azure_subscription resource, but do not destroy the polaris_azure_service_principal resource.
  4. Try to add the subscription back again by re-creating the same polaris_azure_subscription resource.

Context

  • Version of project = v0.8.0-beta.3
  • Version of dependencies = N/A
  • Version of operating system = N/A

Failure Logs

See above.

@johan3141592 johan3141592 added azure Microsoft Azure api-issue There is an issue with the backend API bug Something isn't working labels Mar 26, 2024
@johan3141592
Copy link
Member

This could be solved using the azureCloudAccountTenant GraphQL endpoint. We should probably add Tenant as a concept to the Go SDK, to be used in the TF provider.

@johan3141592 johan3141592 removed the api-issue There is an issue with the backend API label Mar 28, 2024
@johan3141592 johan3141592 self-assigned this Apr 3, 2024
johan3141592 added a commit to rubrikinc/rubrik-polaris-sdk-for-go that referenced this issue Apr 10, 2024
See: rubrikinc/terraform-provider-polaris#85

* Added unit tests for Azure service principal
* Added unit tests for listing Azure tenants and subscriptions
* Replace the old way of listing tenants/subscriptions with single API
call.
* Added Tenant/Tenants/TenantFromAppID
* Added app name to ServicePrincipal
@johan3141592
Copy link
Member

To fix this issue we need improvements to the GraphQL API. The issue has been raised with the engineering team.

@johan3141592 johan3141592 added the api-issue There is an issue with the backend API label May 29, 2024
@johan3141592 johan3141592 removed their assignment Nov 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api-issue There is an issue with the backend API azure Microsoft Azure bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants