本文整理汇总了Golang中github.com/crowdmob/goamz/aws.EnvAuth函数的典型用法代码示例。如果您正苦于以下问题:Golang EnvAuth函数的具体用法?Golang EnvAuth怎么用?Golang EnvAuth使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了EnvAuth函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。
示例1: ExampleV4Signer
func ExampleV4Signer() {
// Get auth from env vars
auth, err := aws.EnvAuth()
if err != nil {
fmt.Println(err)
}
// Create a signer with the auth, name of the service, and aws region
signer := aws.NewV4Signer(auth, "dynamodb", aws.USEast)
// Create a request
req, err := http.NewRequest("POST", aws.USEast.DynamoDBEndpoint, strings.NewReader("sample_request"))
if err != nil {
fmt.Println(err)
}
// Date or x-amz-date header is required to sign a request
req.Header.Add("Date", time.Now().UTC().Format(http.TimeFormat))
// Sign the request
signer.Sign(req)
// Issue signed request
http.DefaultClient.Do(req)
}
开发者ID:rvitale,项目名称:goamz,代码行数:25,代码来源:sign_test.go
示例2: TestGetItemRange
func TestGetItemRange(t *testing.T) {
if !*amazon {
return
}
if !*amazon {
t.Log("Amazon tests not enabled")
return
}
auth, err := aws.EnvAuth()
if err != nil {
t.Log(err)
t.FailNow()
}
server := dynamodb.Server{auth, aws.USEast}
primary := dynamodb.NewStringAttribute("uuid_type", "")
rangeK := dynamodb.NewNumericAttribute("time", "")
key := dynamodb.PrimaryKey{primary, rangeK}
table := server.NewTable("production_storyarc-accelerator-analytics",
key)
item, err := table.GetItem(&dynamodb.Key{HashKey: "aee5df14-6961-4baa-bad1-a1150576594f_MISSES", RangeKey: "1348187524"})
if err != nil {
t.Log(err)
t.FailNow()
}
fmt.Printf("Item : %s\n", item)
}
开发者ID:rvitale,项目名称:goamz,代码行数:34,代码来源:table_test.go
示例3: SetupDB
func (s *DynamoDBCommonSuite) SetupDB() {
if !*integration {
s.t.Skip("Integration tests are disabled")
}
s.t.Logf("Performing Integration tests on %s...", *provider)
var auth aws.Auth
if *provider == "amazon" {
s.t.Log("Using REAL AMAZON SERVER")
awsAuth, err := aws.EnvAuth()
if err != nil {
log.Fatal(err)
}
auth = awsAuth
} else {
auth = dummyAuth
}
s.c = &dynamodb.Client{
Auth: auth,
Region: dummyRegion[*provider],
}
// Ensure that the table does not exist
s.DeleteTable()
if s.CreateNewTable {
s.CreateTable()
}
}
开发者ID:nabeken,项目名称:goamz-dynamodb,代码行数:29,代码来源:dynamodb_test.go
示例4: TestBasicGroupRequest
func TestBasicGroupRequest(t *testing.T) {
var as *AutoScaling
awsAuth, err := aws.EnvAuth()
if err != nil {
mockTest = true
t.Log("Running mock tests as AWS environment variables are not set")
awsAuth := aws.Auth{AccessKey: "abc", SecretKey: "123"}
as = New(awsAuth, aws.Region{AutoScalingEndpoint: testServer.URL})
testServer.Start()
go testServer.WaitRequest()
testServer.Response(200, nil, astest.BasicGroupResponse)
} else {
as = New(awsAuth, aws.USWest2)
}
groupResp, err := as.DescribeAutoScalingGroups(nil)
if err != nil {
t.Fatal(err)
}
if len(groupResp.AutoScalingGroups) > 0 {
firstGroup := groupResp.AutoScalingGroups[0]
if len(firstGroup.AutoScalingGroupName) > 0 {
t.Logf("Found AutoScaling group %s\n",
firstGroup.AutoScalingGroupName)
}
}
testServer.Flush()
}
开发者ID:hayesgm,项目名称:goamz,代码行数:29,代码来源:autoscaling_test.go
示例5: TestGetItem
func TestGetItem(t *testing.T) {
if !*amazon {
t.Log("Amazon tests not enabled")
return
}
auth, err := aws.EnvAuth()
if err != nil {
t.Log(err)
t.FailNow()
}
server := dynamodb.Server{auth, aws.USEast}
primary := dynamodb.NewStringAttribute("domain", "")
key := dynamodb.PrimaryKey{primary, nil}
table := server.NewTable("production_storyarc-accelerator-sites",
key)
item, err := table.GetItem(&dynamodb.Key{HashKey: "ac-news.speedup.storytellerhq.com"})
if err != nil {
t.Log(err)
t.FailNow()
}
fmt.Printf("Item : %s\n", item)
}
开发者ID:rvitale,项目名称:goamz,代码行数:29,代码来源:table_test.go
示例6: TestListTables
func TestListTables(t *testing.T) {
if !*amazon {
t.Log("Amazon tests not enabled")
return
}
auth, err := aws.EnvAuth()
if err != nil {
t.Log(err)
t.FailNow()
}
server := dynamodb.Server{auth, aws.USEast}
tables, err := server.ListTables()
if err != nil {
t.Error(err.Error())
}
if len(tables) == 0 {
t.Log("Expected table to be returned")
t.FailNow()
}
fmt.Printf("tables %s\n", tables)
}
开发者ID:rvitale,项目名称:goamz,代码行数:29,代码来源:table_test.go
示例7: SetUp
func (s *AmazonServer) SetUp(c *C) {
auth, err := aws.EnvAuth()
if err != nil {
c.Fatal(err)
}
s.auth = auth
}
开发者ID:johnvilsack,项目名称:golang-stuff,代码行数:7,代码来源:elbi_test.go
示例8: SetUp
func (s *AmazonServer) SetUp(c *check.C) {
auth, err := aws.EnvAuth()
if err != nil {
c.Fatal(err.Error())
}
s.auth = auth
}
开发者ID:hayesgm,项目名称:goamz,代码行数:7,代码来源:ec2i_test.go
示例9: TestEnvAuthAlt
func (s *S) TestEnvAuthAlt(c *check.C) {
os.Clearenv()
os.Setenv("AWS_SECRET_KEY", "secret")
os.Setenv("AWS_ACCESS_KEY", "access")
auth, err := aws.EnvAuth()
c.Assert(err, check.IsNil)
c.Assert(auth, check.Equals, aws.Auth{SecretKey: "secret", AccessKey: "access"})
}
开发者ID:hayesgm,项目名称:goamz,代码行数:8,代码来源:aws_test.go
示例10: GetBucket
func GetBucket() *s3.Bucket {
auth, err := aws.EnvAuth()
if err != nil {
panic(err.Error())
}
s := s3.New(auth, aws.USEast)
return s.Bucket("filmapp-development")
}
开发者ID:kaiinui,项目名称:mofu,代码行数:9,代码来源:main.go
示例11: main
func main() {
auth, _ := aws.EnvAuth()
r53, _ := route53.NewRoute53(auth)
res, _ := r53.GetHostedZone(os.Args[0])
fmt.Printf("%#v\n", res)
res, _ = r53.ListHostedZones()
fmt.Printf("%#v\n", res)
}
开发者ID:sorah,项目名称:sandbox,代码行数:10,代码来源:test.go
示例12: SetUpSuite
func (s *LiveSuite) SetUpSuite(c *check.C) {
if !Amazon {
c.Skip("amazon tests not enabled (-amazon flag)")
}
auth, err := aws.EnvAuth()
if err != nil {
c.Fatal(err.Error())
}
s.auth = auth
}
开发者ID:hayesgm,项目名称:goamz,代码行数:10,代码来源:suite.go
示例13: SetUpSuite
func (s *SuiteI) SetUpSuite(c *check.C) {
if !*integration {
c.Skip("Integration tests not enabled (-i flag)")
}
auth, err := aws.EnvAuth()
if err != nil {
c.Fatal(err.Error())
}
s.auth = auth
}
开发者ID:hayesgm,项目名称:goamz,代码行数:10,代码来源:suite_test.go
示例14: main
func main() {
flag.Parse()
auth, err := aws.EnvAuth()
if err != nil {
log.Fatalln("Failed to recieve auth from env")
}
awsConnection := s3.New(
auth,
aws.USWest2,
)
bucket := awsConnection.Bucket(targetBucket)
info := gen.BuildInstanceInfo(&localInstanceFetcher{}, "basic_example", ".")
rotateCoordinator := gologging.NewRotateCoordinator(adjustedMaxLines, time.Hour*1)
logger, err := gologging.StartS3Logger(
rotateCoordinator,
info,
&stdoutNotifier{},
&uploader.S3UploaderBuilder{
Bucket: bucket,
KeyNameGenerator: &gen.EdgeKeyNameGenerator{info},
},
&stderrNotifier{},
5,
)
if err != nil {
log.Fatalf("Error building uploader: %s\n ", err)
}
i := 0
now := time.Now()
sigc := make(chan os.Signal, 1)
signal.Notify(sigc,
syscall.SIGHUP,
syscall.SIGINT,
syscall.SIGTERM,
syscall.SIGQUIT)
go func() {
<-sigc
logger.Close()
fmt.Printf("Produced %f rps\n", float64(i)/(float64(time.Now().Sub(now))/float64(time.Second)))
os.Exit(0)
}()
x := int(time.Second) / *rps
for ; i < MAX_LINES_PER_LOG*4; i++ {
// throttle - there is a better solution to this
defer func() {
if x := recover(); x != nil { // means we cuagh a signal
time.Sleep(120 * time.Second)
}
}()
time.Sleep(time.Duration(int(0.8 * float64(x))))
logger.Log("MOAR! %d", i)
}
logger.Close()
}
开发者ID:hyandell,项目名称:gologging,代码行数:55,代码来源:basic.go
示例15: setUpAuth
func setUpAuth(c *check.C) {
if !*amazon {
c.Skip("Test against amazon not enabled.")
}
if *local {
c.Log("Using local server")
dynamodb_region = aws.Region{DynamoDBEndpoint: "http://127.0.0.1:8000"}
dynamodb_auth = aws.Auth{AccessKey: "DUMMY_KEY", SecretKey: "DUMMY_SECRET"}
} else {
c.Log("Using REAL AMAZON SERVER")
dynamodb_region = aws.USWest2
auth, err := aws.EnvAuth()
if err != nil {
c.Fatal(err)
}
dynamodb_auth = auth
}
}
开发者ID:stevenbooru,项目名称:stevenbooru,代码行数:18,代码来源:dynamodb_test.go
示例16: GetAWSAuth
func GetAWSAuth() (aws.Auth, error) {
// First try to see if we have AWS environment variables and auth with that.
auth, err := aws.EnvAuth()
if err == nil {
// If we it worked lets use this
return auth, nil
}
// If ENV didn't work then lets try to get from IAM role
auth, err = aws.GetAuth("", "", "", time.Now().AddDate(1, 1, 1))
if err != nil {
return aws.Auth{}, err
}
return auth, nil
}
开发者ID:rem7,项目名称:s3sync,代码行数:18,代码来源:s3sync.go
示例17: main
func main() {
// This assumes you have ENV vars: AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY
auth, err := aws.EnvAuth()
if err != nil {
log.Fatal(err.Error())
}
// aws.USEast.DynamoDBEndpoint = "http://localhost:3300"
log.Printf("%+v", aws.USEast.DynamoDBEndpoint)
server := dynamodb.Server{auth, aws.USEast}
tables, err := server.ListTables()
if err != nil {
panic(err.Error())
}
if len(tables) == 0 {
panic("Expected table to be returned")
}
fmt.Printf("tables %+v\n", tables)
primary := dynamodb.NewStringAttribute("v", "")
key := dynamodb.PrimaryKey{primary, nil}
table := server.NewTable(tables[0], key)
fmt.Printf("tables %+v\n", table)
desc, err := table.DescribeTable()
if err != nil {
panic(err.Error())
}
if desc.TableSizeBytes > 0 {
log.Println("TableSizeBytes > 0", desc.TableSizeBytes)
}
if desc.ItemCount > 0 {
log.Println("ItemCount > 0", desc.ItemCount)
}
fmt.Printf("tables %+v\n", desc)
}
开发者ID:npaton,项目名称:dynamockdb,代码行数:42,代码来源:dynamock_client_testing.go
示例18: init
func init() {
var msgBodyTmplFile string
flag.StringVar(&queueName, "q", "", "Name of queue to fill")
flag.StringVar(®ion, "r", "", `Queue region (e.g., "us-east-1", "usw01")`)
flag.StringVar(&msgBodyTmpl, "b", defaultMsgTmpl, "Message body template")
flag.StringVar(&msgBodyTmplFile, "f", "", "Read message body template from file")
flag.IntVar(&count, "c", defaultCount, "Number of messages to insert")
flag.BoolVar(&serialMode, "serial", false, "Fill queue non-concurrently")
flag.Parse()
auth, err := aws.EnvAuth()
if err != nil {
fmt.Println(err)
os.Exit(1)
}
if queueName == "" || region == "" {
flag.Usage()
os.Exit(1)
}
if msgBodyTmpl == "" && msgBodyTmplFile == "" {
flag.Usage()
os.Exit(1)
}
if msgBodyTmplFile != "" {
body, err := ioutil.ReadFile(msgBodyTmplFile)
if err != nil {
fmt.Println(err)
os.Exit(1)
}
msgBodyTmpl = string(body)
}
region = normalizeRegion(region)
svc, err := sqs.NewFrom(auth.AccessKey, auth.SecretKey, region)
if err != nil {
fmt.Println("Error accessing SQS:", err)
os.Exit(1)
}
queue, err = svc.GetQueue(queueName)
if err != nil {
fmt.Printf("Error getting queue %s: %s\n", queueName, err)
os.Exit(1)
}
}
开发者ID:ianfoo,项目名称:aws-tools,代码行数:42,代码来源:sqsfill.go
示例19: TestCreateTable
func TestCreateTable(t *testing.T) {
if !*amazon {
t.Log("Amazon tests not enabled")
return
}
auth, err := aws.EnvAuth()
if err != nil {
t.Log(err)
t.FailNow()
}
server := dynamodb.Server{auth, aws.USEast}
attr1 := dynamodb.AttributeDefinitionT{"TestHashKey", "S"}
attr2 := dynamodb.AttributeDefinitionT{"TestRangeKey", "N"}
tableName := "MyTestTable"
keySch1 := dynamodb.KeySchemaT{"TestHashKey", "HASH"}
keySch2 := dynamodb.KeySchemaT{"TestRangeKey", "RANGE"}
provTPut := dynamodb.ProvisionedThroughputT{ReadCapacityUnits: 1, WriteCapacityUnits: 1}
tdesc := dynamodb.TableDescriptionT{
AttributeDefinitions: []dynamodb.AttributeDefinitionT{attr1, attr2},
TableName: tableName,
KeySchema: []dynamodb.KeySchemaT{keySch1, keySch2},
ProvisionedThroughput: provTPut,
}
status, err := server.CreateTable(tdesc)
if err != nil {
t.Error(err.Error())
t.FailNow()
}
fmt.Println(status)
}
开发者ID:noahcampbell,项目名称:goamz,代码行数:42,代码来源:table_test.go
示例20: LookupQueue
func (locator Locator) LookupQueue() (*sqs.Queue, error) {
// login to sqs, reading our credentials from the environment
auth, err := aws.EnvAuth()
if err != nil {
return nil, err
}
// connect to our sqs q
region, found := aws.Regions[locator.RegionName]
if !found {
return nil, errors.New(fmt.Sprintf("no such region, '%s'", locator.RegionName))
}
log.Printf("looking up sqs queue by name, '%s'\n", locator.QueueName)
sqsService := sqs.New(auth, region)
q, err := sqsService.GetQueue(locator.QueueName)
if err != nil {
return nil, err
}
log.Printf("%s: ok\n", locator.QueueName)
return q, nil
}
开发者ID:hayesgm,项目名称:queue,代码行数:22,代码来源:builder.go
注:本文中的github.com/crowdmob/goamz/aws.EnvAuth函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论