Lambda Cloudformation遇到不受支持的属性值错误

时间:2017-12-06 06:47:09

标签: amazon-web-services aws-lambda amazon-cloudformation

尝试使用错误消息“遇到不支持的属性值”创建lambda函数时,cloudformation失败

没有引用不受支持的值,我找不到任何不正确的值。所有值仅用于AWS lambda云形成模板。

同样对于Dev我得到错误,指示安全组是字符串类型但是对于QA没有得到错误。

请您检查指出导致不支持的值错误的原因以及如何解决Dev环境中与安全组相关的错误。

{
    "AWSTemplateFormatVersion": "2010-09-09",
    "Description": "Create Lambda Function For abc",
    "Parameters": {
        "ID" : {
            "Description" : "OwnerContact Value",
            "Type" : "String",
            "Default" : "abc@xyz.com"
        },
        "abcVPCNAME": {
          "Description": "abc VPC NAME",
          "Type": "String",
          "Default": "abc-e-dev",
          "AllowedValues": [
              "abc-e-dev",
              "abc-e-qa",
              "abc-e-prod",
              "abc-w-qa",
              "abc-w-prod",
            ]
        }
    },
   "Mappings" : {
        "params" : {
            "abc-e-dev" : {
                "S3bukcet" : "abc-dev-east",
                "S3Key" : "/lambda/abc_S3.zip",
                "TicketSNS" : "arn:aws:sns:us-east-1:212:abc",
                "HOSTNAME" : "abc.com",
                "ROLENAME" : "arn:aws:iam::454:role/Lambda-role",
                "Subnets" : ["subnet-1","subnet-2","subnet-3"],
                "SecGrps" : ["sg-1","sg-2"],
                "TAG1" : "xyz",
                "TAG2" : "123"
            },
            "abc-e-qa" : {
                "S3bukcet" : "abc-qa-east",
                "S3Key" : "/lambda/abc_S3.zip",
                "TicketSNS" : "arn:aws:sns:us-east-1:212:abc",
                "HOSTNAME" : "xyz.com",
                "ROLENAME" : "arn:aws:iam::454:role/Lambda-role",
                "Subnets" : ["subnet-1","subnet-2","subnet-3"],
                "SecGrps" : "sg-123",
                "TAG1" : "xyz",
                "TAG2" : "123"
            },
        }
    },
    "Resources": {
      "abcS3Get": {
        "Type" : "AWS::Lambda::Function",
        "Properties" : {
          "Code" : {
            "S3Bucket" : { "Fn::FindInMap" : [ "params", {"Ref":"abcVPCNAME"}, "S3bukcet" ]},
            "S3Key" : { "Fn::FindInMap" : [ "params", {"Ref":"abcVPCNAME"}, "S3Key" ]}
          },
          "DeadLetterConfig" : { "Fn::FindInMap" : [ "params", {"Ref":"abcVPCNAME"}, "TicketSNS" ]},
          "Description" : "abc Lambda Function For File Pickup",
          "Environment" : {
            "Key": "abcHOST",
            "Value": { "Fn::FindInMap" : [ "params", {"Ref":"abcVPCNAME"}, "HOSTNAME" ]}
          },
          "FunctionName" : "abc-S3-Pickup",
          "Handler" : "abc_S3_Get.lambda_handler",
          "MemorySize" : 128,
          "Role" : { "Fn::FindInMap" : [ "params", {"Ref":"abcVPCNAME"}, "ROLENAME" ]},
          "Runtime" : "python2.7",
          "Timeout" : 3,
          "VpcConfig" : {
            "SecurityGroupIds" : { "Fn::FindInMap" : [ "params", {"Ref":"abcVPCNAME"}, "SecGrps" ]},
            "SubnetIds" : { "Fn::FindInMap" : [ "params", {"Ref":"abcVPCNAME"}, "Subnets" ]}
          },
          "Tags" : [{
            "Key" : "KEY1",
            "Value" : { "Fn::FindInMap" : [ "params", {"Ref":"abcVPCNAME"}, "TAG1" ]}
            },
            {
            "Key" : "KEY2",
            "Value" : { "Fn::FindInMap" : [ "params", {"Ref":"abcVPCNAME"}, "TAG2" ]}
            },
            {
            "Key" : "KEY3",
            "Value" : {"Ref":"ID"}
            }
          ]
        }
      }
    }
}

1 个答案:

答案 0 :(得分:0)

找到了解决方案。环境中的Value参数存在问题,这是不正确的。

更正了以下内容并解决了问题。

"Environment" : {
            "Variables" : {
              "abcHOST":  {
                "Fn::FindInMap" : [ "params", {"Ref":"abcVPCNAME"}, "HOSTNAME" ]
              }
            }

还有其他几个问题。

"S3Key" : "/lambda/abc_S3.zip",

应该是

"S3Key" : "lambda/abc_S3.zip",

还需要更改Deadletterconfig参数。

Current Value:

"DeadLetterConfig" : { "Fn::FindInMap" : [ "params", {"Ref":"abcVPCNAME"}, "TicketSNS" ]},

Correct Value:

"DeadLetterConfig" : {
            "TargetArn" : { "Fn::FindInMap" : [ "params", {"Ref":"abcVPCNAME"}, "TicketSNS" ]}
            },

在完成上述所有变更后,CFT开始工作。