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

Golang cloudformation.New函数代码示例

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

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



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

示例1: ExampleCloudFormation_ValidateTemplate

func ExampleCloudFormation_ValidateTemplate() {
	svc := cloudformation.New(nil)

	params := &cloudformation.ValidateTemplateInput{
		TemplateBody: aws.String("TemplateBody"),
		TemplateURL:  aws.String("TemplateURL"),
	}
	resp, err := svc.ValidateTemplate(params)

	if err != nil {
		if awsErr, ok := err.(awserr.Error); ok {
			// Generic AWS error with Code, Message, and original error (if any)
			fmt.Println(awsErr.Code(), awsErr.Message(), awsErr.OrigErr())
			if reqErr, ok := err.(awserr.RequestFailure); ok {
				// A service error occurred
				fmt.Println(reqErr.Code(), reqErr.Message(), reqErr.StatusCode(), reqErr.RequestID())
			}
		} else {
			// This case should never be hit, the SDK should always return an
			// error which satisfies the awserr.Error interface.
			fmt.Println(err.Error())
		}
	}

	// Pretty-print the response data.
	fmt.Println(awsutil.Prettify(resp))
}
开发者ID:strife25,项目名称:aws-sdk-go,代码行数:27,代码来源:examples_test.go


示例2: ExampleCloudFormation_ContinueUpdateRollback

func ExampleCloudFormation_ContinueUpdateRollback() {
	sess, err := session.NewSession()
	if err != nil {
		fmt.Println("failed to create session,", err)
		return
	}

	svc := cloudformation.New(sess)

	params := &cloudformation.ContinueUpdateRollbackInput{
		StackName: aws.String("StackNameOrId"), // Required
		ResourcesToSkip: []*string{
			aws.String("ResourceToSkip"), // Required
			// More values...
		},
		RoleARN: aws.String("RoleARN"),
	}
	resp, err := svc.ContinueUpdateRollback(params)

	if err != nil {
		// Print the error, cast err to awserr.Error to get the Code and
		// Message from an error.
		fmt.Println(err.Error())
		return
	}

	// Pretty-print the response data.
	fmt.Println(resp)
}
开发者ID:xibz,项目名称:aws-sdk-go,代码行数:29,代码来源:examples_test.go


示例3: ExampleCloudFormation_ListStacks

func ExampleCloudFormation_ListStacks() {
	svc := cloudformation.New(nil)

	params := &cloudformation.ListStacksInput{
		NextToken: aws.String("NextToken"),
		StackStatusFilter: []*string{
			aws.String("StackStatus"), // Required
			// More values...
		},
	}
	resp, err := svc.ListStacks(params)

	if err != nil {
		if awsErr, ok := err.(awserr.Error); ok {
			// Generic AWS error with Code, Message, and original error (if any)
			fmt.Println(awsErr.Code(), awsErr.Message(), awsErr.OrigErr())
			if reqErr, ok := err.(awserr.RequestFailure); ok {
				// A service error occurred
				fmt.Println(reqErr.Code(), reqErr.Message(), reqErr.StatusCode(), reqErr.RequestID())
			}
		} else {
			// This case should never be hit, the SDK should always return an
			// error which satisfies the awserr.Error interface.
			fmt.Println(err.Error())
		}
	}

	// Pretty-print the response data.
	fmt.Println(awsutil.Prettify(resp))
}
开发者ID:strife25,项目名称:aws-sdk-go,代码行数:30,代码来源:examples_test.go


示例4: ExampleCloudFormation_SignalResource

func ExampleCloudFormation_SignalResource() {
	svc := cloudformation.New(nil)

	params := &cloudformation.SignalResourceInput{
		LogicalResourceId: aws.String("LogicalResourceId"),      // Required
		StackName:         aws.String("StackNameOrId"),          // Required
		Status:            aws.String("ResourceSignalStatus"),   // Required
		UniqueId:          aws.String("ResourceSignalUniqueId"), // Required
	}
	resp, err := svc.SignalResource(params)

	if err != nil {
		if awsErr, ok := err.(awserr.Error); ok {
			// Generic AWS error with Code, Message, and original error (if any)
			fmt.Println(awsErr.Code(), awsErr.Message(), awsErr.OrigErr())
			if reqErr, ok := err.(awserr.RequestFailure); ok {
				// A service error occurred
				fmt.Println(reqErr.Code(), reqErr.Message(), reqErr.StatusCode(), reqErr.RequestID())
			}
		} else {
			// This case should never be hit, the SDK should always return an
			// error which satisfies the awserr.Error interface.
			fmt.Println(err.Error())
		}
	}

	// Pretty-print the response data.
	fmt.Println(awsutil.Prettify(resp))
}
开发者ID:strife25,项目名称:aws-sdk-go,代码行数:29,代码来源:examples_test.go


示例5: StackExists

// StackExists returns whether the given stackName or stackID currently exists
func StackExists(stackNameOrID string, awsSession *session.Session, logger *logrus.Logger) (bool, error) {
	cf := cloudformation.New(awsSession)

	describeStacksInput := &cloudformation.DescribeStacksInput{
		StackName: aws.String(stackNameOrID),
	}
	describeStacksOutput, err := cf.DescribeStacks(describeStacksInput)
	logger.WithFields(logrus.Fields{
		"DescribeStackOutput": describeStacksOutput,
	}).Debug("DescribeStackOutput results")

	exists := false
	if err != nil {
		logger.WithFields(logrus.Fields{
			"DescribeStackOutputError": err,
		}).Debug("DescribeStackOutput")

		// If the stack doesn't exist, then no worries
		if strings.Contains(err.Error(), "does not exist") {
			exists = false
		} else {
			return false, err
		}
	} else {
		exists = true
	}
	return exists, nil
}
开发者ID:mweagle,项目名称:Sparta,代码行数:29,代码来源:util.go


示例6: ExampleCloudFormation_EstimateTemplateCost

func ExampleCloudFormation_EstimateTemplateCost() {
	svc := cloudformation.New(nil)

	params := &cloudformation.EstimateTemplateCostInput{
		Parameters: []*cloudformation.Parameter{
			{ // Required
				ParameterKey:     aws.String("ParameterKey"),
				ParameterValue:   aws.String("ParameterValue"),
				UsePreviousValue: aws.Bool(true),
			},
			// More values...
		},
		TemplateBody: aws.String("TemplateBody"),
		TemplateURL:  aws.String("TemplateURL"),
	}
	resp, err := svc.EstimateTemplateCost(params)

	if err != nil {
		if awsErr, ok := err.(awserr.Error); ok {
			// Generic AWS error with Code, Message, and original error (if any)
			fmt.Println(awsErr.Code(), awsErr.Message(), awsErr.OrigErr())
			if reqErr, ok := err.(awserr.RequestFailure); ok {
				// A service error occurred
				fmt.Println(reqErr.Code(), reqErr.Message(), reqErr.StatusCode(), reqErr.RequestID())
			}
		} else {
			// This case should never be hit, the SDK should always return an
			// error which satisfies the awserr.Error interface.
			fmt.Println(err.Error())
		}
	}

	// Pretty-print the response data.
	fmt.Println(awsutil.Prettify(resp))
}
开发者ID:strife25,项目名称:aws-sdk-go,代码行数:35,代码来源:examples_test.go


示例7: ExampleCloudFormation_GetStackPolicy

func ExampleCloudFormation_GetStackPolicy() {
	svc := cloudformation.New(nil)

	params := &cloudformation.GetStackPolicyInput{
		StackName: aws.String("StackName"), // Required
	}
	resp, err := svc.GetStackPolicy(params)

	if err != nil {
		if awsErr, ok := err.(awserr.Error); ok {
			// Generic AWS Error with Code, Message, and original error (if any)
			fmt.Println(awsErr.Code(), awsErr.Message(), awsErr.OrigErr())
			if reqErr, ok := err.(awserr.RequestFailure); ok {
				// A service error occurred
				fmt.Println(reqErr.Code(), reqErr.Message(), reqErr.StatusCode(), reqErr.RequestID())
			}
		} else {
			// This case should never be hit, the SDK should always return an
			// error which satisfies the awserr.Error interface.
			fmt.Println(err.Error())
		}
	}

	// Pretty-print the response data.
	fmt.Println(awsutil.StringValue(resp))
}
开发者ID:jasonmoo,项目名称:aws-sdk-go,代码行数:26,代码来源:examples_test.go


示例8: StackEvents

// StackEvents returns the slice of cloudformation.StackEvents for the given stackID or stackName
func StackEvents(stackID string,
	eventFilterLowerBound time.Time,
	awsSession *session.Session) ([]*cloudformation.StackEvent, error) {
	cfService := cloudformation.New(awsSession)
	var events []*cloudformation.StackEvent

	nextToken := ""
	for {
		params := &cloudformation.DescribeStackEventsInput{
			StackName: aws.String(stackID),
		}
		if len(nextToken) > 0 {
			params.NextToken = aws.String(nextToken)
		}

		resp, err := cfService.DescribeStackEvents(params)
		if nil != err {
			return nil, err
		}
		for _, eachEvent := range resp.StackEvents {
			if eachEvent.Timestamp.After(eventFilterLowerBound) {
				events = append(events, eachEvent)
			}
		}
		if nil == resp.NextToken {
			break
		} else {
			nextToken = *resp.NextToken
		}
	}
	return events, nil
}
开发者ID:mweagle,项目名称:Sparta,代码行数:33,代码来源:util.go


示例9: New

func New(config Config) (*Client, error) {
	credentials := credentials.NewStaticCredentials(config.AccessKey, config.SecretKey, "")
	sdkConfig := &aws.Config{
		Credentials: credentials,
		Region:      aws.String(config.Region),
	}

	session := session.New(sdkConfig)

	if config.CloudFormationWaitTimeout == 0 {
		return nil, fmt.Errorf("AWS config CloudFormationWaitTimeout must be a positive timeout")
	}

	ec2EndpointConfig, err := config.getEndpoint("ec2")
	if err != nil {
		return nil, err
	}
	cloudformationEndpointConfig, err := config.getEndpoint("cloudformation")
	if err != nil {
		return nil, err
	}
	iamEndpointConfig, err := config.getEndpoint("iam")
	if err != nil {
		return nil, err
	}

	return &Client{
		EC2:            ec2.New(session, ec2EndpointConfig),
		CloudFormation: cloudformation.New(session, cloudformationEndpointConfig),
		IAM:            iam.New(session, iamEndpointConfig),
		Clock:          clockImpl{},
		CloudFormationWaitTimeout: config.CloudFormationWaitTimeout,
	}, nil
}
开发者ID:rosenhouse,项目名称:tubes,代码行数:34,代码来源:client.go


示例10: ActiveStacks

func ActiveStacks(region string) ([]string, error) {
	var stack_names []string

	svc := cloudformation.New(session.New(), &aws.Config{Region: aws.String(region)})

	params := &cloudformation.ListStacksInput{
		StackStatusFilter: []*string{
			aws.String("CREATE_COMPLETE"),
			aws.String("UPDATE_COMPLETE"),
			aws.String("UPDATE_ROLLBACK_COMPLETE"),
		},
	}

	resp, err := svc.ListStacks(params)

	if err != nil {
		return nil, err
	}

	for _, element := range resp.StackSummaries {
		stack_names = append(stack_names, *element.StackName)
	}

	sort.Strings(stack_names)

	return stack_names, nil
}
开发者ID:scottbrown,项目名称:aws-stack-tools,代码行数:27,代码来源:active_stacks.go


示例11: getInstanceInfo

func (d *Driver) getInstanceInfo() error {

	svc := cloudformation.New(session.New())

	params := &cloudformation.DescribeStacksInput{
		StackName: aws.String(d.MachineName),
	}
	resp, err := svc.DescribeStacks(params)

	if err != nil {
		return err
	}

	for _, element := range resp.Stacks[0].Outputs {
		outputV := *element.OutputValue
		if *element.OutputKey == "PrivateIp" {
			d.PrivateIPAddress = outputV
		}
		if *element.OutputKey == "InstanceID" {
			d.InstanceId = outputV
		}
		if *element.OutputKey == "IpAddress" {
			d.IPAddress = outputV
		}

	}

	return nil
}
开发者ID:waterytowers,项目名称:machine-cloudformation,代码行数:29,代码来源:amazoncf.go


示例12: stackAvailable

func (d *Driver) stackAvailable() (bool, error) {

	log.Debug("Checking if the stack is available......")

	svc := cloudformation.New(session.New())

	params := &cloudformation.DescribeStacksInput{
		StackName: aws.String(d.MachineName),
	}
	resp, err := svc.DescribeStacks(params)

	log.Debug(resp)

	if err != nil {
		return false, err
	}

	if *resp.Stacks[0].StackStatus == cloudformation.StackStatusRollbackInProgress || *resp.Stacks[0].StackStatus == cloudformation.StackStatusRollbackComplete {
		return false, errors.New("Stack Rollback Occured")
	}

	if *resp.Stacks[0].StackStatus == cloudformation.StackStatusCreateComplete {
		return true, nil
	} else {
		log.Debug("Stack Not Available Yet")
		return false, nil
	}
}
开发者ID:waterytowers,项目名称:machine-cloudformation,代码行数:28,代码来源:amazoncf.go


示例13: followStackEvents

func followStackEvents(c *cli.Context) {
	// Defaults
	cmdTimout := 600 * time.Second
	checkInteval := 15 * time.Second

	// Keep the last lot of stack events
	var preStackEvents []*cloudformation.StackEvent

	svc := cloudformation.New(&aws.Config{Region: aws.String("us-west-2")})

	params := &cloudformation.DescribeStackEventsInput{
		StackName: aws.String("test-stack"),
	}
	preStackEvents = periodicCommand(svc, params, preStackEvents)

	ticker := time.NewTicker(checkInteval)
	quit := make(chan struct{})
	go func() {
		for {
			select {
			case <-ticker.C:
				preStackEvents = periodicCommand(svc, params, preStackEvents)
			case <-quit:
				ticker.Stop()
				return
			}
		}
	}()

	time.Sleep(cmdTimout)
}
开发者ID:braidenjudd,项目名称:awsx,代码行数:31,代码来源:followStackEvents.go


示例14: Example

func Example() {
	// create a backend that implements the subset of the AWS API you need
	fakeBackend := &CloudFormationBackend{}

	// start a local HTTP server that dispatches requests to the backend
	fakeServer := httptest.NewServer(awsfaker.New(fakeBackend))

	// configure and use your client.  this might be a separate process,
	// with the endpoint override set via environment variable or other config
	client := cloudformation.New(session.New(&aws.Config{
		Credentials: credentials.NewStaticCredentials("some-access-key", "some-secret-key", ""),
		Region:      aws.String("some-region"),
		Endpoint:    aws.String(fakeServer.URL), // override the default AWS endpoint
	}))

	out, err := client.CreateStack(&cloudformation.CreateStackInput{
		StackName: aws.String("some-stack"),
	})
	if err != nil {
		panic(err)
	}
	fmt.Printf("[Client] CreateStack returned ID: %q\n", *out.StackId)

	_, err = client.CreateStack(&cloudformation.CreateStackInput{
		StackName: aws.String("some-stack"),
	})
	fmt.Printf("[Client] CreateStack returned error:\n %s\n", err)
	// Output:
	// [Server] CreateStack called on "some-stack"
	// [Client] CreateStack returned ID: "some-id"
	// [Server] CreateStack called on "some-stack"
	// [Client] CreateStack returned error:
	//  AlreadyExistsException: Stack [some-stack] already exists
	// 	status code: 400, request id:
}
开发者ID:rosenhouse,项目名称:awsfaker,代码行数:35,代码来源:example_test.go


示例15: ExampleCloudFormation_GetTemplate

func ExampleCloudFormation_GetTemplate() {
	sess, err := session.NewSession()
	if err != nil {
		fmt.Println("failed to create session,", err)
		return
	}

	svc := cloudformation.New(sess)

	params := &cloudformation.GetTemplateInput{
		ChangeSetName: aws.String("ChangeSetNameOrId"),
		StackName:     aws.String("StackName"),
		TemplateStage: aws.String("TemplateStage"),
	}
	resp, err := svc.GetTemplate(params)

	if err != nil {
		// Print the error, cast err to awserr.Error to get the Code and
		// Message from an error.
		fmt.Println(err.Error())
		return
	}

	// Pretty-print the response data.
	fmt.Println(resp)
}
开发者ID:xibz,项目名称:aws-sdk-go,代码行数:26,代码来源:examples_test.go


示例16: ExampleCloudFormation_EstimateTemplateCost

func ExampleCloudFormation_EstimateTemplateCost() {
	svc := cloudformation.New(nil)

	params := &cloudformation.EstimateTemplateCostInput{
		Parameters: []*cloudformation.Parameter{
			{ // Required
				ParameterKey:     aws.String("ParameterKey"),
				ParameterValue:   aws.String("ParameterValue"),
				UsePreviousValue: aws.Bool(true),
			},
			// More values...
		},
		TemplateBody: aws.String("TemplateBody"),
		TemplateURL:  aws.String("TemplateURL"),
	}
	resp, err := svc.EstimateTemplateCost(params)

	if err != nil {
		// Print the error, cast err to awserr.Error to get the Code and
		// Message from an error.
		fmt.Println(err.Error())
		return
	}

	// Pretty-print the response data.
	fmt.Println(resp)
}
开发者ID:ManifoldMike,项目名称:coreos-kubernetes,代码行数:27,代码来源:examples_test.go


示例17: main

func main() {
	flag.Parse()

	config, err := LoadConfig(configFilePath)
	if err != nil {
		log.Fatalf("Error loading config file: %s", err)
	}

	logger := buildLogger(config.LogLevel)

	awsConfig := aws.NewConfig().WithRegion(config.CloudFormationConfig.Region)
	awsSession := session.New(awsConfig)

	cfsvc := cloudformation.New(awsSession)
	stack := awscf.NewCloudFormationStack(cfsvc, logger)

	serviceBroker := cfbroker.New(config.CloudFormationConfig, stack, logger)

	credentials := brokerapi.BrokerCredentials{
		Username: config.Username,
		Password: config.Password,
	}

	brokerAPI := brokerapi.New(serviceBroker, logger, credentials)
	http.Handle("/", brokerAPI)

	fmt.Println("CloudFormation Service Broker started on port " + port + "...")
	http.ListenAndServe(":"+port, nil)
}
开发者ID:cf-platform-eng,项目名称:cloudformation-broker,代码行数:29,代码来源:main.go


示例18: ExampleCloudFormation_SignalResource

func ExampleCloudFormation_SignalResource() {
	sess, err := session.NewSession()
	if err != nil {
		fmt.Println("failed to create session,", err)
		return
	}

	svc := cloudformation.New(sess)

	params := &cloudformation.SignalResourceInput{
		LogicalResourceId: aws.String("LogicalResourceId"),      // Required
		StackName:         aws.String("StackNameOrId"),          // Required
		Status:            aws.String("ResourceSignalStatus"),   // Required
		UniqueId:          aws.String("ResourceSignalUniqueId"), // Required
	}
	resp, err := svc.SignalResource(params)

	if err != nil {
		// Print the error, cast err to awserr.Error to get the Code and
		// Message from an error.
		fmt.Println(err.Error())
		return
	}

	// Pretty-print the response data.
	fmt.Println(resp)
}
开发者ID:acquia,项目名称:fifo2kinesis,代码行数:27,代码来源:examples_test.go


示例19: ExampleCloudFormation_ValidateTemplate

func ExampleCloudFormation_ValidateTemplate() {
	sess, err := session.NewSession()
	if err != nil {
		fmt.Println("failed to create session,", err)
		return
	}

	svc := cloudformation.New(sess)

	params := &cloudformation.ValidateTemplateInput{
		TemplateBody: aws.String("TemplateBody"),
		TemplateURL:  aws.String("TemplateURL"),
	}
	resp, err := svc.ValidateTemplate(params)

	if err != nil {
		// Print the error, cast err to awserr.Error to get the Code and
		// Message from an error.
		fmt.Println(err.Error())
		return
	}

	// Pretty-print the response data.
	fmt.Println(resp)
}
开发者ID:acquia,项目名称:fifo2kinesis,代码行数:25,代码来源:examples_test.go


示例20: ExampleCloudFormation_ListStacks

func ExampleCloudFormation_ListStacks() {
	sess, err := session.NewSession()
	if err != nil {
		fmt.Println("failed to create session,", err)
		return
	}

	svc := cloudformation.New(sess)

	params := &cloudformation.ListStacksInput{
		NextToken: aws.String("NextToken"),
		StackStatusFilter: []*string{
			aws.String("StackStatus"), // Required
			// More values...
		},
	}
	resp, err := svc.ListStacks(params)

	if err != nil {
		// Print the error, cast err to awserr.Error to get the Code and
		// Message from an error.
		fmt.Println(err.Error())
		return
	}

	// Pretty-print the response data.
	fmt.Println(resp)
}
开发者ID:acquia,项目名称:fifo2kinesis,代码行数:28,代码来源:examples_test.go



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Golang cloudformation.CloudFormation类代码示例发布时间:2022-05-24
下一篇:
Golang autoscaling.UpdateAutoScalingGroupInput类代码示例发布时间:2022-05-24
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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