
2 4 0 Custom Terraform Provider: Resource and CRUD (Go)
Code Notes
package main
import (
"bytes"
"encoding/json"
"net/http"
...
)
func main() {...}
type Config struct {...}
func provider() {...}
func validateUUID(...) {...}
func providerConfigure(...) {...}
func Resource() *schema.Resource {
resource := &schema.Resource{
CreateContext: resourceHouseCreate,
ReadContext: resourceHouseRead,
UpdateContext: resourceHouseUpdate,
DeleteContext: resourceHouseDelete,
Schema: map[string]*schema.Schema{
"name": {
Type: schema.TypeString,
Required: true,
Description: "Name of home",
},
"description": {
Type: schema.TypeString,
Required: true,
Description: "Description of home",
},
"domain_name": {
Type: schema.TypeString,
Required: true,
Description: "Domain name of home eg. *.cloudfront.net",
},
"town": {
Type: schema.TypeString,
Required: true,
Description: "The town to which the home will belong to",
},
"content_version": {
Type: schema.TypeInt,
Required: true,
Description: "The content version of the home",
},
},
}
return resource
}
Resources
Last updated
