Esempio n. 1
0
// Create a new CloudWatch object for a given namespace
func NewCloudWatch(auth aws.Auth, region aws.ServiceInfo) (*CloudWatch, error) {
	service, err := aws.NewService(auth, region)
	if err != nil {
		return nil, err
	}
	return &CloudWatch{
		Service: service,
	}, nil
}
Esempio n. 2
0
File: rds.go Progetto: aalness/goamz
// New creates a new RDS Client.
func New(auth *aws.Auth, region aws.Region) (*RDS, error) {
	service, err := aws.NewService(auth, region.RDSEndpoint)
	if err != nil {
		return nil, err
	}
	return &RDS{
		Service: service,
	}, nil
}
Esempio n. 3
0
func getService(service, region string) (*aws.Service, error) {

	reg, err := GetAWSRegion(region)
	if err != nil {
		return nil, err
	}

	var endpoint string
	switch service {
	case "cf":
		endpoint = reg.CloudFormationEndpoint
	case "ec2":
		endpoint = reg.EC2Endpoint
	case "iam":
		endpoint = reg.IAMEndpoint
	case "rds":
		endpoint = reg.RDSEndpoint.Endpoint
	default:
		return nil, fmt.Errorf("Service %s not implemented", service)
	}

	// only get the creds from the env for now
	auth, err := aws.GetAuth("", "", "", time.Now())
	if err != nil {
		return nil, err
	}

	serviceInfo := aws.ServiceInfo{
		Endpoint: endpoint,
		Signer:   aws.V2Signature,
	}

	svc, err := aws.NewService(auth, serviceInfo)
	if err != nil {
		return nil, err
	}
	return svc, nil
}