I have created a CFT to create the lambda function, the function is getting created. Now I want to connect it to the database. In the console there is option to connect to RDS database but in CFT I am not finding any.
lambda function doc:https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/aws-resource-lambda-function.html
{
"AWSTemplateFormatVersion": "2010-09-09",
"Description": "The template for API gateway stage.",
"Parameters": {
"projectName": {
"Type": "String"
},
"role": {
"Type": "String"
},
"imageUri": {
"Type": "String"
},
"securityGroupIDs": {
"Type": "CommaDelimitedList"
}
},
"Resources": {
"lambda": {
"Type": "AWS::Lambda::Function",
"Properties": {
"Code": {
"ImageUri": {
"Ref": "imageUri"
}
},
"FunctionName": {
"Fn::Sub": "${projectName}-lambda"
},
"PackageType": "Image",
"Role": {
"Ref": "role"
},
"Timeout": 10,
"VpcConfig": {
"Ipv6AllowedForDualStack": false,
"SecurityGroupIds": {
"Ref": "securityGroupIDs"
},
"SubnetIds": "<enforced_value>"
}
}
}
},
"Outputs": {
"functionName": {
"Description": "The custom lambda function name.",
"Value": {
"Ref": "lambda"
}
},
"arn": {
"Description": "The ARN of custom lambda function.",
"Value": {
"Fn::GetAtt": [
"lambda",
"Arn"
]
}
}
}
}
Check out these patterns for Lambda and RDS: