コード例 #1
0
ファイル: aws.go プロジェクト: chancez/mantle
func NewAWSCluster(conf AWSOptions) (Cluster, error) {
	api := ec2.New(aws.NewConfig().WithCredentials(credentials.NewEnvCredentials()))

	agent, err := network.NewSSHAgent(&net.Dialer{})
	if err != nil {
		return nil, err
	}

	ac := &awsCluster{
		api:   api,
		conf:  conf,
		agent: agent,
		machs: make(map[string]*awsMachine),
	}

	return ac, nil
}
コード例 #2
0
ファイル: aws.go プロジェクト: carriercomm/mantle
// NewAWSCluster creates an instance of a Cluster suitable for spawning
// instances on Amazon Web Services' Elastic Compute platform.
//
// NewAWSCluster will consume the environment variables $AWS_REGION,
// $AWS_ACCESS_KEY_ID, and $AWS_SECRET_ACCESS_KEY to determine the region to
// spawn instances in and the credentials to use to authenticate.
func NewAWSCluster(conf AWSOptions) (Cluster, error) {
	cfg := aws.NewConfig().WithCredentials(credentials.NewEnvCredentials())
	api := ec2.New(session.New(cfg))

	bc, err := newBaseCluster()
	if err != nil {
		return nil, err
	}

	ac := &awsCluster{
		baseCluster: bc,
		api:         api,
		conf:        conf,
	}

	return ac, nil
}
コード例 #3
0
ファイル: customizations_test.go プロジェクト: chancez/mantle
func TestCopySnapshotPresignedURL(t *testing.T) {
	svc := ec2.New(&aws.Config{Region: aws.String("us-west-2")})

	assert.NotPanics(t, func() {
		// Doesn't panic on nil input
		req, _ := svc.CopySnapshotRequest(nil)
		req.Sign()
	})

	req, _ := svc.CopySnapshotRequest(&ec2.CopySnapshotInput{
		SourceRegion:     aws.String("us-west-1"),
		SourceSnapshotId: aws.String("snap-id"),
	})
	req.Sign()

	b, _ := ioutil.ReadAll(req.HTTPRequest.Body)
	q, _ := url.ParseQuery(string(b))
	url, _ := url.QueryUnescape(q.Get("PresignedUrl"))
	assert.Equal(t, "us-west-2", q.Get("DestinationRegion"))
	assert.Regexp(t, `^https://ec2\.us-west-1\.amazon.+&DestinationRegion=us-west-2`, url)
}
コード例 #4
0
ファイル: interface_test.go プロジェクト: chancez/mantle
func TestInterface(t *testing.T) {
	assert.Implements(t, (*ec2iface.EC2API)(nil), ec2.New(nil))
}