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


Golang OpsWorks.DescribeElasticLoadBalancers方法代码示例

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


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

示例1: Read

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

	req := &opsworks.DescribeLayersInput{
		LayerIds: []*string{
			aws.String(d.Id()),
		},
	}

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

	resp, err := client.DescribeLayers(req)
	if err != nil {
		if awserr, ok := err.(awserr.Error); ok {
			if awserr.Code() == "ResourceNotFoundException" {
				d.SetId("")
				return nil
			}
		}
		return err
	}

	layer := resp.Layers[0]
	d.Set("id", layer.LayerId)
	d.Set("auto_assign_elastic_ips", layer.AutoAssignElasticIps)
	d.Set("auto_assign_public_ips", layer.AutoAssignPublicIps)
	d.Set("custom_instance_profile_arn", layer.CustomInstanceProfileArn)
	d.Set("custom_security_group_ids", flattenStringList(layer.CustomSecurityGroupIds))
	d.Set("auto_healing", layer.EnableAutoHealing)
	d.Set("install_updates_on_boot", layer.InstallUpdatesOnBoot)
	d.Set("name", layer.Name)
	d.Set("system_packages", flattenStringList(layer.Packages))
	d.Set("stack_id", layer.StackId)
	d.Set("use_ebs_optimized_instances", layer.UseEbsOptimizedInstances)

	if lt.CustomShortName {
		d.Set("short_name", layer.Shortname)
	}

	if v := layer.CustomJson; v == nil {
		if err := d.Set("custom_json", ""); err != nil {
			return err
		}
	} else if err := d.Set("custom_json", normalizeJson(*v)); err != nil {
		return err
	}

	lt.SetAttributeMap(d, layer.Attributes)
	lt.SetLifecycleEventConfiguration(d, layer.LifecycleEventConfiguration)
	lt.SetCustomRecipes(d, layer.CustomRecipes)
	lt.SetVolumeConfigurations(d, layer.VolumeConfigurations)

	/* get ELB */
	ebsRequest := &opsworks.DescribeElasticLoadBalancersInput{
		LayerIds: []*string{
			aws.String(d.Id()),
		},
	}
	loadBalancers, err := client.DescribeElasticLoadBalancers(ebsRequest)
	if err != nil {
		return err
	}

	if loadBalancers.ElasticLoadBalancers == nil || len(loadBalancers.ElasticLoadBalancers) == 0 {
		d.Set("elastic_load_balancer", "")
	} else {
		loadBalancer := loadBalancers.ElasticLoadBalancers[0]
		if loadBalancer != nil {
			d.Set("elastic_load_balancer", loadBalancer.ElasticLoadBalancerName)
		}
	}

	return nil
}
开发者ID:Originate,项目名称:terraform,代码行数:73,代码来源:opsworks_layers.go


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