2014-08-20 00:40:48 +02:00
|
|
|
package aws
|
|
|
|
|
|
|
|
import (
|
2014-09-10 06:44:31 +02:00
|
|
|
"os"
|
|
|
|
|
2014-08-20 00:40:48 +02:00
|
|
|
"github.com/hashicorp/terraform/helper/schema"
|
|
|
|
)
|
|
|
|
|
|
|
|
// Provider returns a schema.Provider for AWS.
|
|
|
|
//
|
|
|
|
// NOTE: schema.Provider became available long after the AWS provider
|
|
|
|
// was started, so resources may not be converted to this new structure
|
|
|
|
// yet. This is a WIP. To assist with the migration, make sure any resources
|
|
|
|
// you migrate are acceptance tested, then perform the migration.
|
|
|
|
func Provider() *schema.Provider {
|
|
|
|
// TODO: Move the validation to this, requires conditional schemas
|
|
|
|
// TODO: Move the configuration to this, requires validation
|
|
|
|
|
|
|
|
return &schema.Provider{
|
2014-09-10 06:44:31 +02:00
|
|
|
Schema: map[string]*schema.Schema{
|
|
|
|
"region": &schema.Schema{
|
2014-09-29 23:00:35 +02:00
|
|
|
Type: schema.TypeString,
|
|
|
|
Required: true,
|
|
|
|
DefaultFunc: envDefaultFunc("AWS_REGION"),
|
|
|
|
Description: descriptions["region"],
|
|
|
|
InputDefault: "us-east-1",
|
2014-09-10 06:44:31 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
"access_key": &schema.Schema{
|
2014-09-10 06:46:50 +02:00
|
|
|
Type: schema.TypeString,
|
|
|
|
Required: true,
|
|
|
|
DefaultFunc: envDefaultFunc("AWS_ACCESS_KEY"),
|
2014-09-29 22:30:28 +02:00
|
|
|
Description: descriptions["access_key"],
|
2014-09-10 06:44:31 +02:00
|
|
|
},
|
|
|
|
|
|
|
|
"secret_key": &schema.Schema{
|
2014-09-10 06:46:50 +02:00
|
|
|
Type: schema.TypeString,
|
|
|
|
Required: true,
|
|
|
|
DefaultFunc: envDefaultFunc("AWS_SECRET_KEY"),
|
2014-09-29 22:30:28 +02:00
|
|
|
Description: descriptions["secret_key"],
|
2014-09-10 06:44:31 +02:00
|
|
|
},
|
|
|
|
},
|
|
|
|
|
2014-08-20 01:56:23 +02:00
|
|
|
ResourcesMap: map[string]*schema.Resource{
|
2014-10-10 23:50:23 +02:00
|
|
|
"aws_autoscaling_group": resourceAwsAutoscalingGroup(),
|
|
|
|
"aws_eip": resourceAwsEip(),
|
|
|
|
"aws_elb": resourceAwsElb(),
|
|
|
|
"aws_instance": resourceAwsInstance(),
|
|
|
|
"aws_launch_configuration": resourceAwsLaunchConfiguration(),
|
|
|
|
"aws_security_group": resourceAwsSecurityGroup(),
|
|
|
|
"aws_db_subnet_group": resourceAwsDbSubnetGroup(),
|
|
|
|
"aws_vpc": resourceAwsVpc(),
|
2014-10-22 23:22:30 +02:00
|
|
|
"aws_db_parameter_group": resourceAwsDbParameterGroup(),
|
2014-11-02 21:30:33 +01:00
|
|
|
"aws_subnet": resourceAwsSubnet(),
|
2014-08-20 01:56:23 +02:00
|
|
|
},
|
2014-08-20 00:40:48 +02:00
|
|
|
}
|
|
|
|
}
|
2014-09-10 06:46:50 +02:00
|
|
|
|
|
|
|
func envDefaultFunc(k string) schema.SchemaDefaultFunc {
|
|
|
|
return func() (interface{}, error) {
|
|
|
|
if v := os.Getenv(k); v != "" {
|
|
|
|
return v, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
}
|
2014-09-29 22:30:28 +02:00
|
|
|
|
|
|
|
var descriptions map[string]string
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
descriptions = map[string]string{
|
|
|
|
"region": "The region where AWS operations will take place. Examples\n" +
|
|
|
|
"are us-east-1, us-west-2, etc.",
|
|
|
|
|
|
|
|
"access_key": "The access key for API operations. You can retrieve this\n" +
|
|
|
|
"from the 'Security & Credentials' section of the AWS console.",
|
|
|
|
|
|
|
|
"secret_key": "The secret key for API operations. You can retrieve this\n" +
|
|
|
|
"from the 'Security & Credentials' section of the AWS console.",
|
|
|
|
}
|
|
|
|
}
|