• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Golang ec2.New函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Golang中github.com/crowdmob/goamz/ec2.New函数的典型用法代码示例。如果您正苦于以下问题:Golang New函数的具体用法?Golang New怎么用?Golang New使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了New函数的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Golang代码示例。

示例1: TestRegions

// Communicate with all EC2 endpoints to see if they are alive.
func (s *ClientTests) TestRegions(c *check.C) {
	name := sessionName("goamz-region-test")
	perms := []ec2.IPPerm{{
		Protocol:  "tcp",
		FromPort:  80,
		ToPort:    80,
		SourceIPs: []string{"127.0.0.1/32"},
	}}
	errs := make(chan error, len(allRegions))
	for _, region := range allRegions {
		go func(r aws.Region) {
			e := ec2.New(s.ec2.Auth, r)
			_, err := e.AuthorizeSecurityGroup(ec2.SecurityGroup{Name: name}, perms)
			errs <- err
		}(region)
	}
	for _ = range allRegions {
		err := <-errs
		if err != nil {
			ec2_err, ok := err.(*ec2.Error)
			if ok {
				c.Check(ec2_err.Code, check.Matches, "InvalidGroup.NotFound")
			} else {
				c.Errorf("Non-EC2 error: %s", err)
			}
		} else {
			c.Errorf("Test should have errored but it seems to have succeeded")
		}
	}
}
开发者ID:hayesgm,项目名称:goamz,代码行数:31,代码来源:ec2i_test.go


示例2: SetUpSuite

func (s *AmazonClientSuite) SetUpSuite(c *check.C) {
	if !testutil.Amazon {
		c.Skip("AmazonClientSuite tests not enabled")
	}
	s.srv.SetUp(c)
	s.ec2 = ec2.New(s.srv.auth, aws.USEast)
}
开发者ID:hayesgm,项目名称:goamz,代码行数:7,代码来源:ec2i_test.go


示例3: main

func main() {
	kingpin.Version("1.2.1")
	kingpin.Parse()

	sl, err := syslog.New(syslog.LOG_NOTICE|syslog.LOG_LOCAL0, "[varnish-purge-proxy]")
	defer sl.Close()
	if err != nil {
		log.Println("Error writing to syslog")
	} else {
		log.SetFlags(0)
		log.SetOutput(sl)
	}

	if len(*tags) == 0 {
		fmt.Println("No tags specified")
		return
	}

	// Set up access to ec2
	auth, err := aws.GetAuth("", "", "", time.Now().Add(time.Duration(24*365*time.Hour)))
	if err != nil {
		log.Println(err)
		return
	}
	ec2region := ec2.New(auth, region)

	go serveHTTP(*port, ec2region)

	select {}
}
开发者ID:madedotcom,项目名称:varnish-purge-proxy,代码行数:30,代码来源:varnish-purge-proxy.go


示例4: SetUpSuite

func (s *AmazonServerSuite) SetUpSuite(c *C) {
	if !testutil.Amazon {
		c.Skip("AmazonServerSuite tests not enabled")
	}
	s.srv.SetUp(c)
	s.ServerTests.ec2 = ec2.New(s.srv.auth, aws.USEast)
}
开发者ID:johnvilsack,项目名称:golang-stuff,代码行数:7,代码来源:ec2t_test.go


示例5: SetUpSuite

func (s *AmazonClientSuite) SetUpSuite(c *C) {
	if !*amazon {
		c.Skip("AmazonClientSuite tests not enabled")
	}
	s.srv.SetUp(c)
	s.elb = elb.New(s.srv.auth, aws.USEast)
	s.ec2 = ec2.New(s.srv.auth, aws.USEast)
}
开发者ID:johnvilsack,项目名称:golang-stuff,代码行数:8,代码来源:elbi_test.go


示例6: TestSignatureWithEndpointPath

func (s *S) TestSignatureWithEndpointPath(c *check.C) {
	ec2.FakeTime(true)
	defer ec2.FakeTime(false)

	testServer.Response(200, nil, RebootInstancesExample)

	// https://bugs.launchpad.net/goamz/+bug/1022749
	ec2 := ec2.New(s.ec2.Auth, aws.Region{EC2Endpoint: testServer.URL + "/services/Cloud"})

	_, err := ec2.RebootInstances("i-10a64379")
	c.Assert(err, check.IsNil)

	req := testServer.WaitRequest()
	c.Assert(req.Form["Signature"], check.DeepEquals, []string{"VVoC6Y6xfES+KvZo+789thP8+tye4F6fOKBiKmXk4S4="})
}
开发者ID:hayesgm,项目名称:goamz,代码行数:15,代码来源:ec2_test.go


示例7: TestSignatureWithEndpointPath

func (s *S) TestSignatureWithEndpointPath(c *gocheck.C) {
	ec2.FakeTime(true)
	defer ec2.FakeTime(false)

	testServer.Response(200, nil, RebootInstancesExample)

	// https://bugs.launchpad.net/goamz/+bug/1022749
	ec2 := ec2.New(s.ec2.Auth, aws.Region{EC2Endpoint: testServer.URL + "/services/Cloud"})

	_, err := ec2.RebootInstances("i-10a64379")
	c.Assert(err, gocheck.IsNil)

	req := testServer.WaitRequest()
	c.Assert(req.Form["Signature"], gocheck.DeepEquals, []string{"klxs+VwDa1EKHBsxlDYYN58wbP6An+RVdhETv1Fm/os="})
}
开发者ID:nabeken,项目名称:goamz,代码行数:15,代码来源:ec2_test.go


示例8: TestSignatureWithEndpointPath

func (s *S) TestSignatureWithEndpointPath(c *C) {
	ec2.FakeTime(true)
	defer ec2.FakeTime(false)

	testServer.Response(200, nil, RebootInstancesExample)

	// https://bugs.launchpad.net/goamz/+bug/1022749
	ec2 := ec2.New(s.ec2.Auth, aws.Region{EC2Endpoint: testServer.URL + "/services/Cloud"})

	_, err := ec2.RebootInstances("i-10a64379")
	c.Assert(err, IsNil)

	req := testServer.WaitRequest()
	c.Assert(req.Form["Signature"], DeepEquals, []string{"gdG/vEm+c6ehhhfkrJy3+wuVzw/rzKR42TYelMwti7M="})
}
开发者ID:johnvilsack,项目名称:golang-stuff,代码行数:15,代码来源:ec2_test.go


示例9: main

func main() {
	flag.Parse()

	auth, err := aws.GetAuth("", "", "", time.Now().Add(time.Hour))
	if err != nil {
		panic(err)
	}

	filter := ec2.NewFilter()
	filter.Add("instance-state-name", "running")
	filter.Add("tag:env", "prod")

	c := ec2.New(auth, aws.USEast)
	resp, err := c.DescribeInstances(nil, filter)
	if err != nil {
		log.Panicln(err)
	}
	rezzies := resp.Reservations

	for _, rv := range rezzies {
		for _, inst := range rv.Instances {
			if len(inst.BlockDevices) < 3 {
				for _, bd := range inst.BlockDevices {
					vid := bd.EBS.VolumeId
					name, err := getName(inst.Tags)
					log.Printf("Creating snapshot for: %s volume: %v\n", name, vid)
					if err != nil {
						log.Fatalf("Error getting name:", err)
					}

					stamp := time.Now().UTC().Format(TIME_FORMAT)
					snprsp, err := c.CreateSnapshot(vid, fmt.Sprintf("%s %s %s", name, *period, stamp))
					if err != nil {
						log.Printf("Failed to snap: %s, Error: %s\n", vid, err)
						break
					} else {
						log.Printf("Created snap: %s\n", snprsp.Id)
						t := ec2.Tag{Key: "inst_snap", Value: fmt.Sprintf("%s/%s", inst.InstanceId, *period)}
						tags = append(inst.Tags, t)
						wg.Add(1)
						go tagSnapshot(inst.InstanceId, snprsp.Id, tags, c)
					}
				}
			}
		}
	}
	wg.Wait()
}
开发者ID:reedobrien,项目名称:aws-go-utils,代码行数:48,代码来源:main.go


示例10: SetUpSuite

func (s *LocalServerSuite) SetUpSuite(c *gocheck.C) {
	s.srv.SetUp(c)
	s.ServerTests.ec2 = ec2.New(s.srv.auth, s.srv.region)
	s.clientTests.ec2 = ec2.New(s.srv.auth, s.srv.region)
}
开发者ID:nkts,项目名称:golang-devops-stuff,代码行数:5,代码来源:ec2t_test.go


示例11: SetUpSuite

func (s *S) SetUpSuite(c *check.C) {
	testServer.Start()
	auth := aws.Auth{AccessKey: "abc", SecretKey: "123"}
	s.ec2 = ec2.New(auth, aws.Region{EC2Endpoint: testServer.URL})
}
开发者ID:hayesgm,项目名称:goamz,代码行数:5,代码来源:ec2_test.go


示例12: getInstanceStatus

func getInstanceStatus(region string, auth *aws.Auth, instances []string, filter *ec2.Filter) ([]ec2.InstanceStatus, error) {
	endpoint := "https://ec2." + region + ".amazonaws.com"
	ec2 := ec2.New(*auth, aws.Region{EC2Endpoint: endpoint})
	resp, err := ec2.DescribeInstanceStatus(nil, filter)
	return resp.InstanceStatuses, err
}
开发者ID:jaibheem,项目名称:trash,代码行数:6,代码来源:retirement.go


示例13: SetUpSuite

func (s *S) SetUpSuite(c *C) {
	testServer.Start()
	auth := aws.Auth{"abc", "123"}
	s.ec2 = ec2.New(auth, aws.Region{EC2Endpoint: testServer.URL})
}
开发者ID:johnvilsack,项目名称:golang-stuff,代码行数:5,代码来源:ec2_test.go



注:本文中的github.com/crowdmob/goamz/ec2.New函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Golang ec2.NewFilter函数代码示例发布时间:2022-05-23
下一篇:
Golang dynamodb.Server类代码示例发布时间:2022-05-23
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap