String values passed to Lambda-backed Custom Resource become E-notation

0

Issue:

Certain values that passed to Lambda-backed Custom Resource become exponential notation form.
(even if I double-quoted the values)
Values should be passed to lambda function as-is.

CloudFormation Template to reproduce(non-important resources are omitted):

  CfnCustomResourceFunction:
    Type: AWS::Lambda::Function
    Properties:
      FunctionName: cfn-custom-resource-function
      Handler:      index.handler
      Timeout:      900
      MemorySize:   128
      Runtime:      nodejs8.10
      Role:         !Sub ${CfnCustomResourceFunctionRole.Arn}
      Code:
        ZipFile: |
          var response = require('cfn-response');
          exports.handler = function(event, context) {
            console.log(JSON.stringify(event, null, 2));
            response.send(event, context, response.SUCCESS, {});
          };

  CustomResource:
    Type: Custom::CfnCustomResourceFunction
    Properties:
      ServiceToken: !Sub ${CfnCustomResourceFunction.Arn}
      Value1: "011111111111"
      Value2: "022222222222"
      Value3: "033333333333"
      Value4: "044444444444"
      Value5: "055555555555"
      Value6: "066666666666"
      Value7: "077777777777"
      Value8: "088888888888"
      Value9: "099999999999"

CloudWatch Logs(some values are sanitized):

2019-03-01T05:32:20.091Z	e3e35acf-96ce-4290-8315-1f0520fcd772
{
    "RequestType": "Create",
    "ServiceToken": "arn:aws:lambda:ap-northeast-1:xxxxxxxxxxxx:function:cfn-custom-resource-function",
    "ResponseURL": "https://cloudformation-custom-resource-response-apnortheast1.s3-ap-northeast-1.amazonaws.com/arn%3Aaws%3Acloudformation%3Aap-northeast-1%3Axxxxxxxxxxxx%3Astack/stack-name/18d8c640-0801-11e9-b562-0e819627e6da%7CCustomResource%7C59875204-de7e-4cd3-83db-83f260fea2d7?AWSAccessKeyId=AKIAI263AXSLMBRIXBRA&Expires=1551425539&Signature=L2fsXHLeMFeIlbQ5%2FUlhCLFgt0A%3D",
    "StackId": "arn:aws:cloudformation:ap-northeast-1:xxxxxxxxxxxx:stack/stack-name/18d8c640-0801-11e9-b562-0e819627e6da",
    "RequestId": "59875204-de7e-4cd3-83db-83f260fea2d7",
    "LogicalResourceId": "CustomResource",
    "ResourceType": "Custom::CfnCustomResourceFunction",
    "ResourceProperties": {
        "ServiceToken": "arn:aws:lambda:ap-northeast-1:xxxxxxxxxxxx:function:cfn-custom-resource-function",
        "Value9": "9.9999999999E10",
        "Value3": "033333333333",
        "Value4": "044444444444",
        "Value1": "011111111111",
        "Value2": "022222222222",
        "Value7": "077777777777",
        "Value8": "8.8888888888E10",
        "Value5": "055555555555",
        "Value6": "066666666666"
    }
}

Take a look at "Value8" and "Value9"

Background:

I noticed when I had been creating lambda function that takes list of AWS account numbers, and some of my AWS account numbers are actually hitting this issue.

Request/Question:

Is this a bug of Lambda Backed CFn Custom Resource?
Is there any workaround for this issue?

gefragt vor 5 Jahren384 Aufrufe
1 Antwort
0

I identified the root cause of the issue and it was not the problem of CloudFormation.
It seems it is bug at aws cloudformation package command during the build pipeline.

Parameters:
  Value7:
    Type: String
    Default: "077777777777"
  Value8:
    Type: String
    Default: "088888888888"
  Value9:
    Type: String
    Default: "099999999999"
Resources:
  NestedStack:
    Type: AWS::CloudFormation::Stack
    Properties:
      TemplateURL: ./template_child.yml
$ aws --version
aws-cli/1.16.110 Python/3.7.2 Darwin/18.2.0 botocore/1.12.100

$ aws cloudformation package --s3-bucket BUCKET_NAME --template-file template.yml                                                           
Uploading to 137ce8b72427772da39a43ddc087908a.template  101 / 101.0  (100.00%)
Parameters:
  Value7:
    Type: String
    Default: '077777777777'
  Value8:
    Type: String
    Default: 088888888888
  Value9:
    Type: String
    Default: 099999999999
Resources:
  NestedStack:
    Type: AWS::CloudFormation::Stack
    Properties:
      TemplateURL: https://s3.amazonaws.com/BUCKET_NAME/137ce8b72427772da39a43ddc087908a.template

Quotes are removed after aws cloudformation package and treated as number value.

I'll report this issue to aws-cli Github repository and mark this issue as "Answered".

beantwortet vor 5 Jahren

Du bist nicht angemeldet. Anmelden um eine Antwort zu veröffentlichen.

Eine gute Antwort beantwortet die Frage klar, gibt konstruktives Feedback und fördert die berufliche Weiterentwicklung des Fragenstellers.

Richtlinien für die Beantwortung von Fragen