Class LambdaFunctionResource


  • public class LambdaFunctionResource
    extends Object
    Model for handled resource.
    • Field Detail

      • SERVERLESS_RESOURCE_TYPE

        public static final String SERVERLESS_RESOURCE_TYPE
        Serverless resource type identifier.
        See Also:
        Constant Field Values
      • DEFAULT_LOGS_RETENTION_DAYS

        private static final Number DEFAULT_LOGS_RETENTION_DAYS
        Default retention period for logs (in days).
      • DEFAULT_ALERT_PERIOD

        private static final Number DEFAULT_ALERT_PERIOD
        Default alarm check period (in seconds).
      • COUNTER_METRIC_VALUE

        private static final String COUNTER_METRIC_VALUE
        Value used for counting metrics (each metric record is single occurrence).
        See Also:
        Constant Field Values
      • PROPERTY_LOG_GROUP_NAME

        private static final String PROPERTY_LOG_GROUP_NAME
        LogGroupName property name.
        See Also:
        Constant Field Values
      • PROPERTY_LOGS_RETENTION_IN_DAYS

        private static final String PROPERTY_LOGS_RETENTION_IN_DAYS
        LogsRetentionInDays property name.
        See Also:
        Constant Field Values
      • PROPERTY_COMPARISON_OPERATOR

        private static final String PROPERTY_COMPARISON_OPERATOR
        ComparisonOperator property name.
        See Also:
        Constant Field Values
      • PROPERTY_EVALUATION_PERIODS

        private static final String PROPERTY_EVALUATION_PERIODS
        EvaluationPeriods property name.
        See Also:
        Constant Field Values
      • PROPERTY_TREAT_MISSING_DATA

        private static final String PROPERTY_TREAT_MISSING_DATA
        TreatMissingData property name.
        See Also:
        Constant Field Values
      • PROPERTY_METRIC_NAMESPACE

        private static final String PROPERTY_METRIC_NAMESPACE
        MetricNamespace property name.
        See Also:
        Constant Field Values
      • PROPERTY_METRIC_TRANSFORMATIONS

        private static final String PROPERTY_METRIC_TRANSFORMATIONS
        MetricTransformations property name.
        See Also:
        Constant Field Values
      • PROPERTY_FILTER_PATTERN

        private static final String PROPERTY_FILTER_PATTERN
        FilterPattern property name.
        See Also:
        Constant Field Values
      • logicalId

        private String logicalId
        Resource name.
      • mode

        private String mode
        Resource mode (`Lambda` or `Serverless`).
    • Constructor Detail

      • LambdaFunctionResource

        public LambdaFunctionResource​(String logicalId,
                                      String mode)
    • Method Detail

      • buildDefinitions

        public Map<String,​Object> buildDefinitions​(Map<String,​Object> properties)
        Builds definition of physical resources.
        Parameters:
        properties - Properties for our custom resource.
        Returns:
        Definitions of all resources.
      • createLogGroup

        private void createLogGroup​(Map<String,​Object> resources,
                                    Map<String,​Object> properties)
        Creates log group resource definition.
        Parameters:
        resources - Resources container.
        properties - Resource properties.
      • createMemoryMetricFilter

        private void createMemoryMetricFilter​(Map<String,​Object> resources)
        Creates memory metric filter resource definition.
        Parameters:
        resources - Resources container.
      • createErrorsMetricFilter

        private void createErrorsMetricFilter​(Map<String,​Object> resources,
                                              Map<String,​Object> properties)
        Creates errors metric filter resource definition.
        Parameters:
        resources - Resources container.
        properties - Resource properties.
      • createErrorsAlarm

        private void createErrorsAlarm​(Map<String,​Object> resources,
                                       Map<String,​Object> properties)
        Creates errors alarm resource definition.
        Parameters:
        resources - Resources container.
        properties - Resource properties.
      • createWarningsMetricFilter

        private void createWarningsMetricFilter​(Map<String,​Object> resources,
                                                Map<String,​Object> properties)
        Creates warnings metric filter resource definition.
        Parameters:
        resources - Resources container.
        properties - Resource properties.
      • createMetricFilter

        private void createMetricFilter​(Map<String,​Object> resources,
                                        String resourceName,
                                        String metricNameSuffix,
                                        String metricValue,
                                        Object filterPattern)
        Generic method for metric filter creation.
        Parameters:
        resources - Resources container.
        resourceName - Resource logical ID.
        metricNameSuffix - Metric name postfix.
        metricValue - Metric value.
        filterPattern - Metric log filter pattern.
      • createLambdaFunction

        private void createLambdaFunction​(Map<String,​Object> resources,
                                          Map<String,​Object> properties)
        Creates function resource definition.
        Parameters:
        resources - Resources container.
        properties - Resource properties.
      • getLogGroupLogicalId

        public String getLogGroupLogicalId()
        Builds logical ID of LogGroup resource.
        Returns:
        LogGroup logical ID.
      • generateResource

        private void generateResource​(Map<String,​Object> resources,
                                      String suffix,
                                      String type,
                                      Map<String,​Object> properties)
        Adds resource to collection.
        Parameters:
        resources - Resources container.
        suffix - Resource logical ID suffix.
        type - CloudFormation resource type.
        properties - Resource configuration.