// GetAWSAutoScalingLaunchConfigurationWithName retrieves all AWSAutoScalingLaunchConfiguration items from an AWS CloudFormation template
// whose logical ID matches the provided name. Returns an error if not found.
19544
func (t *Template) GetAWSAutoScalingLaunchConfigurationWithName(name string) (*resources.AWSAutoScalingLaunchConfiguration, error) {
	if untyped, ok := t.Resources[name]; ok {
		switch resource := untyped.(type) {
		case *resources.AWSAutoScalingLaunchConfiguration:
			return resource, nil
		}
	}
	return nil, fmt.Errorf("resource %q of type AWSAutoScalingLaunchConfiguration not found", name)
}
141437
func (t *Template) GetAWSGameLiftBuildWithName(name string) (*resources.AWSGameLiftBuild, error) {
	if untyped, ok := t.Resources[name]; ok {
		switch resource := untyped.(type) {
		case *resources.AWSGameLiftBuild:
			return resource, nil
		}
	}
	return nil, fmt.Errorf("resource %q of type AWSGameLiftBuild not found", name)
}
537726
func (t *Template) GetAWSIoTAnalyticsPipelineWithName(name string) (*resources.AWSIoTAnalyticsPipeline, error) {
	if untyped, ok := t.Resources[name]; ok {
		switch resource := untyped.(type) {
		case *resources.AWSIoTAnalyticsPipeline:
			return resource, nil
		}
	}
	return nil, fmt.Errorf("resource %q of type AWSIoTAnalyticsPipeline not found", name)
}
57075
func (t *Template) GetAWSAutoScalingAutoScalingGroupWithName(name string) (*resources.AWSAutoScalingAutoScalingGroup, error) {
	if untyped, ok := t.Resources[name]; ok {
		switch resource := untyped.(type) {
		case *resources.AWSAutoScalingAutoScalingGroup:
			return resource, nil
		}
	}
	return nil, fmt.Errorf("resource %q of type AWSAutoScalingAutoScalingGroup not found", name)
}
952947
func (t *Template) GetAWSElasticLoadBalancingV2TargetGroupWithName(name string) (*resources.AWSElasticLoadBalancingV2TargetGroup, error) {
	if untyped, ok := t.Resources[name]; ok {
		switch resource := untyped.(type) {
		case *resources.AWSElasticLoadBalancingV2TargetGroup:
			return resource, nil
		}
	}
	return nil, fmt.Errorf("resource %q of type AWSElasticLoadBalancingV2TargetGroup not found", name)
}
893341
func (s *InstanceDetails) SetLaunchConfigurationName(v string) *InstanceDetails {
	s.LaunchConfigurationName = &v
	return s
}
20464
func (t *Template) GetAWSApplicationAutoScalingScalableTargetWithName(name string) (*resources.AWSApplicationAutoScalingScalableTarget, error) {
	if untyped, ok := t.Resources[name]; ok {
		switch resource := untyped.(type) {
		case *resources.AWSApplicationAutoScalingScalableTarget:
			return resource, nil
		}
	}
	return nil, fmt.Errorf("resource %q of type AWSApplicationAutoScalingScalableTarget not found", name)
}
840976
func (t *Template) GetAWSKinesisAnalyticsV2ApplicationWithName(name string) (*resources.AWSKinesisAnalyticsV2Application, error) {
	if untyped, ok := t.Resources[name]; ok {
		switch resource := untyped.(type) {
		case *resources.AWSKinesisAnalyticsV2Application:
			return resource, nil
		}
	}
	return nil, fmt.Errorf("resource %q of type AWSKinesisAnalyticsV2Application not found", name)
}
608583
func FindAutoScalingLaunchTemplateConfigurations(cloud fi.Cloud, securityGroups sets.String) ([]*resources.Resource, error) {
	var list []*resources.Resource

	c, ok := cloud.(awsup.AWSCloud)
	if !ok {
		return nil, errors.New("expected a aws cloud provider")
	}
	glog.V(2).Infof("Finding all Autoscaling LaunchTemplates associated to security groups")

	resp, err := c.EC2().DescribeLaunchTemplates(&ec2.DescribeLaunchTemplatesInput{MaxResults: fi.Int64(100)})
	if err != nil {
		return list, nil
	}

	for _, x := range resp.LaunchTemplates {
		// @step: grab the actual launch template
		req, err := c.EC2().DescribeLaunchTemplateVersions(&ec2.DescribeLaunchTemplateVersionsInput{
			LaunchTemplateName: x.LaunchTemplateName,
		})
		if err != nil {
			return list, err
		}
		for _, j := range req.LaunchTemplateVersions {
			// @check if the security group references the security group above
			for _, y := range j.LaunchTemplateData.SecurityGroupIds {
				if securityGroups.Has(fi.StringValue(y)) {
					list = append(list, &resources.Resource{
						Name:    aws.StringValue(x.LaunchTemplateName),
						ID:      aws.StringValue(x.LaunchTemplateName),
						Type:    TypeAutoscalingLaunchConfig,
						Deleter: DeleteAutoScalingGroupLaunchTemplate,
					})
				}
			}
		}
	}

	return list, nil
}
1051132
func (t *Template) GetAWSAutoScalingScalingPolicyWithName(name string) (*resources.AWSAutoScalingScalingPolicy, error) {
	if untyped, ok := t.Resources[name]; ok {
		switch resource := untyped.(type) {
		case *resources.AWSAutoScalingScalingPolicy:
			return resource, nil
		}
	}
	return nil, fmt.Errorf("resource %q of type AWSAutoScalingScalingPolicy not found", name)
}
110714
func (t *Template) GetAWSWAFWebACLWithName(name string) (*resources.AWSWAFWebACL, error) {
	if untyped, ok := t.Resources[name]; ok {
		switch resource := untyped.(type) {
		case *resources.AWSWAFWebACL:
			return resource, nil
		}
	}
	return nil, fmt.Errorf("resource %q of type AWSWAFWebACL not found", name)
}
1004415
func (t *Template) GetAWSWAFByteMatchSetWithName(name string) (*resources.AWSWAFByteMatchSet, error) {
	if untyped, ok := t.Resources[name]; ok {
		switch resource := untyped.(type) {
		case *resources.AWSWAFByteMatchSet:
			return resource, nil
		}
	}
	return nil, fmt.Errorf("resource %q of type AWSWAFByteMatchSet not found", name)
}
1057573
func (t *Template) GetAWSServiceCatalogTagOptionWithName(name string) (*resources.AWSServiceCatalogTagOption, error) {
	if untyped, ok := t.Resources[name]; ok {
		switch resource := untyped.(type) {
		case *resources.AWSServiceCatalogTagOption:
			return resource, nil
		}
	}
	return nil, fmt.Errorf("resource %q of type AWSServiceCatalogTagOption not found", name)
}
355583
func (t *Template) GetAWSGlueTableWithName(name string) (*resources.AWSGlueTable, error) {
	if untyped, ok := t.Resources[name]; ok {
		switch resource := untyped.(type) {
		case *resources.AWSGlueTable:
			return resource, nil
		}
	}
	return nil, fmt.Errorf("resource %q of type AWSGlueTable not found", name)
}
504641
func findInstanceLaunchConfiguration(i *autoscaling.Instance) string {
	name := aws.StringValue(i.LaunchConfigurationName)
	if name != "" {
		return name
	}

	// else we need to check the launch template
	if i.LaunchTemplate != nil {
		name = aws.StringValue(i.LaunchTemplate.LaunchTemplateName)
		version := aws.StringValue(i.LaunchTemplate.Version)
		if name != "" {
			launchTemplate := name + ":" + version
			return launchTemplate
		}
	}

	return ""
}
215707
func (t *Template) GetAWSApiGatewayV2IntegrationWithName(name string) (*resources.AWSApiGatewayV2Integration, error) {
	if untyped, ok := t.Resources[name]; ok {
		switch resource := untyped.(type) {
		case *resources.AWSApiGatewayV2Integration:
			return resource, nil
		}
	}
	return nil, fmt.Errorf("resource %q of type AWSApiGatewayV2Integration not found", name)
}
1354045
func (t *Template) GetAWSOpsWorksCMServerWithName(name string) (*resources.AWSOpsWorksCMServer, error) {
	if untyped, ok := t.Resources[name]; ok {
		switch resource := untyped.(type) {
		case *resources.AWSOpsWorksCMServer:
			return resource, nil
		}
	}
	return nil, fmt.Errorf("resource %q of type AWSOpsWorksCMServer not found", name)
}