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

Golang cloudformation.CreateStackInput类代码示例

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

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



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

示例1: ServiceCreate

func (p *AWSProvider) ServiceCreate(name, kind string, params map[string]string) (*structs.Service, error) {
	_, err := p.ServiceGet(name)
	if awsError(err) != "ValidationError" {
		return nil, fmt.Errorf("service named %s already exists", name)
	}

	s := &structs.Service{
		Name:       name,
		Parameters: cfParams(params),
		Type:       kind,
	}

	var req *cloudformation.CreateStackInput

	switch s.Type {
	case "syslog":
		req, err = createSyslog(s)
	}

	if err != nil {
		return s, err
	}

	// pass through service parameters as Cloudformation Parameters
	for key, value := range s.Parameters {
		req.Parameters = append(req.Parameters, &cloudformation.Parameter{
			ParameterKey:   aws.String(key),
			ParameterValue: aws.String(value),
		})
	}

	// tag the service
	tags := map[string]string{
		"Rack":    os.Getenv("RACK"),
		"System":  "convox",
		"Service": s.Type,
		"Type":    "service",
		"Name":    s.Name,
	}

	for key, value := range tags {
		req.Tags = append(req.Tags, &cloudformation.Tag{Key: aws.String(key), Value: aws.String(value)})
	}

	_, err = p.cloudformation().CreateStack(req)

	p.EventSend(&structs.Event{
		Action: "service:create",
		Data: map[string]string{
			"name": s.Name,
			"type": s.Type,
		},
	}, err)

	return s, err
}
开发者ID:cleblanc87,项目名称:rack,代码行数:56,代码来源:service.go


示例2: Create

func (s *Service) Create() error {
	var req *cloudformation.CreateStackInput
	var err error

	switch s.Type {
	case "papertrail":
		req, err = s.CreatePapertrail()
	case "webhook":
		req, err = s.CreateWebhook()
	case "s3":
		req, err = s.CreateS3()
	case "sns":
		req, err = s.CreateSNS()
	case "sqs":
		req, err = s.CreateSQS()
	default:
		req, err = s.CreateDatastore()
	}

	if err != nil {
		return err
	}

	// pass through service parameters as Cloudformation Parameters
	for key, value := range s.Parameters {
		req.Parameters = append(req.Parameters, &cloudformation.Parameter{
			ParameterKey:   aws.String(key),
			ParameterValue: aws.String(value),
		})
	}

	// tag the service
	tags := map[string]string{
		"Rack":    os.Getenv("RACK"),
		"System":  "convox",
		"Service": s.Type,
		"Type":    "service",
		"Name":    s.Name,
	}

	for key, value := range tags {
		req.Tags = append(req.Tags, &cloudformation.Tag{Key: aws.String(key), Value: aws.String(value)})
	}

	_, err = CloudFormation().CreateStack(req)

	if err != nil {
		NotifySuccess("service:create", map[string]string{
			"name": s.Name,
			"type": s.Type,
		})
	}

	return err
}
开发者ID:cleblanc87,项目名称:rack,代码行数:55,代码来源:service.go


示例3: resourceAwsCloudFormationStackCreate

func resourceAwsCloudFormationStackCreate(d *schema.ResourceData, meta interface{}) error {
	retryTimeout := int64(30)
	conn := meta.(*AWSClient).cfconn

	input := cloudformation.CreateStackInput{
		StackName: aws.String(d.Get("name").(string)),
	}
	if v, ok := d.GetOk("template_body"); ok {
		input.TemplateBody = aws.String(normalizeJson(v.(string)))
	}
	if v, ok := d.GetOk("template_url"); ok {
		input.TemplateURL = aws.String(v.(string))
	}
	if v, ok := d.GetOk("capabilities"); ok {
		input.Capabilities = expandStringList(v.(*schema.Set).List())
	}
	if v, ok := d.GetOk("disable_rollback"); ok {
		input.DisableRollback = aws.Bool(v.(bool))
	}
	if v, ok := d.GetOk("notification_arns"); ok {
		input.NotificationARNs = expandStringList(v.(*schema.Set).List())
	}
	if v, ok := d.GetOk("on_failure"); ok {
		input.OnFailure = aws.String(v.(string))
	}
	if v, ok := d.GetOk("parameters"); ok {
		input.Parameters = expandCloudFormationParameters(v.(map[string]interface{}))
	}
	if v, ok := d.GetOk("policy_body"); ok {
		input.StackPolicyBody = aws.String(normalizeJson(v.(string)))
	}
	if v, ok := d.GetOk("policy_url"); ok {
		input.StackPolicyURL = aws.String(v.(string))
	}
	if v, ok := d.GetOk("tags"); ok {
		input.Tags = expandCloudFormationTags(v.(map[string]interface{}))
	}
	if v, ok := d.GetOk("timeout_in_minutes"); ok {
		m := int64(v.(int))
		input.TimeoutInMinutes = aws.Int64(m)
		if m > retryTimeout {
			retryTimeout = m + 5
			log.Printf("[DEBUG] CloudFormation timeout: %d", retryTimeout)
		}
	}

	log.Printf("[DEBUG] Creating CloudFormation Stack: %s", input)
	resp, err := conn.CreateStack(&input)
	if err != nil {
		return fmt.Errorf("Creating CloudFormation stack failed: %s", err.Error())
	}

	d.SetId(*resp.StackId)

	wait := resource.StateChangeConf{
		Pending:    []string{"CREATE_IN_PROGRESS", "ROLLBACK_IN_PROGRESS", "ROLLBACK_COMPLETE"},
		Target:     []string{"CREATE_COMPLETE"},
		Timeout:    time.Duration(retryTimeout) * time.Minute,
		MinTimeout: 5 * time.Second,
		Refresh: func() (interface{}, string, error) {
			resp, err := conn.DescribeStacks(&cloudformation.DescribeStacksInput{
				StackName: aws.String(d.Get("name").(string)),
			})
			status := *resp.Stacks[0].StackStatus
			log.Printf("[DEBUG] Current CloudFormation stack status: %q", status)

			if status == "ROLLBACK_COMPLETE" {
				stack := resp.Stacks[0]
				failures, err := getCloudFormationFailures(stack.StackName, *stack.CreationTime, conn)
				if err != nil {
					return resp, "", fmt.Errorf(
						"Failed getting details about rollback: %q", err.Error())
				}

				return resp, "", fmt.Errorf("ROLLBACK_COMPLETE:\n%q", failures)
			}
			return resp, status, err
		},
	}

	_, err = wait.WaitForState()
	if err != nil {
		return err
	}

	log.Printf("[INFO] CloudFormation Stack %q created", d.Get("name").(string))

	return resourceAwsCloudFormationStackRead(d, meta)
}
开发者ID:RezaDKhan,项目名称:terraform,代码行数:89,代码来源:resource_aws_cloudformation_stack.go


示例4: resourceAwsCloudFormationStackCreate

func resourceAwsCloudFormationStackCreate(d *schema.ResourceData, meta interface{}) error {
	retryTimeout := int64(30)
	conn := meta.(*AWSClient).cfconn

	input := cloudformation.CreateStackInput{
		StackName: aws.String(d.Get("name").(string)),
	}
	if v, ok := d.GetOk("template_body"); ok {
		template, _ := normalizeJsonString(v.(string))
		input.TemplateBody = aws.String(template)
	}
	if v, ok := d.GetOk("template_url"); ok {
		input.TemplateURL = aws.String(v.(string))
	}
	if v, ok := d.GetOk("capabilities"); ok {
		input.Capabilities = expandStringList(v.(*schema.Set).List())
	}
	if v, ok := d.GetOk("disable_rollback"); ok {
		input.DisableRollback = aws.Bool(v.(bool))
	}
	if v, ok := d.GetOk("notification_arns"); ok {
		input.NotificationARNs = expandStringList(v.(*schema.Set).List())
	}
	if v, ok := d.GetOk("on_failure"); ok {
		input.OnFailure = aws.String(v.(string))
	}
	if v, ok := d.GetOk("parameters"); ok {
		input.Parameters = expandCloudFormationParameters(v.(map[string]interface{}))
	}
	if v, ok := d.GetOk("policy_body"); ok {
		policy, _ := normalizeJsonString(v.(string))
		input.StackPolicyBody = aws.String(policy)
	}
	if v, ok := d.GetOk("policy_url"); ok {
		input.StackPolicyURL = aws.String(v.(string))
	}
	if v, ok := d.GetOk("tags"); ok {
		input.Tags = expandCloudFormationTags(v.(map[string]interface{}))
	}
	if v, ok := d.GetOk("timeout_in_minutes"); ok {
		m := int64(v.(int))
		input.TimeoutInMinutes = aws.Int64(m)
		if m > retryTimeout {
			retryTimeout = m + 5
			log.Printf("[DEBUG] CloudFormation timeout: %d", retryTimeout)
		}
	}

	log.Printf("[DEBUG] Creating CloudFormation Stack: %s", input)
	resp, err := conn.CreateStack(&input)
	if err != nil {
		return fmt.Errorf("Creating CloudFormation stack failed: %s", err.Error())
	}

	d.SetId(*resp.StackId)
	var lastStatus string

	wait := resource.StateChangeConf{
		Pending: []string{
			"CREATE_IN_PROGRESS",
			"DELETE_IN_PROGRESS",
			"ROLLBACK_IN_PROGRESS",
		},
		Target: []string{
			"CREATE_COMPLETE",
			"CREATE_FAILED",
			"DELETE_COMPLETE",
			"DELETE_FAILED",
			"ROLLBACK_COMPLETE",
			"ROLLBACK_FAILED",
		},
		Timeout:    time.Duration(retryTimeout) * time.Minute,
		MinTimeout: 1 * time.Second,
		Refresh: func() (interface{}, string, error) {
			resp, err := conn.DescribeStacks(&cloudformation.DescribeStacksInput{
				StackName: aws.String(d.Id()),
			})
			if err != nil {
				log.Printf("[ERROR] Failed to describe stacks: %s", err)
				return nil, "", err
			}
			if len(resp.Stacks) == 0 {
				// This shouldn't happen unless CloudFormation is inconsistent
				// See https://github.com/hashicorp/terraform/issues/5487
				log.Printf("[WARN] CloudFormation stack %q not found.\nresponse: %q",
					d.Id(), resp)
				return resp, "", fmt.Errorf(
					"CloudFormation stack %q vanished unexpectedly during creation.\n"+
						"Unless you knowingly manually deleted the stack "+
						"please report this as bug at https://github.com/hashicorp/terraform/issues\n"+
						"along with the config & Terraform version & the details below:\n"+
						"Full API response: %s\n",
					d.Id(), resp)
			}

			status := *resp.Stacks[0].StackStatus
			lastStatus = status
			log.Printf("[DEBUG] Current CloudFormation stack status: %q", status)

			return resp, status, err
//.........这里部分代码省略.........
开发者ID:partamonov,项目名称:terraform,代码行数:101,代码来源:resource_aws_cloudformation_stack.go


示例5:

					describeStacksError = awserr.NewRequestFailure(awsError, 400, "request-id")
				})

				It("returns the proper error", func() {
					_, err := stack.Describe(stackName)
					Expect(err).To(HaveOccurred())
					Expect(err).To(Equal(ErrStackDoesNotExist))
				})
			})
		})
	})

	var _ = Describe("Create", func() {
		var (
			stackDetails StackDetails

			createStackInput *cloudformation.CreateStackInput
			createStackError error
		)

		BeforeEach(func() {
			stackDetails = StackDetails{
				StackName:   stackName,
				TemplateURL: "test-template-url",
			}

			createStackInput = &cloudformation.CreateStackInput{
				StackName:   aws.String(stackName),
				TemplateURL: aws.String("test-template-url"),
			}
			createStackError = nil
		})
开发者ID:cf-platform-eng,项目名称:cloudformation-broker,代码行数:32,代码来源:cf_stack_test.go


示例6: ServiceCreate

func (p *AWSProvider) ServiceCreate(name, kind string, params map[string]string) (*structs.Service, error) {
	_, err := p.ServiceGet(name)
	if awsError(err) != "ValidationError" {
		return nil, fmt.Errorf("service named %s already exists", name)
	}

	s := &structs.Service{
		Name:       name,
		Parameters: cfParams(params),
		Type:       kind,
	}
	s.Parameters["CustomTopic"] = customTopic
	s.Parameters["NotificationTopic"] = notificationTopic

	var req *cloudformation.CreateStackInput

	switch s.Type {
	case "memcached", "mysql", "postgres", "redis", "sqs":
		req, err = p.createService(s)
	case "fluentd":
		req, err = p.createServiceURL(s, "tcp")
	case "s3":
		if s.Parameters["Topic"] != "" {
			s.Parameters["Topic"] = fmt.Sprintf("%s-%s", p.Rack, s.Parameters["Topic"])
		}
		req, err = p.createService(s)
	case "sns":
		if s.Parameters["Queue"] != "" {
			s.Parameters["Queue"] = fmt.Sprintf("%s-%s", p.Rack, s.Parameters["Queue"])
		}
		req, err = p.createService(s)
	case "syslog":
		req, err = p.createServiceURL(s, "tcp", "tcp+tls", "udp")
	case "webhook":
		s.Parameters["Url"] = fmt.Sprintf("http://%s/sns?endpoint=%s", p.NotificationHost, url.QueryEscape(s.Parameters["Url"]))
		req, err = p.createServiceURL(s, "http", "https")
	default:
		err = fmt.Errorf("Invalid service type: %s", s.Type)
	}
	if err != nil {
		return s, err
	}

	keys := []string{}

	for key := range s.Parameters {
		keys = append(keys, key)
	}

	// sort keys for easier testing
	sort.Strings(keys)

	// pass through service parameters as Cloudformation Parameters
	for _, key := range keys {
		req.Parameters = append(req.Parameters, &cloudformation.Parameter{
			ParameterKey:   aws.String(key),
			ParameterValue: aws.String(s.Parameters[key]),
		})
	}

	// tag the service
	tags := map[string]string{
		"Name":    s.Name,
		"Rack":    p.Rack,
		"Service": s.Type,
		"System":  "convox",
		"Type":    "service",
	}
	tagKeys := []string{}

	for key := range tags {
		tagKeys = append(tagKeys, key)
	}

	// sort keys for easier testing
	sort.Strings(tagKeys)
	for _, key := range tagKeys {
		req.Tags = append(req.Tags, &cloudformation.Tag{Key: aws.String(key), Value: aws.String(tags[key])})
	}

	_, err = p.cloudformation().CreateStack(req)

	p.EventSend(&structs.Event{
		Action: "service:create",
		Data: map[string]string{
			"name": s.Name,
			"type": s.Type,
		},
	}, err)

	return s, err
}
开发者ID:gmelika,项目名称:rack,代码行数:92,代码来源:service.go



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
Golang cloudfront.New函数代码示例发布时间:2022-05-24
下一篇:
Golang cloudformation.CloudFormation类代码示例发布时间: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