Exemplo n.º 1
0
func TestCopySnapshotPresignedURL(t *testing.T) {
	svc := ec2.New(unit.Session, &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))
	u, _ := url.QueryUnescape(q.Get("PresignedUrl"))
	assert.Equal(t, "us-west-2", q.Get("DestinationRegion"))
	assert.Equal(t, "us-west-1", q.Get("SourceRegion"))
	assert.Regexp(t, `^https://ec2\.us-west-1\.amazonaws\.com/.+&DestinationRegion=us-west-2`, u)
}
Exemplo n.º 2
0
func EC2() *ec2.EC2 {
	return ec2.New(awsConfig())
}
Exemplo n.º 3
0
func EC2() *ec2.EC2 {
	return ec2.New(session.New(), awsConfig())
}
Exemplo n.º 4
0
Arquivo: aws.go Projeto: kuenzaa/rack
func EC2(req Request) *ec2.EC2 {
	return ec2.New(session.New(), &aws.Config{
		Credentials: Credentials(&req),
		Region:      Region(&req),
	})
}
Exemplo n.º 5
0
Arquivo: aws.go Projeto: soulware/rack
func (p *AWSProvider) ec2() *ec2.EC2 {
	return ec2.New(session.New(), p.config())
}