microsoft / microsoft/terraform-provider-msgraph

The resource is successfully created, but it is not written to the Terraform state.

Open
#60 3 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

enhancement
Dominant language
Go
Stars
65
Forks
25
Avg merge
3d 10h
Merged PRs (30d)
6

Description

Recently, I attempted to use the msgraph Terraform provider to provision the /identityGovernance/entitlementManagement/accessPackages/{accessPackageId}/accessPackageResourceRoleScopes resource via the Microsoft Graph Beta API.

Aside from the fact that the Microsoft Graph Beta API returns an invalid URL in the Location header during resource creation (in this specific case), there also appears to be an issue with how the msgraph Terraform provider handles the 201 Created HTTP status code.

Based on my limited experience, the msgraph Terraform provider appears to assume that every resource supports the GET by ID operation
and constructs the verification request using the original request URL and the resource ID returned in the POST response.
However, in reality, many resources in the Microsoft Graph API only support the LIST operation — as was the case in my situation — which leads to resource creation verification failures.

As a result, the resource is successfully created, but it is not written to the Terraform state.

Possible solutions:

  1. Preferably, a response with 201 Created status code should always include a valid URL in the Location header, so it can be used as intended. Therefore, we should report any invalid Location header issues to the upstream.
  2. If possible, implement client-side logic to determine whether the resource supports the GET by ID operation — for example, by analyzing the OpenAPI specification — and construct the verification request accordingly. If not, use appropriate fallback logic.

Related links:

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by tracing the provider's handling of a 201 Created response, including its use of the Location header and GET-by-ID verification request. Reproduce the accessPackageResourceRoleScopes case against the Microsoft Graph Beta API, then verify that creation succeeds and the resource is written to Terraform state when only LIST is supported.

Written by the indexing model from the issue text.

Assessment

Tech stack
go, terraform
Domain
api, infrastructure, tooling
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.