gpt4 book ai didi

amazon-web-services - CloudFormation - 无法创建 Lambda 函数

转载 作者:行者123 更新时间:2023-12-03 07:13:36 25 4
gpt4 key购买 nike

我正在尝试创建 Lambda 函数和 Lambda TriggeronSQS。以下是我的云形成模板 -

模板

{
"AWSTemplateFormatVersion": "2010-09-09",
"Resources": {
"myfunction": {
"Type": "AWS::Lambda::Function",
"Properties": {
"Runtime": "java8",
"Role": "arn:aws:iam::219560220147:role/test@123",
"Code": {
"S3Bucket": "lambdacode1234",
"S3Key": "code.jar"
},
"MemorySize": 256,
"Handler": "com.test.MyHandler",
"Timeout": 25
},
"Metadata": {
"AWS::CloudFormation::Designer": {
"id": "63dae6c8-ebdb-459b-88db-02ad5dae294a"
}
}
},
"LESM34AJN": {
"Type": "AWS::Lambda::EventSourceMapping",
"Properties": {
"EventSourceArn":" arn:aws:sqs:ap-south-1:219560220147:testlambda",
"FunctionName": {
"Fn::GetAtt": [
"myfunction",
"Arn"
]
},
"BatchSize" : 1,
"Enabled" : "TRUE"
},
"Metadata": {
"AWS::CloudFormation::Designer": {
"id": "26a65289-5f1e-41db-b94d-812d2340c945"
}
}
}
},
"Mappings": {
"RegionCodeMapping": {
"us-east-1": {
"regionCode": "US"
},
"us-west-2": {
"regionCode": "FE"
},
"eu-west-1": {
"regionCode": "EU"
}
}
},
"Parameters": {
"teamname": {
"Description": "Enter Name TeamName",
"Type": "String",
"AllowedPattern": "^[a-z0-9-]*$"
},
"env": {
"Description": "Enter Envirment type e.g. dev,test,prod",
"Type": "String",
"AllowedValues": [
"devo",
"test",
"prod"
]
},
"sqsARNtoTriggerLambda": {
"Type": "String"
},
"codeFile": {
"Type": "String"
}
},
"Outputs": {
"LambdaFunctionARN": {
"Description": "ARN of Lambda Function",
"Value": {
"Fn::GetAtt": [
"myfunction",
"Arn"
]
}
}
}

}

错误

我尝试通过 AWS 控制台创建堆栈,但收到以下 SQS 策略创建错误

1 validation error detected: Value ' arn:aws:sqs:ap-south-1:219560220147:testlambda' at 'eventSourceArn' failed to satisfy constraint: Member must satisfy regular expression pattern: arn:(aws[a-zA-Z0-9-]):([a-zA-Z0-9-])+:([a-z]{2}((-gov)|(-iso(b?)))?-[a-z]+-\d{1})?:(\d{12})?:(.) (Service: AWSLambda; Status Code: 400; Error Code: ValidationException; Request ID: 9a86cb1e-49e4-490d-9e48-fd93aa8d81dd)

CloudFormation Console Error

我已经提到了documentation 但无法弄清楚问题出在哪里?你知道这里出了什么问题吗?

最佳答案

EventSourceArn 中删除空格。

改变

"LESM34AJN": {
"Type": "AWS::Lambda::EventSourceMapping",
"Properties": {
"EventSourceArn":" arn:aws:sqs:ap-south-1:219560220147:testlambda",
"FunctionName": {
"Fn::GetAtt": [
"myfunction",
"Arn"
]
},

"LESM34AJN": {
"Type": "AWS::Lambda::EventSourceMapping",
"Properties": {
"EventSourceArn":"arn:aws:sqs:ap-south-1:219560220147:testlambda",
"FunctionName": {
"Fn::GetAtt": [
"myfunction",
"Arn"
]
},

enter image description here

From here

关于amazon-web-services - CloudFormation - 无法创建 Lambda 函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59139746/

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