Class LambdaFunctionResource
- java.lang.Object
-
- pl.wrzasq.lambda.macro.lambda.function.template.LambdaFunctionResource
-
public class LambdaFunctionResource extends Object
Model for handled resource.
-
-
Field Summary
Fields Modifier and Type Field Description private static String
COUNTER_METRIC_VALUE
Value used for counting metrics (each metric record is single occurrence).private static Number
DEFAULT_ALERT_PERIOD
Default alarm check period (in seconds).private static Number
DEFAULT_LOGS_RETENTION_DAYS
Default retention period for logs (in days).static String
LAMBDA_RESOURCE_TYPE
Resource type identifier.private String
logicalId
Resource name.private static String
METRICS_NAMESPACE
Metrics namespace.private String
mode
Resource mode (`Lambda` or `Serverless`).private static String
PROPERTY_COMPARISON_OPERATOR
ComparisonOperator property name.private static String
PROPERTY_EVALUATION_PERIODS
EvaluationPeriods property name.private static String
PROPERTY_FILTER_PATTERN
FilterPattern property name.private static String
PROPERTY_LOG_GROUP_NAME
LogGroupName property name.private static String
PROPERTY_LOGS_RETENTION_IN_DAYS
LogsRetentionInDays property name.private static String
PROPERTY_METRIC_NAME
MetricName property name.private static String
PROPERTY_METRIC_NAMESPACE
MetricNamespace property name.private static String
PROPERTY_METRIC_TRANSFORMATIONS
MetricTransformations property name.private static String
PROPERTY_METRIC_VALUE
MetricValue property name.private static String
PROPERTY_NAMESPACE
Namespace property name.private static String
PROPERTY_PERIOD
Period property name.private static String
PROPERTY_STATISTIC
Statistic property name.private static String
PROPERTY_THRESHOLD
Threshold property name.private static String
PROPERTY_TREAT_MISSING_DATA
TreatMissingData property name.static String
SERVERLESS_RESOURCE_TYPE
Serverless resource type identifier.
-
Constructor Summary
Constructors Constructor Description LambdaFunctionResource(String logicalId, String mode)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Map<String,Object>
buildDefinitions(Map<String,Object> properties)
Builds definition of physical resources.private void
createErrorsAlarm(Map<String,Object> resources, Map<String,Object> properties)
Creates errors alarm resource definition.private void
createErrorsMetricFilter(Map<String,Object> resources, Map<String,Object> properties)
Creates errors metric filter resource definition.private void
createLambdaFunction(Map<String,Object> resources, Map<String,Object> properties)
Creates function resource definition.private void
createLogGroup(Map<String,Object> resources, Map<String,Object> properties)
Creates log group resource definition.private void
createMemoryMetricFilter(Map<String,Object> resources)
Creates memory metric filter resource definition.private void
createMetricFilter(Map<String,Object> resources, String resourceName, String metricNameSuffix, String metricValue, Object filterPattern)
Generic method for metric filter creation.private void
createWarningsMetricFilter(Map<String,Object> resources, Map<String,Object> properties)
Creates warnings metric filter resource definition.private void
generateResource(Map<String,Object> resources, String suffix, String type, Map<String,Object> properties)
Adds resource to collection.String
getLogGroupLogicalId()
Builds logical ID of LogGroup resource.
-
-
-
Field Detail
-
LAMBDA_RESOURCE_TYPE
public static final String LAMBDA_RESOURCE_TYPE
Resource type identifier.- See Also:
- Constant Field Values
-
SERVERLESS_RESOURCE_TYPE
public static final String SERVERLESS_RESOURCE_TYPE
Serverless resource type identifier.- See Also:
- Constant Field Values
-
METRICS_NAMESPACE
private static final String METRICS_NAMESPACE
Metrics namespace.- 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_NAMESPACE
private static final String PROPERTY_NAMESPACE
Namespace property name.- See Also:
- Constant Field Values
-
PROPERTY_METRIC_NAME
private static final String PROPERTY_METRIC_NAME
MetricName property name.- See Also:
- Constant Field Values
-
PROPERTY_STATISTIC
private static final String PROPERTY_STATISTIC
Statistic 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_THRESHOLD
private static final String PROPERTY_THRESHOLD
Threshold 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_PERIOD
private static final String PROPERTY_PERIOD
Period 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_VALUE
private static final String PROPERTY_METRIC_VALUE
MetricValue 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`).
-
-
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.
-
-