1
votes

The cloudformation is failing when trying to create lambda function with the error message "Encountered unsupported property Value"

There is no reference to the unsupported value and I couldn't find any incorrect value. All the values were used from AWS lambda cloud formation template only.

Also for the Dev I get the error indicating security group is string type but for QA doesn't get the error.

Can you please check point out what's causing unsupported value error and how to resolve security group related error for Dev environment.

{
    "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

1 Answers

0
votes

Found the resolution. It was issue with Value parameter in Environment which is incorrect.

Corrected to below and resolved the issue.

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

There were couple of other issues as well.

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

should be

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

Also Deadletterconfig parameter needs to be altered as well.

Current Value:

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

Correct Value:

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

The CFT started working after all of the above changes.