diff --git a/README.md b/README.md index 2fcd11a..3551d54 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,4 @@ # terraform-provider-croc Terraform provider for Croc.ru + +https://www.hashicorp.com/blog/terraform-custom-providers.html diff --git a/croc/provider.go b/croc/provider.go new file mode 100644 index 0000000..5e3ad26 --- /dev/null +++ b/croc/provider.go @@ -0,0 +1,57 @@ +package croc + +import ( + "log" + "github.com/hashicorp/terraform/helper/schema" + "github.com/hashicorp/terraform/terraform" + ) + + func Provider() terraform.ResourceProvider { + return &schema.Provider{ + Schema: map[string]*schema.Schema{ + "project" : &schema.Schema{ + Type: schema.TypeString, + Required: true, + }, + "storage_url" : &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Default: "https://storage.cloud.croc.ru:443", + }, + "api_url" : &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Default: "https://api.cloud.croc.ru:443/", + }, + "monitoring_url" : &schema.Schema{ + Type: schema.TypeString, + Optional: true, + Default: "https://monitoring.cloud.croc.ru:443/", + }, + "ec2_access_key" : &schema.Schema{ + Type: schema.TypeString, + Required: true, + }, + "ec2_secret_key" : &schema.Schema{ + Type: schema.TypeString, + Required: true, + }, + "aws_access_key" : &schema.Schema{ + Type: schema.TypeString, + Required: true, + }, + "aws_secret_key" : &schema.Schema{ + Type: schema.TypeString, + Required: true, + }, + }, + ResourcesMap: map[string]*schema.Resource{}, + }, + ConfigureFunc: providerConfigure, +} + +func providerConfigure(d * schema.ResourceData) (interface{}, error) { + config := Config{} + log.Println("[INFO], Initializing Croc client") + return config.Client() +} diff --git a/main.go b/main.go new file mode 100644 index 0000000..c06a4b8 --- /dev/null +++ b/main.go @@ -0,0 +1,12 @@ +package main + +import ( + "github.com/hashicorp/terraform/plugin" + "github.com/AlexisSellier/terraform-provider-croc/croc" + ) + + func main() { + plugin.Serve(&plugin.ServeOpts{ + ProviderFunc: croc.Provider, +}) +}