2014-08-20 00:40:48 +02:00
|
|
|
package aws
|
|
|
|
|
|
|
|
import (
|
|
|
|
"github.com/hashicorp/terraform/helper/schema"
|
2014-11-24 14:04:48 +01:00
|
|
|
"github.com/hashicorp/terraform/terraform"
|
2014-08-20 00:40:48 +02:00
|
|
|
)
|
|
|
|
|
2014-11-24 14:04:48 +01:00
|
|
|
// Provider returns a terraform.ResourceProvider.
|
|
|
|
func Provider() terraform.ResourceProvider {
|
2014-08-20 00:40:48 +02:00
|
|
|
// 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{
|
|
|
|
"access_key": &schema.Schema{
|
2014-09-10 06:46:50 +02:00
|
|
|
Type: schema.TypeString,
|
|
|
|
Required: true,
|
2015-01-16 18:22:09 +01:00
|
|
|
DefaultFunc: schema.EnvDefaultFunc("AWS_ACCESS_KEY", nil),
|
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,
|
2015-01-16 18:22:09 +01:00
|
|
|
DefaultFunc: schema.EnvDefaultFunc("AWS_SECRET_KEY", nil),
|
2014-09-29 22:30:28 +02:00
|
|
|
Description: descriptions["secret_key"],
|
2014-09-10 06:44:31 +02:00
|
|
|
},
|
2014-11-21 17:58:34 +01:00
|
|
|
|
|
|
|
"region": &schema.Schema{
|
|
|
|
Type: schema.TypeString,
|
|
|
|
Required: true,
|
2015-01-16 18:22:09 +01:00
|
|
|
DefaultFunc: schema.EnvDefaultFunc("AWS_REGION", nil),
|
2014-11-21 17:58:34 +01:00
|
|
|
Description: descriptions["region"],
|
|
|
|
InputDefault: "us-east-1",
|
|
|
|
},
|
2014-09-10 06:44:31 +02:00
|
|
|
},
|
|
|
|
|
2014-08-20 01:56:23 +02:00
|
|
|
ResourcesMap: map[string]*schema.Resource{
|
2014-11-24 14:04:48 +01:00
|
|
|
"aws_autoscaling_group": resourceAwsAutoscalingGroup(),
|
|
|
|
"aws_db_instance": resourceAwsDbInstance(),
|
|
|
|
"aws_db_parameter_group": resourceAwsDbParameterGroup(),
|
|
|
|
"aws_db_security_group": resourceAwsDbSecurityGroup(),
|
2014-11-21 17:58:34 +01:00
|
|
|
"aws_db_subnet_group": resourceAwsDbSubnetGroup(),
|
|
|
|
"aws_eip": resourceAwsEip(),
|
|
|
|
"aws_elb": resourceAwsElb(),
|
|
|
|
"aws_instance": resourceAwsInstance(),
|
|
|
|
"aws_internet_gateway": resourceAwsInternetGateway(),
|
2014-12-18 04:27:57 +01:00
|
|
|
"aws_key_pair": resourceAwsKeyPair(),
|
2014-11-21 17:58:34 +01:00
|
|
|
"aws_launch_configuration": resourceAwsLaunchConfiguration(),
|
2014-11-26 14:42:39 +01:00
|
|
|
"aws_network_acl": resourceAwsNetworkAcl(),
|
2014-11-21 17:58:34 +01:00
|
|
|
"aws_route53_record": resourceAwsRoute53Record(),
|
|
|
|
"aws_route53_zone": resourceAwsRoute53Zone(),
|
|
|
|
"aws_route_table": resourceAwsRouteTable(),
|
|
|
|
"aws_route_table_association": resourceAwsRouteTableAssociation(),
|
|
|
|
"aws_s3_bucket": resourceAwsS3Bucket(),
|
|
|
|
"aws_security_group": resourceAwsSecurityGroup(),
|
|
|
|
"aws_subnet": resourceAwsSubnet(),
|
|
|
|
"aws_vpc": resourceAwsVpc(),
|
2014-08-20 01:56:23 +02:00
|
|
|
},
|
2014-09-10 06:46:50 +02:00
|
|
|
|
2014-11-21 17:58:34 +01:00
|
|
|
ConfigureFunc: providerConfigure,
|
2014-09-10 06:46:50 +02:00
|
|
|
}
|
|
|
|
}
|
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.",
|
|
|
|
}
|
|
|
|
}
|
2014-11-21 17:58:34 +01:00
|
|
|
|
|
|
|
func providerConfigure(d *schema.ResourceData) (interface{}, error) {
|
|
|
|
config := Config{
|
|
|
|
AccessKey: d.Get("access_key").(string),
|
|
|
|
SecretKey: d.Get("secret_key").(string),
|
|
|
|
Region: d.Get("region").(string),
|
|
|
|
}
|
|
|
|
|
|
|
|
return config.Client()
|
|
|
|
}
|