github.com/koding/terraform@v0.6.4-0.20170608090606-5d7e0339779d/builtin/providers/aws/aws_sweeper_test.go (about)

     1  package aws
     2  
     3  import (
     4  	"fmt"
     5  	"os"
     6  	"testing"
     7  
     8  	"github.com/hashicorp/terraform/helper/resource"
     9  )
    10  
    11  func TestMain(m *testing.M) {
    12  	resource.TestMain(m)
    13  }
    14  
    15  // sharedClientForRegion returns a common AWSClient setup needed for the sweeper
    16  // functions for a given region
    17  func sharedClientForRegion(region string) (interface{}, error) {
    18  	if os.Getenv("AWS_ACCESS_KEY_ID") == "" {
    19  		return nil, fmt.Errorf("empty AWS_ACCESS_KEY_ID")
    20  	}
    21  
    22  	if os.Getenv("AWS_SECRET_ACCESS_KEY") == "" {
    23  		return nil, fmt.Errorf("empty AWS_SECRET_ACCESS_KEY")
    24  	}
    25  
    26  	conf := &Config{
    27  		Region: region,
    28  	}
    29  
    30  	// configures a default client for the region, using the above env vars
    31  	client, err := conf.Client()
    32  	if err != nil {
    33  		return nil, fmt.Errorf("error getting AWS client")
    34  	}
    35  
    36  	return client, nil
    37  }