Minimum requirements for provider CRUD and data source functions to behave properly?

I am very new to the provider SDK. I see lots of example code, but I haven’t found 1 central place that describes the minimum requirements for implementing the provider CRUD functions. I am specifically concerned with the proper way to handle what each CRUD function should do in the various scenarios of modifications to the system (i.e. what the provider is for) EXTERNAL to the terraform state. For example:

  1. What is the create function supposed to do if the resource already exists in the system? Should it throw an error or not? Should it set id to “” or not?
  2. What is the read function supposed to do if the resource no longer exists in the system? Should it throw an error or not? Should it set id to “” or not?
  3. Does the update function have to call HasChanges or can it just perform the update assuming the update function is only being called BECAUSE TF detected changes?

I guess I am looking for a boilerplate repo (using the latest sdk without using any deprecated function) with stubs for everything related to a data source and resource with comments on how to handle unexpected errors and when or when not to throw an error and when or when not to set id to a proper value OR “”.

Hi @scastria, have you had a chance to look at our scaffolding provider yet?

No, I did not know about that. I just took a look and it looks good for someone trying to get their build environment going and at the very beginning of writing a provider.

I am a little bit past that right now. I have a bunch of specific questions like the ones in my original post and a lot more.

Plus, I would like a lot more examples, like how to handle nested blocks (schemas), and more advanced stuff like that.

For example, in order to have a nested block, I see that the AWS provider uses a TypeList with MaxItems = 1. Why?