2014-05-30 02:28:38 +02:00
|
|
|
package aws
|
|
|
|
|
2014-06-03 23:26:31 +02:00
|
|
|
import (
|
2014-06-18 18:33:13 +02:00
|
|
|
"fmt"
|
|
|
|
|
2014-06-03 23:26:31 +02:00
|
|
|
"github.com/hashicorp/terraform/terraform"
|
|
|
|
)
|
|
|
|
|
2014-05-30 02:28:38 +02:00
|
|
|
type ResourceProvider struct {
|
|
|
|
}
|
|
|
|
|
2014-06-13 08:08:47 +02:00
|
|
|
func (p *ResourceProvider) Validate(c *terraform.ResourceConfig) ([]string, []error) {
|
|
|
|
errs := c.CheckSet([]string{
|
|
|
|
"access_key",
|
|
|
|
"secret_key",
|
|
|
|
})
|
|
|
|
|
|
|
|
return nil, errs
|
2014-06-13 07:39:29 +02:00
|
|
|
}
|
|
|
|
|
2014-06-13 07:15:36 +02:00
|
|
|
func (p *ResourceProvider) Configure(*terraform.ResourceConfig) error {
|
2014-06-07 05:17:38 +02:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2014-06-19 01:52:21 +02:00
|
|
|
func (p *ResourceProvider) Apply(
|
|
|
|
s *terraform.ResourceState,
|
|
|
|
d *terraform.ResourceDiff) (*terraform.ResourceState, error) {
|
|
|
|
result := &terraform.ResourceState{
|
|
|
|
ID: "foo",
|
|
|
|
}
|
2014-06-19 23:08:48 +02:00
|
|
|
result = result.MergeDiff(d)
|
2014-06-23 22:14:08 +02:00
|
|
|
result.Attributes["public_dns"] = "foo"
|
|
|
|
result.Attributes["public_ip"] = "foo"
|
|
|
|
result.Attributes["private_dns"] = "foo"
|
|
|
|
result.Attributes["private_ip"] = "foo"
|
2014-06-19 01:52:21 +02:00
|
|
|
|
|
|
|
return result, nil
|
|
|
|
}
|
|
|
|
|
2014-06-07 05:17:38 +02:00
|
|
|
func (p *ResourceProvider) Diff(
|
|
|
|
s *terraform.ResourceState,
|
2014-06-13 07:15:36 +02:00
|
|
|
c *terraform.ResourceConfig) (*terraform.ResourceDiff, error) {
|
2014-06-18 18:33:13 +02:00
|
|
|
b := diffMap.Get(s.Type)
|
|
|
|
if b == nil {
|
|
|
|
return nil, fmt.Errorf("Unknown type: %s", s.Type)
|
|
|
|
}
|
|
|
|
|
|
|
|
return b.Diff(s, c)
|
2014-05-30 02:28:38 +02:00
|
|
|
}
|
2014-06-03 23:26:31 +02:00
|
|
|
|
2014-06-20 20:52:21 +02:00
|
|
|
func (p *ResourceProvider) Refresh(
|
|
|
|
s *terraform.ResourceState) (*terraform.ResourceState, error) {
|
|
|
|
return s, nil
|
|
|
|
}
|
|
|
|
|
2014-06-03 23:26:31 +02:00
|
|
|
func (p *ResourceProvider) Resources() []terraform.ResourceType {
|
2014-06-10 20:34:14 +02:00
|
|
|
return []terraform.ResourceType{
|
|
|
|
terraform.ResourceType{
|
|
|
|
Name: "aws_instance",
|
|
|
|
},
|
|
|
|
}
|
2014-06-03 23:26:31 +02:00
|
|
|
}
|