// Returns the name of the CloudFormation resource that should be used to create
// custom task definitions.
166635
func taskDefinitionResourceType(app *twelvefactor.Manifest) string {
	check := []string{
		"EMPIRE_X_TASK_DEFINITION_TYPE",
		"ECS_TASK_DEFINITION", // For backwards compatibility.
	}

	for _, n := range check {
		if v, ok := app.Env[n]; ok {
			if v == "custom" {
				return "Custom::ECSTaskDefinition"
			}
		}
	}

	// Default when not set.
	return "AWS::ECS::TaskDefinition"
}
77267
func (t *Template) GetAWSRDSDBClusterWithName(name string) (*resources.AWSRDSDBCluster, error) {
	if untyped, ok := t.Resources[name]; ok {
		switch resource := untyped.(type) {
		case *resources.AWSRDSDBCluster:
			return resource, nil
		}
	}
	return nil, fmt.Errorf("resource %q of type AWSRDSDBCluster not found", name)
}
818580
func (t *Template) GetAWSEKSClusterWithName(name string) (*resources.AWSEKSCluster, error) {
	if untyped, ok := t.Resources[name]; ok {
		switch resource := untyped.(type) {
		case *resources.AWSEKSCluster:
			return resource, nil
		}
	}
	return nil, fmt.Errorf("resource %q of type AWSEKSCluster not found", name)
}
493524
func GetResourceName(res Resource) string {
	switch v := res.(type) {
	case *v2.ClusterLoadAssignment:
		return v.GetClusterName()
	case *v2.Cluster:
		return v.GetName()
	case *v2.RouteConfiguration:
		return v.GetName()
	case *v2.Listener:
		return v.GetName()
	case *auth.Secret:
		return v.GetName()
	default:
		return ""
	}
}
400172
func (t *Template) GetAWSAppSyncFunctionConfigurationWithName(name string) (*resources.AWSAppSyncFunctionConfiguration, error) {
	if untyped, ok := t.Resources[name]; ok {
		switch resource := untyped.(type) {
		case *resources.AWSAppSyncFunctionConfiguration:
			return resource, nil
		}
	}
	return nil, fmt.Errorf("resource %q of type AWSAppSyncFunctionConfiguration not found", name)
}
380483
func (t *Template) GetAWSWAFRegionalIPSetWithName(name string) (*resources.AWSWAFRegionalIPSet, error) {
	if untyped, ok := t.Resources[name]; ok {
		switch resource := untyped.(type) {
		case *resources.AWSWAFRegionalIPSet:
			return resource, nil
		}
	}
	return nil, fmt.Errorf("resource %q of type AWSWAFRegionalIPSet not found", name)
}
415670
func (s *oracleVolumeSource) resourceName(tag string) string {
	return s.api.ComposeName(s.env.namespace.Value(s.envName + "-" + tag))
}
675521
func (t *Template) GetAWSAppSyncResolverWithName(name string) (*resources.AWSAppSyncResolver, error) {
	if untyped, ok := t.Resources[name]; ok {
		switch resource := untyped.(type) {
		case *resources.AWSAppSyncResolver:
			return resource, nil
		}
	}
	return nil, fmt.Errorf("resource %q of type AWSAppSyncResolver not found", name)
}
33028
func CloudFormationLambdaCustomResourceHandler(command CustomResourceCommand, logger *logrus.Logger) interface{} {
	return func(ctx context.Context,
		event CloudFormationLambdaEvent) error {
		lambdaCtx, lambdaCtxOk := awsLambdaCtx.FromContext(ctx)
		if !lambdaCtxOk {
			return errors.Errorf("Failed to access AWS Lambda Context from ctx argument")
		}
		customResourceSession := awsSession(logger)
		var opResults map[string]interface{}
		var opErr error
		executeOperation := false
		// If we're in cleanup mode, then skip it...
		// Don't forward to the CustomAction handler iff we're in CLEANUP mode
		describeStacksInput := &cloudformation.DescribeStacksInput{
			StackName: aws.String(event.StackID),
		}
		cfSvc := cloudformation.New(customResourceSession)
		describeStacksOutput, describeStacksOutputErr := cfSvc.DescribeStacks(describeStacksInput)
		if nil != describeStacksOutputErr {
			opErr = describeStacksOutputErr
		} else {
			stackDesc := describeStacksOutput.Stacks[0]
			if stackDesc == nil {
				opErr = errors.Errorf("DescribeStack failed: %s", event.StackID)
			} else {
				executeOperation = (*stackDesc.StackStatus != "UPDATE_COMPLETE_CLEANUP_IN_PROGRESS")
			}
		}

		logger.WithFields(logrus.Fields{
			"ExecuteOperation": event.LogicalResourceID,
			"Stacks":           fmt.Sprintf("%#+v", describeStacksOutput),
			"RequestType":      event.RequestType,
		}).Debug("CustomResource Request")

		if opErr == nil && executeOperation {
			switch event.RequestType {
			case CreateOperation:
				opResults, opErr = command.Create(customResourceSession, &event, logger)
			case DeleteOperation:
				opResults, opErr = command.Delete(customResourceSession, &event, logger)
			case UpdateOperation:
				opResults, opErr = command.Update(customResourceSession, &event, logger)
			}
		}
		// Notify CloudFormation of the result
		if event.ResponseURL != "" {
			sendErr := SendCloudFormationResponse(lambdaCtx,
				&event,
				opResults,
				opErr,
				logger)
			if nil != sendErr {
				logger.WithFields(logrus.Fields{
					"Error": sendErr.Error(),
					"URL":   event.ResponseURL,
				}).Info("Failed to ACK status to CloudFormation")
			} else {
				// If the cloudformation notification was complete, then this
				// execution functioned properly and we can clear the Error
				opErr = nil
			}
		}
		return opErr
	}
}
188161
func (t *Template) GetAWSOpsWorksVolumeWithName(name string) (*resources.AWSOpsWorksVolume, error) {
	if untyped, ok := t.Resources[name]; ok {
		switch resource := untyped.(type) {
		case *resources.AWSOpsWorksVolume:
			return resource, nil
		}
	}
	return nil, fmt.Errorf("resource %q of type AWSOpsWorksVolume not found", name)
}
1028397
func (t *Template) GetAWSCloud9EnvironmentEC2WithName(name string) (*resources.AWSCloud9EnvironmentEC2, error) {
	if untyped, ok := t.Resources[name]; ok {
		switch resource := untyped.(type) {
		case *resources.AWSCloud9EnvironmentEC2:
			return resource, nil
		}
	}
	return nil, fmt.Errorf("resource %q of type AWSCloud9EnvironmentEC2 not found", name)
}
636873
func (t *Template) GetAWSCloudFormationCustomResourceWithName(name string) (*resources.AWSCloudFormationCustomResource, error) {
	if untyped, ok := t.Resources[name]; ok {
		switch resource := untyped.(type) {
		case *resources.AWSCloudFormationCustomResource:
			return resource, nil
		}
	}
	return nil, fmt.Errorf("resource %q of type AWSCloudFormationCustomResource not found", name)
}
940758
func (t *Template) GetAWSServiceDiscoveryHttpNamespaceWithName(name string) (*resources.AWSServiceDiscoveryHttpNamespace, error) {
	if untyped, ok := t.Resources[name]; ok {
		switch resource := untyped.(type) {
		case *resources.AWSServiceDiscoveryHttpNamespace:
			return resource, nil
		}
	}
	return nil, fmt.Errorf("resource %q of type AWSServiceDiscoveryHttpNamespace 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)
}
696260
func (t *Template) GetAWSWAFRegionalSizeConstraintSetWithName(name string) (*resources.AWSWAFRegionalSizeConstraintSet, error) {
	if untyped, ok := t.Resources[name]; ok {
		switch resource := untyped.(type) {
		case *resources.AWSWAFRegionalSizeConstraintSet:
			return resource, nil
		}
	}
	return nil, fmt.Errorf("resource %q of type AWSWAFRegionalSizeConstraintSet not found", name)
}
557278
func (t *Template) GetAWSGreengrassResourceDefinitionVersionWithName(name string) (*resources.AWSGreengrassResourceDefinitionVersion, error) {
	if untyped, ok := t.Resources[name]; ok {
		switch resource := untyped.(type) {
		case *resources.AWSGreengrassResourceDefinitionVersion:
			return resource, nil
		}
	}
	return nil, fmt.Errorf("resource %q of type AWSGreengrassResourceDefinitionVersion not found", name)
}
511438
func (t *Template) GetAWSCloudFrontCloudFrontOriginAccessIdentityWithName(name string) (*resources.AWSCloudFrontCloudFrontOriginAccessIdentity, error) {
	if untyped, ok := t.Resources[name]; ok {
		switch resource := untyped.(type) {
		case *resources.AWSCloudFrontCloudFrontOriginAccessIdentity:
			return resource, nil
		}
	}
	return nil, fmt.Errorf("resource %q of type AWSCloudFrontCloudFrontOriginAccessIdentity not found", name)
}