@mapbox/cloudfriend
Version:
Helper functions for assembling CloudFormation templates in JavaScript
133 lines • 3.17 kB
JSON
{
"AWSTemplateFormatVersion": "2010-09-09",
"Metadata": {},
"Parameters": {},
"Rules": {},
"Mappings": {},
"Conditions": {},
"Resources": {
"MyLambdaLogs": {
"Type": "AWS::Logs::LogGroup",
"Properties": {
"LogGroupName": {
"Fn::Sub": [
"/aws/lambda/${name}",
{
"name": {
"Fn::Sub": "${AWS::StackName}-MyLambda"
}
}
]
},
"RetentionInDays": 14
}
},
"MyLambda": {
"Type": "AWS::Lambda::Function",
"Properties": {
"Code": {
"S3Bucket": "my-code-bucket",
"S3Key": "path/to/code.zip"
},
"Description": {
"Fn::Sub": "MyLambda in the ${AWS::StackName} stack"
},
"FunctionName": {
"Fn::Sub": "${AWS::StackName}-MyLambda"
},
"Handler": "index.handler",
"MemorySize": 128,
"Runtime": "nodejs22.x",
"Timeout": 300,
"Role": {
"Fn::GetAtt": [
"CustomLambdaRole",
"Arn"
]
}
}
},
"MyLambdaErrorAlarm": {
"Type": "AWS::CloudWatch::Alarm",
"Properties": {
"AlarmName": {
"Fn::Sub": "${AWS::StackName}-MyLambda-Errors-${AWS::Region}"
},
"AlarmDescription": {
"Fn::Sub": [
"Error alarm for ${name} lambda function in ${AWS::StackName} stack",
{
"name": {
"Fn::Sub": "${AWS::StackName}-MyLambda"
}
}
]
},
"AlarmActions": [],
"Period": 60,
"EvaluationPeriods": 5,
"DatapointsToAlarm": 1,
"Statistic": "Sum",
"Threshold": 0,
"ComparisonOperator": "GreaterThanThreshold",
"TreatMissingData": "notBreaching",
"Namespace": "AWS/Lambda",
"Dimensions": [
{
"Name": "FunctionName",
"Value": {
"Ref": "MyLambda"
}
}
],
"MetricName": "Errors"
}
},
"MyLambdaLogPolicy": {
"Type": "AWS::IAM::Policy",
"Properties": {
"PolicyName": "MyLambda-lambda-log-access",
"Roles": [
{
"Fn::Select": [
1,
{
"Fn::Split": [
"/",
{
"Fn::GetAtt": [
"CustomLambdaRole",
"Arn"
]
}
]
}
]
}
],
"PolicyDocument": {
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": "logs:*",
"Resource": {
"Fn::GetAtt": [
"MyLambdaLogs",
"Arn"
]
}
}
]
}
}
},
"CustomLambdaRole": {
"Type": "AWS::IAM::Role",
"Properties": {
"AssumeRolePolicyDocument": {}
}
}
},
"Outputs": {}
}