microsoft / microsoft/terraform-provider-msgraph
The resource is successfully created, but it is not written to the Terraform state.
Nobody has claimed this yet.
- 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:
- Preferably, a response with
201 Createdstatus code should always include a valid URL in theLocationheader, so it can be used as intended. Therefore, we should report any invalidLocationheader issues to the upstream. - If possible, implement client-side logic to determine whether the resource supports the
GET by IDoperation — 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
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- 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