cfn-lambda
Version:
CloudFormation custom resource helper for Lambda Node.js runtime
103 lines (102 loc) • 2.51 kB
JSON
{
"AWSTemplateFormatVersion": "2010-09-09",
"Parameters": {
"ResourceTypeName": {
"Type": "String"
},
"ResourceTypeVersion": {
"Type": "String"
},
"CodeBucket": {
"Type": "String"
},
"LambdaRuntimeVersion": {
"Type": "String",
"Default": "nodejs14.x"
}
},
"Resources": {
"ServiceLambda": {
"Type": "AWS::Lambda::Function",
"DependsOn": [
"ServiceLambdaRole"
],
"Properties": {
"Code": {
"S3Bucket": {
"Ref": "CodeBucket"
},
"S3Key": {
"Fn::Sub": "${ResourceTypeVersion}.zip"
}
},
"FunctionName": {
"Fn::Sub": "${ResourceTypeName}-${ResourceTypeVersion}"
},
"Description": {
"Fn::Sub": "CloudFormation Custom Resource service for Custom::${ResourceTypeName}, version ${ResourceTypeVersion}"
},
"Role": {
"Fn::GetAtt": [
"ServiceLambdaRole",
"Arn"
]
},
"Handler": "index.handler",
"Runtime": {
"Ref": "LambdaRuntimeVersion"
},
"Timeout": 300,
"MemorySize": 128
}
},
"ServiceLambdaRole": {
"Type": "AWS::IAM::Role",
"Properties": {
"AssumeRolePolicyDocument": {
"Version": "2012-10-17",
"Statement": {
"Effect": "Allow",
"Principal": {
"Service": "lambda.amazonaws.com"
},
"Action": "sts:AssumeRole"
}
}
}
},
"ServiceLambdaRolePolicy": {
"Type": "AWS::IAM::Policy",
"DependsOn": [
"ServiceLambdaRole"
],
"Properties": {
"PolicyDocument": "THIS IS REPLACED IN THE SCRIPT WITH THE JSON FOR THE SPECIFIC SERVICE",
"PolicyName": {
"Fn::Sub": "${ResourceTypeName}-${ResourceTypeVersion}-lambda-role-policy"
},
"Roles": [
{
"Ref": "ServiceLambdaRole"
}
]
}
}
},
"Outputs": {
"ServiceToken": {
"Description": "The Lambda function ARN to use for ServiceToken in Properties for any future stack resources invoking this custom resource.",
"Value": {
"Fn::GetAtt": [
"ServiceLambda",
"Arn"
]
},
"Export": {
"Name": {
"Fn::Sub": "${ResourceTypeName}-${ResourceTypeVersion}-ServiceToken"
}
}
}
}
}