Add configuration items
This commit is contained in:
parent
6790c2c86f
commit
76b9caefc6
3 changed files with 71 additions and 0 deletions
|
@ -1,2 +1,4 @@
|
|||
# terraform-provider-croc
|
||||
Terraform provider for Croc.ru
|
||||
|
||||
https://www.hashicorp.com/blog/terraform-custom-providers.html
|
||||
|
|
57
croc/provider.go
Normal file
57
croc/provider.go
Normal file
|
@ -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()
|
||||
}
|
12
main.go
Normal file
12
main.go
Normal file
|
@ -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,
|
||||
})
|
||||
}
|
Loading…
Reference in a new issue