Writing terraform schema for the api response (Custom provider)

Hello Folks,

I’m trying to write my own terraform provider for an Api’s.

Here’s the response::

{
"data": [
    {
        "id": "5f35a422ce4a86df8a9",
        "name": "Example Service",
        "slug": "example-service",
        "email": "c840842b6064acff1f085f07aad9d4f1c1fac45c@xyz.com",
        "escalation_policy_id": "5f35a422xxxxxxx",
        "organization_id": "xxxxxxxxxxxx",
        "api_key": "c840xxxxxxxx5c",
        "description": "Example Service",
        "depends": [],
        "escalation_policy": {
            "id": "xxxxxxxxxxxx3",
            "name": "Example Escalation Policy",
            "description": "On-Boarding Exampleccc",
            "slug": "example-escalation-policy"
        }
    },
    {
        "id": "5f3xxxxx2",
        "name": "firstSer5e",
        "slug": "firstser5e",
        "email": "ro.com",
        "escalation_policy_id": "5f35xxxxx3",
        "organization_id": "xxxxxxxxxxd",
        "api_key": "5e49a3f384xxxxxxxxxxc8d6",
        "description": "createdViaApi",
        "depends": null,
        "escalation_policy": {
            "id": "5f35axxxxxxxxxx73",
            "name": "Example Escalation Policy",
            "description": "On-Boarding Exampleccc",
            "slug": "example-escalation-policy"
        }
    }
]

}

I’m bit stuck in writing schema in Golang. Any help would be appreciated!

Hi Roshan,

We recently published a collection of tutorials that guide you through writing a custom Terraform provider.

The Implement Complex Read tutorial contains instructions on how to map a complex, nested data model into a schema.Resource{}. The order data model/schema explored is similar to your response’s.

Let me know if that helps or if you have any additional questions!

1 Like