func (c *CustomResourceProvisioner) provision(ctx context.Context, m Message, req customresources.Request) (string, interface{}, error) { p, ok := c.Provisioners[req.ResourceType] if !ok { return "", nil, fmt.Errorf("no provisioner for %v", req.ResourceType) } // If the provisioner defines a type for the properties, let's unmarhsal // into that Go type. req.ResourceProperties = p.Properties() req.OldResourceProperties = p.Properties() err := json.Unmarshal([]byte(m.Message), &req) if err != nil { return "", nil, fmt.Errorf("error unmarshalling to cloudformation request: %v", err) } return p.Provision(ctx, req) }