UNPKG

@mapbox/cloudfriend

Version:

Helper functions for assembling CloudFormation templates in JavaScript

183 lines 4.37 kB
{ "AWSTemplateFormatVersion": "2010-09-09", "Metadata": {}, "Parameters": {}, "Rules": {}, "Mappings": {}, "Conditions": { "Always": { "Fn::Equals": [ "1", "1" ] } }, "Resources": { "AnotherThing": { "Type": "AWS::SNS::Topic" }, "MyLambdaLogs": { "Type": "AWS::Logs::LogGroup", "Condition": "Always", "Properties": { "LogGroupName": { "Fn::Sub": [ "/aws/lambda/${name}", { "name": "my-function" } ] }, "RetentionInDays": 30 } }, "MyLambda": { "Type": "AWS::Lambda::Function", "Condition": "Always", "DependsOn": "AnotherThing", "Properties": { "Code": { "S3Bucket": "my-code-bucket", "S3Key": "path/to/code.zip" }, "DeadLetterConfig": { "TargetArn": "arn:aws:sqs:us-east-1:123456789012:queue/fake" }, "Description": "my description", "Environment": { "Variables": { "MyCoolEnv": "a" } }, "FunctionName": "my-function", "Handler": "index.something", "KmsKeyArn": "arn:aws:kms:us-east-1:123456789012:key/fake", "Layers": [ "arn:aws:lambda:us-east-2:590474943231:layer:AWS-Parameters-and-Secrets-Lambda-Extension:4" ], "MemorySize": 512, "ReservedConcurrentExecutions": 10, "Runtime": "nodejs22.x", "Timeout": 30, "TracingConfig": { "Mode": "Active" }, "VpcConfig": { "SecurityGroupIds": [ "sg-12345678" ], "SubnetIds": [ "fake" ] }, "Tags": [ { "Key": "a", "Value": "b" } ], "Role": { "Fn::GetAtt": [ "MyLambdaRole", "Arn" ] } } }, "MyLambdaErrorAlarm": { "Type": "AWS::CloudWatch::Alarm", "Condition": "Always", "Properties": { "AlarmName": "my-alarm", "AlarmDescription": "some alarm", "AlarmActions": [ "devnull@mapbox.com" ], "Period": 120, "EvaluationPeriods": 2, "DatapointsToAlarm": 1, "Statistic": "Minimum", "Threshold": 10, "ComparisonOperator": "LessThanThreshold", "TreatMissingData": "breaching", "EvaluateLowSampleCountPercentile": "ignore", "OKActions": [ "devnull@mapbox.com" ], "Namespace": "AWS/Lambda", "Dimensions": [ { "Name": "FunctionName", "Value": { "Ref": "MyLambda" } } ], "MetricName": "Errors" } }, "MyLambdaLogPolicy": { "Type": "AWS::IAM::Policy", "Condition": "Always", "DependsOn": "MyLambdaRole", "Properties": { "PolicyName": "MyLambda-lambda-log-access", "Roles": [ { "Ref": "MyLambdaRole" } ], "PolicyDocument": { "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": "logs:*", "Resource": { "Fn::GetAtt": [ "MyLambdaLogs", "Arn" ] } } ] } } }, "MyLambdaRole": { "Type": "AWS::IAM::Role", "Condition": "Always", "Properties": { "AssumeRolePolicyDocument": { "Statement": [ { "Effect": "Allow", "Action": "sts:AssumeRole", "Principal": { "Service": { "Fn::Sub": "lambda.amazonaws.com" } } } ] }, "Policies": [ { "PolicyName": "main", "PolicyDocument": { "Version": "2012-10-17", "Statement": [ { "Effect": "Allow", "Action": "s3:GetObject", "Resource": "arn:aws:s3:::fake/data" } ] } } ] } } }, "Outputs": {} }