gpt4 book ai didi

amazon-web-services - AWS CloudFormation 模板 - 如何使用 SQS 队列配置 Lambda 以从队列中选取项目

转载 作者:行者123 更新时间:2023-12-03 07:24:53 27 4
gpt4 key购买 nike

我对 AWS CloudFormaton 模板创建还很陌生。无法找到创建将与 SQS 队列连接的 Lambda 函数的方法。

任何示例或资源都可以帮助我学习和实现。

最佳答案

您需要:

AWS::SQS::Queue
AWS::Lambda::Function
AWS::Lambda::EventSourceMapping

"DequeueInstanceQueue": {
"Type": "AWS::SQS::Queue",
"Properties": {
"VisibilityTimeout": 301
},
"DeletionPolicy": "Delete"
},
"DequeueInstanceMapping": {
"Type": "AWS::Lambda::EventSourceMapping",
"Properties": {
"EventSourceArn": {
"Fn::GetAtt": [
"DequeueInstanceQueue",
"Arn"
]
},
"FunctionName": {
"Fn::GetAtt": [
"DequeueInstance",
"Arn"
]
},
"BatchSize": "1"
},
"DeletionPolicy": "Delete"
},
"DequeueInstance": {
"Type": "AWS::Lambda::Function",
"Properties": {
"Runtime": "dotnetcore2.1",
"Environment": {
"Variables": {
"ServerName": {
"Fn::ImportValue": {
"Fn::Sub": "${DatabaseStack}-RdsEndpointAddress"
}
},
"DatabaseUserName": {
"Fn::ImportValue": {
"Fn::Sub": "${DatabaseStack}-MasterUsername"
}
},
"Password": {
"Fn::ImportValue": {
"Fn::Sub": "${DatabaseStack}-MasterUserPassword"
}
},
"BranchName": {
"Ref": "DbBranch"
},
"DequeueInstanceVehicleQueue": {
"Ref": "DequeueInstanceVehicleQueue"
}
}
},
"VpcConfig": {
"SecurityGroupIds": [
{
"Fn::ImportValue": {
"Fn::Sub": "${DatabaseStack}-DbGroup"
}
}
],
"SubnetIds": [
{
"Fn::ImportValue": {
"Fn::Sub": "${NetworkStack}-PrivateSubnet1"
}
},
{
"Fn::ImportValue": {
"Fn::Sub": "${NetworkStack}-PrivateSubnet2"
}
}
]
},
"Timeout": 300,
"Handler": "YadaYada.BubbleBoy.WebApi::YadaYada.BubbleBoy.WebApi.Functions.ProductMaker::DequeueInstance",
"MemorySize": 3008,
"Role": {
"Fn::GetAtt": [
"DequeueInstanceRole",
"Arn"
]
},
"Code": {
"S3Bucket": {
"Ref": "YadaYadaBubbleBoyWebApiBucket"
},
"S3Key": {
"Ref": "YadaYadaBubbleBoyWebApiKey"
}
}
},
"DeletionPolicy": "Delete"
},

关于amazon-web-services - AWS CloudFormation 模板 - 如何使用 SQS 队列配置 Lambda 以从队列中选取项目,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55995717/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com