terraform-provider-newrelic icon indicating copy to clipboard operation
terraform-provider-newrelic copied to clipboard

Importing workloads should only take a guid

Open vosechu opened this issue 4 years ago • 3 comments

Feature Description

Importing workloads should only require the guid from the url. That string contains everything you need to move forward I believe. Specifically wrt this page: https://registry.terraform.io/providers/newrelic/newrelic/latest/docs/resources/workload

echo "eyJuZXJkbGV0SWQiOiJ3b3JrbG9hZHMub3ZlcnZpZXciLCJlbnRpdHlJZCI6Ik1YeE9VakY4VjA5U1MweFBRVVI4TWpJME1EZyJ9" | base64 -d | jq
{
  "nerdletId": "workloads.overview",
  "entityId": "MXxOUjF8V09SS0xPQUR8MjI0MDg"
}

> echo "MXxOUjF8V09SS0xPQUR8MjI0MDg" | base64 -d
1|NR1|WORKLOAD|224

vosechu avatar Jul 30 '20 22:07 vosechu

Hey there @vosechu! Thanks for the issue!

Workloads are account-scoped (you can't look them up in NerdGraph without an account ID), so at a minimum we'll need account ID and GUID for an import.

The integer workload ID was needed at the time this Terraform resource was implemented because the underlying API made use of it in an early version of its schema. The workloads team has since updated the schema to standardize around the GUID, which is great. That means we can eliminate the need for the integer workload ID on import, but it's going to be slightly tricky because it will be a breaking change for the state files of anyone who has already made use of this resource. It's totally possible but we will just need to be careful to migrate all existing state out in the wild. Can you weigh in on the pain it is causing? Is it more of a hassle or is it a blocker for a certain use case?

ctrombley avatar Jul 30 '20 23:07 ctrombley

No pain at all. Definitely feel free to close.

What really happened was that I learned that we can base64 decode everything and I'm excited to find places that could take advantage of the wealth of info. All I was saying here was that the entity id contains account id, so you really don't need both.

But given the pain of changing, it's probably not worth doing now :)

❤️ you Trombs!

vosechu avatar Jul 31 '20 21:07 vosechu

Whoa I didn't even realize what you had written up!

mindblown

TIL! We will definitely take this on!

ctrombley avatar Aug 03 '20 18:08 ctrombley