providers/aws: Vet aws

This commit is contained in:
clint shryock 2015-12-01 09:31:20 -06:00
parent 3cbe014e31
commit 4a5847f9ea
11 changed files with 19 additions and 28 deletions

View File

@ -36,7 +36,6 @@ func testAccCheckLifecycleHookExists(n string, hook *autoscaling.LifecycleHook)
return func(s *terraform.State) error { return func(s *terraform.State) error {
rs, ok := s.RootModule().Resources[n] rs, ok := s.RootModule().Resources[n]
if !ok { if !ok {
rs = rs
return fmt.Errorf("Not found: %s", n) return fmt.Errorf("Not found: %s", n)
} }

View File

@ -144,7 +144,7 @@ func testAccCheckASGNDestroy(s *terraform.State) error {
} }
if len(resp.NotificationConfigurations) != 0 { if len(resp.NotificationConfigurations) != 0 {
fmt.Errorf("Error finding notification descriptions") return fmt.Errorf("Error finding notification descriptions")
} }
} }

View File

@ -34,7 +34,6 @@ func testAccCheckScalingPolicyExists(n string, policy *autoscaling.ScalingPolicy
return func(s *terraform.State) error { return func(s *terraform.State) error {
rs, ok := s.RootModule().Resources[n] rs, ok := s.RootModule().Resources[n]
if !ok { if !ok {
rs = rs
return fmt.Errorf("Not found: %s", n) return fmt.Errorf("Not found: %s", n)
} }

View File

@ -68,7 +68,6 @@ func testAccCheckCloudFormationStackExists(n string, stack *cloudformation.Stack
return func(s *terraform.State) error { return func(s *terraform.State) error {
rs, ok := s.RootModule().Resources[n] rs, ok := s.RootModule().Resources[n]
if !ok { if !ok {
rs = rs
return fmt.Errorf("Not found: %s", n) return fmt.Errorf("Not found: %s", n)
} }

View File

@ -19,8 +19,6 @@ func resourceAwsInstanceMigrateState(
default: default:
return is, fmt.Errorf("Unexpected schema version: %d", v) return is, fmt.Errorf("Unexpected schema version: %d", v)
} }
return is, nil
} }
func migrateStateV0toV1(is *terraform.InstanceState) (*terraform.InstanceState, error) { func migrateStateV0toV1(is *terraform.InstanceState) (*terraform.InstanceState, error) {

View File

@ -112,22 +112,22 @@ func TestAccAWSInstance_blockDevices(t *testing.T) {
// Check if the root block device exists. // Check if the root block device exists.
if _, ok := blockDevices["/dev/sda1"]; !ok { if _, ok := blockDevices["/dev/sda1"]; !ok {
fmt.Errorf("block device doesn't exist: /dev/sda1") return fmt.Errorf("block device doesn't exist: /dev/sda1")
} }
// Check if the secondary block device exists. // Check if the secondary block device exists.
if _, ok := blockDevices["/dev/sdb"]; !ok { if _, ok := blockDevices["/dev/sdb"]; !ok {
fmt.Errorf("block device doesn't exist: /dev/sdb") return fmt.Errorf("block device doesn't exist: /dev/sdb")
} }
// Check if the third block device exists. // Check if the third block device exists.
if _, ok := blockDevices["/dev/sdc"]; !ok { if _, ok := blockDevices["/dev/sdc"]; !ok {
fmt.Errorf("block device doesn't exist: /dev/sdc") return fmt.Errorf("block device doesn't exist: /dev/sdc")
} }
// Check if the encrypted block device exists // Check if the encrypted block device exists
if _, ok := blockDevices["/dev/sdd"]; !ok { if _, ok := blockDevices["/dev/sdd"]; !ok {
fmt.Errorf("block device doesn't exist: /dev/sdd") return fmt.Errorf("block device doesn't exist: /dev/sdd")
} }
return nil return nil

View File

@ -17,8 +17,6 @@ func resourceAwsKeyPairMigrateState(
default: default:
return is, fmt.Errorf("Unexpected schema version: %d", v) return is, fmt.Errorf("Unexpected schema version: %d", v)
} }
return is, nil
} }
func migrateKeyPairStateV0toV1(is *terraform.InstanceState) (*terraform.InstanceState, error) { func migrateKeyPairStateV0toV1(is *terraform.InstanceState) (*terraform.InstanceState, error) {

View File

@ -162,17 +162,17 @@ func testAccCheckAWSLaunchConfigurationAttributes(conf *autoscaling.LaunchConfig
// Check if the root block device exists. // Check if the root block device exists.
if _, ok := blockDevices["/dev/sda1"]; !ok { if _, ok := blockDevices["/dev/sda1"]; !ok {
fmt.Errorf("block device doesn't exist: /dev/sda1") return fmt.Errorf("block device doesn't exist: /dev/sda1")
} }
// Check if the secondary block device exists. // Check if the secondary block device exists.
if _, ok := blockDevices["/dev/sdb"]; !ok { if _, ok := blockDevices["/dev/sdb"]; !ok {
fmt.Errorf("block device doesn't exist: /dev/sdb") return fmt.Errorf("block device doesn't exist: /dev/sdb")
} }
// Check if the third block device exists. // Check if the third block device exists.
if _, ok := blockDevices["/dev/sdc"]; !ok { if _, ok := blockDevices["/dev/sdc"]; !ok {
fmt.Errorf("block device doesn't exist: /dev/sdc") return fmt.Errorf("block device doesn't exist: /dev/sdc")
} }
// Check if the secondary block device exists. // Check if the secondary block device exists.

View File

@ -1,6 +1,7 @@
package aws package aws
import ( import (
"errors"
"fmt" "fmt"
"log" "log"
@ -10,6 +11,11 @@ import (
"github.com/hashicorp/terraform/helper/schema" "github.com/hashicorp/terraform/helper/schema"
) )
// How long to sleep if a limit-exceeded event happens
var routeTargetValidationError = errors.New("Error: more than 1 target specified. Only 1 of gateway_id" +
"instance_id, network_interface_id, route_table_id or" +
"vpc_peering_connection_id is allowed.")
// AWS Route resource Schema declaration // AWS Route resource Schema declaration
func resourceAwsRoute() *schema.Resource { func resourceAwsRoute() *schema.Resource {
return &schema.Resource{ return &schema.Resource{
@ -94,9 +100,7 @@ func resourceAwsRouteCreate(d *schema.ResourceData, meta interface{}) error {
} }
if numTargets > 1 { if numTargets > 1 {
fmt.Errorf("Error: more than 1 target specified. Only 1 of gateway_id" + return routeTargetValidationError
"instance_id, network_interface_id, route_table_id or" +
"vpc_peering_connection_id is allowed.")
} }
createOpts := &ec2.CreateRouteInput{} createOpts := &ec2.CreateRouteInput{}
@ -127,7 +131,7 @@ func resourceAwsRouteCreate(d *schema.ResourceData, meta interface{}) error {
VpcPeeringConnectionId: aws.String(d.Get("vpc_peering_connection_id").(string)), VpcPeeringConnectionId: aws.String(d.Get("vpc_peering_connection_id").(string)),
} }
default: default:
fmt.Errorf("Error: invalid target type specified.") return fmt.Errorf("Error: invalid target type specified.")
} }
log.Printf("[DEBUG] Route create config: %s", createOpts) log.Printf("[DEBUG] Route create config: %s", createOpts)
@ -139,7 +143,7 @@ func resourceAwsRouteCreate(d *schema.ResourceData, meta interface{}) error {
route, err := findResourceRoute(conn, d.Get("route_table_id").(string), d.Get("destination_cidr_block").(string)) route, err := findResourceRoute(conn, d.Get("route_table_id").(string), d.Get("destination_cidr_block").(string))
if err != nil { if err != nil {
fmt.Errorf("Error: %s", err) return err
} }
d.SetId(routeIDHash(d, route)) d.SetId(routeIDHash(d, route))
@ -187,9 +191,7 @@ func resourceAwsRouteUpdate(d *schema.ResourceData, meta interface{}) error {
} }
if numTargets > 1 { if numTargets > 1 {
fmt.Errorf("Error: more than 1 target specified. Only 1 of gateway_id" + return routeTargetValidationError
"instance_id, network_interface_id, route_table_id or" +
"vpc_peering_connection_id is allowed.")
} }
// Formulate ReplaceRouteInput based on the target type // Formulate ReplaceRouteInput based on the target type
@ -221,7 +223,7 @@ func resourceAwsRouteUpdate(d *schema.ResourceData, meta interface{}) error {
VpcPeeringConnectionId: aws.String(d.Get("vpc_peering_connection_id").(string)), VpcPeeringConnectionId: aws.String(d.Get("vpc_peering_connection_id").(string)),
} }
default: default:
fmt.Errorf("Error: invalid target type specified.") return fmt.Errorf("Error: invalid target type specified.")
} }
log.Printf("[DEBUG] Route replace config: %s", replaceOpts) log.Printf("[DEBUG] Route replace config: %s", replaceOpts)

View File

@ -26,8 +26,6 @@ func resourceAwsSecurityGroupRuleMigrateState(
default: default:
return is, fmt.Errorf("Unexpected schema version: %d", v) return is, fmt.Errorf("Unexpected schema version: %d", v)
} }
return is, nil
} }
func migrateSGRuleStateV0toV1(is *terraform.InstanceState) (*terraform.InstanceState, error) { func migrateSGRuleStateV0toV1(is *terraform.InstanceState) (*terraform.InstanceState, error) {

View File

@ -223,8 +223,6 @@ func resourceAwsVpcDhcpOptionsDelete(d *schema.ResourceData, meta interface{}) e
// Any other error, we want to quit the retry loop immediately // Any other error, we want to quit the retry loop immediately
return resource.RetryError{Err: err} return resource.RetryError{Err: err}
} }
return nil
}) })
} }