当前位置: 首页>>代码示例>>Golang>>正文


Golang OpsWorks.CreateLayer方法代码示例

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


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

示例1: Create

func (lt *opsworksLayerType) Create(d *schema.ResourceData, client *opsworks.OpsWorks) error {

	req := &opsworks.CreateLayerInput{
		AutoAssignElasticIps:        aws.Bool(d.Get("auto_assign_elastic_ips").(bool)),
		AutoAssignPublicIps:         aws.Bool(d.Get("auto_assign_public_ips").(bool)),
		CustomInstanceProfileArn:    aws.String(d.Get("custom_instance_profile_arn").(string)),
		CustomRecipes:               lt.CustomRecipes(d),
		CustomSecurityGroupIds:      expandStringSet(d.Get("custom_security_group_ids").(*schema.Set)),
		EnableAutoHealing:           aws.Bool(d.Get("auto_healing").(bool)),
		InstallUpdatesOnBoot:        aws.Bool(d.Get("install_updates_on_boot").(bool)),
		LifecycleEventConfiguration: lt.LifecycleEventConfiguration(d),
		Name:                     aws.String(d.Get("name").(string)),
		Packages:                 expandStringSet(d.Get("system_packages").(*schema.Set)),
		Type:                     aws.String(lt.TypeName),
		StackId:                  aws.String(d.Get("stack_id").(string)),
		UseEbsOptimizedInstances: aws.Bool(d.Get("use_ebs_optimized_instances").(bool)),
		Attributes:               lt.AttributeMap(d),
		VolumeConfigurations:     lt.VolumeConfigurations(d),
	}

	if lt.CustomShortName {
		req.Shortname = aws.String(d.Get("short_name").(string))
	} else {
		req.Shortname = aws.String(lt.TypeName)
	}

	req.CustomJson = aws.String(d.Get("custom_json").(string))

	log.Printf("[DEBUG] Creating OpsWorks layer: %s", d.Id())

	resp, err := client.CreateLayer(req)
	if err != nil {
		return err
	}

	layerId := *resp.LayerId
	d.SetId(layerId)
	d.Set("id", layerId)

	loadBalancer := aws.String(d.Get("elastic_load_balancer").(string))
	if loadBalancer != nil && *loadBalancer != "" {
		log.Printf("[DEBUG] Attaching load balancer: %s", *loadBalancer)
		_, err := client.AttachElasticLoadBalancer(&opsworks.AttachElasticLoadBalancerInput{
			ElasticLoadBalancerName: loadBalancer,
			LayerId:                 &layerId,
		})
		if err != nil {
			return err
		}
	}

	return lt.Read(d, client)
}
开发者ID:Originate,项目名称:terraform,代码行数:53,代码来源:opsworks_layers.go


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