Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cloudformation package fails when using a local java jar file in the Aws::Lambda::Function 'Code' property #3288

Closed
lestephane opened this issue Apr 25, 2018 · 1 comment
Labels
cloudformation guidance Question that needs advice or information. lambda

Comments

@lestephane
Copy link

When I use a local java JAR in an AWS::Lambda::Function template

  SomeFunction:
    Type: AWS::Lambda::Function
    Properties:
      Code: target/somefunction-1.0-SNAPSHOT.jar <<<<<<<<<<<<<<<<<<<<< 
      FunctionName: SomeFunction
      MemorySize: 512
      Handler: com.package.SomeLambdaHandler::handleRequest
      Role: !Ref SomeExecutionRole
      Timeout: 20
      Runtime: java8

That i then pass to aws cloudformation package (to upload the jar to s3 on my behalf)

aws cloudformation package
  --template-file cf-api-lambda.yml
  --output-template-file target/cf-api-lambda.yml
  --s3-bucket some-existing-bucket
  --force-upload

the JAR gets uploaded all the way to 100%, but then everything bombs:

Uploading to 284ff8d34bc5e8ab4b78ced5296ff5fc  262144 / 16337912.0  (1.60%)
Uploading to 284ff8d34bc5e8ab4b78ced5296ff5fc  524288 / 16337912.0  (3.21%)
Uploading to 284ff8d34bc5e8ab4b78ced5296ff5fc  786432 / 16337912.0  (4.81%)
Uploading to 284ff8d34bc5e8ab4b78ced5296ff5fc  1048576 / 16337912.0  (6.42%)
Uploading to 284ff8d34bc5e8ab4b78ced5296ff5fc  1310720 / 16337912.0  (8.02%)
Uploading to 284ff8d34bc5e8ab4b78ced5296ff5fc  1572864 / 16337912.0  (9.63%)
Uploading to 284ff8d34bc5e8ab4b78ced5296ff5fc  1835008 / 16337912.0  (11.23%)
Uploading to 284ff8d34bc5e8ab4b78ced5296ff5fc  2097152 / 16337912.0  (12.84%)
Uploading to 284ff8d34bc5e8ab4b78ced5296ff5fc  2359296 / 16337912.0  (14.44%)
Uploading to 284ff8d34bc5e8ab4b78ced5296ff5fc  2621440 / 16337912.0  (16.05%)
Uploading to 284ff8d34bc5e8ab4b78ced5296ff5fc  2883584 / 16337912.0  (17.65%)
Uploading to 284ff8d34bc5e8ab4b78ced5296ff5fc  3145728 / 16337912.0  (19.25%)
Uploading to 284ff8d34bc5e8ab4b78ced5296ff5fc  3407872 / 16337912.0  (20.86%)
Uploading to 284ff8d34bc5e8ab4b78ced5296ff5fc  3670016 / 16337912.0  (22.46%)
Uploading to 284ff8d34bc5e8ab4b78ced5296ff5fc  3932160 / 16337912.0  (24.07%)
Uploading to 284ff8d34bc5e8ab4b78ced5296ff5fc  4194304 / 16337912.0  (25.67%)
Uploading to 284ff8d34bc5e8ab4b78ced5296ff5fc  4456448 / 16337912.0  (27.28%)
Uploading to 284ff8d34bc5e8ab4b78ced5296ff5fc  4718592 / 16337912.0  (28.88%)
Uploading to 284ff8d34bc5e8ab4b78ced5296ff5fc  4980736 / 16337912.0  (30.49%)
Uploading to 284ff8d34bc5e8ab4b78ced5296ff5fc  5242880 / 16337912.0  (32.09%)
Uploading to 284ff8d34bc5e8ab4b78ced5296ff5fc  5505024 / 16337912.0  (33.69%)
Uploading to 284ff8d34bc5e8ab4b78ced5296ff5fc  5767168 / 16337912.0  (35.30%)
Uploading to 284ff8d34bc5e8ab4b78ced5296ff5fc  6029312 / 16337912.0  (36.90%)
Uploading to 284ff8d34bc5e8ab4b78ced5296ff5fc  6291456 / 16337912.0  (38.51%)
Uploading to 284ff8d34bc5e8ab4b78ced5296ff5fc  6553600 / 16337912.0  (40.11%)
Uploading to 284ff8d34bc5e8ab4b78ced5296ff5fc  6815744 / 16337912.0  (41.72%)
Uploading to 284ff8d34bc5e8ab4b78ced5296ff5fc  7077888 / 16337912.0  (43.32%)
Uploading to 284ff8d34bc5e8ab4b78ced5296ff5fc  7340032 / 16337912.0  (44.93%)
Uploading to 284ff8d34bc5e8ab4b78ced5296ff5fc  7602176 / 16337912.0  (46.53%)
Uploading to 284ff8d34bc5e8ab4b78ced5296ff5fc  7864320 / 16337912.0  (48.14%)
Uploading to 284ff8d34bc5e8ab4b78ced5296ff5fc  8126464 / 16337912.0  (49.74%)
Uploading to 284ff8d34bc5e8ab4b78ced5296ff5fc  8388608 / 16337912.0  (51.34%)
Uploading to 284ff8d34bc5e8ab4b78ced5296ff5fc  8650752 / 16337912.0  (52.95%)
Uploading to 284ff8d34bc5e8ab4b78ced5296ff5fc  8912896 / 16337912.0  (54.55%)
Uploading to 284ff8d34bc5e8ab4b78ced5296ff5fc  9175040 / 16337912.0  (56.16%)
Uploading to 284ff8d34bc5e8ab4b78ced5296ff5fc  9437184 / 16337912.0  (57.76%)
Uploading to 284ff8d34bc5e8ab4b78ced5296ff5fc  9699328 / 16337912.0  (59.37%)
Uploading to 284ff8d34bc5e8ab4b78ced5296ff5fc  9961472 / 16337912.0  (60.97%)
Uploading to 284ff8d34bc5e8ab4b78ced5296ff5fc  10223616 / 16337912.0  (62.58%)
Uploading to 284ff8d34bc5e8ab4b78ced5296ff5fc  10485760 / 16337912.0  (64.18%)
Uploading to 284ff8d34bc5e8ab4b78ced5296ff5fc  10747904 / 16337912.0  (65.79%)
Uploading to 284ff8d34bc5e8ab4b78ced5296ff5fc  11010048 / 16337912.0  (67.39%)
Uploading to 284ff8d34bc5e8ab4b78ced5296ff5fc  11272192 / 16337912.0  (68.99%)
Uploading to 284ff8d34bc5e8ab4b78ced5296ff5fc  11534336 / 16337912.0  (70.60%)
Uploading to 284ff8d34bc5e8ab4b78ced5296ff5fc  11796480 / 16337912.0  (72.20%)
Uploading to 284ff8d34bc5e8ab4b78ced5296ff5fc  12058624 / 16337912.0  (73.81%)
Uploading to 284ff8d34bc5e8ab4b78ced5296ff5fc  12320768 / 16337912.0  (75.41%)
Uploading to 284ff8d34bc5e8ab4b78ced5296ff5fc  12582912 / 16337912.0  (77.02%)
Uploading to 284ff8d34bc5e8ab4b78ced5296ff5fc  12845056 / 16337912.0  (78.62%)
Uploading to 284ff8d34bc5e8ab4b78ced5296ff5fc  13107200 / 16337912.0  (80.23%)
Uploading to 284ff8d34bc5e8ab4b78ced5296ff5fc  13369344 / 16337912.0  (81.83%)
Uploading to 284ff8d34bc5e8ab4b78ced5296ff5fc  13631488 / 16337912.0  (83.43%)
Uploading to 284ff8d34bc5e8ab4b78ced5296ff5fc  13893632 / 16337912.0  (85.04%)
Uploading to 284ff8d34bc5e8ab4b78ced5296ff5fc  14155776 / 16337912.0  (86.64%)
Uploading to 284ff8d34bc5e8ab4b78ced5296ff5fc  14417920 / 16337912.0  (88.25%)
Uploading to 284ff8d34bc5e8ab4b78ced5296ff5fc  14680064 / 16337912.0  (89.85%)
Uploading to 284ff8d34bc5e8ab4b78ced5296ff5fc  14942208 / 16337912.0  (91.46%)
Uploading to 284ff8d34bc5e8ab4b78ced5296ff5fc  15027192 / 16337912.0  (91.98%)
Uploading to 284ff8d34bc5e8ab4b78ced5296ff5fc  15289336 / 16337912.0  (93.58%)
Uploading to 284ff8d34bc5e8ab4b78ced5296ff5fc  15551480 / 16337912.0  (95.19%)
Uploading to 284ff8d34bc5e8ab4b78ced5296ff5fc  15813624 / 16337912.0  (96.79%)
Uploading to 284ff8d34bc5e8ab4b78ced5296ff5fc  16075768 / 16337912.0  (98.40%)
Uploading to 284ff8d34bc5e8ab4b78ced5296ff5fc  16337912 / 16337912.0  (100.00%)
'str' object has no attribute 'get'

AWS CLI Version

$ aws --version
aws-cli/1.15.8 Python/3.6.3 Linux/4.13.0-38-generic botocore/1.10.8

Relevant --debug output

2018-04-25 19:41:11,986 - ThreadPoolExecutor-0_3 - botocore.hooks - DEBUG - Event needs-retry.s3.CompleteMultipartUpload: calling handler <function check_for_200_error at 0x7f04f0e2b510>
2018-04-25 19:41:11,986 - ThreadPoolExecutor-0_3 - botocore.hooks - DEBUG - Event needs-retry.s3.CompleteMultipartUpload: calling handler <botocore.retryhandler.RetryHandler object at 0x7f04eea3acf8>
2018-04-25 19:41:11,987 - ThreadPoolExecutor-0_3 - botocore.retryhandler - DEBUG - No retry needed.
2018-04-25 19:41:11,987 - ThreadPoolExecutor-0_3 - botocore.hooks - DEBUG - Event needs-retry.s3.CompleteMultipartUpload: calling handler <bound method S3RegionRedirector.redirect_from_error of <botocore.utils.S3RegionRedirector object at 0x7f04eea3afd0>>
2018-04-25 19:41:11,987 - ThreadPoolExecutor-0_3 - botocore.hooks - DEBUG - Event after-call.s3.CompleteMultipartUpload: calling handler <function enhance_error_msg at 0x7f04eedfb598>
2018-04-25 19:41:11,987 - ThreadPoolExecutor-0_3 - s3transfer.utils - DEBUG - Releasing acquire 0/None
2018-04-25 19:41:11,988 - MainThread - awscli.clidriver - DEBUG - Exception caught in main()
Traceback (most recent call last):
  File "/home/lestephane/anaconda3/lib/python3.6/site-packages/awscli/clidriver.py", line 208, in main
    return command_table[parsed_args.command](remaining, parsed_args)
  File "/home/lestephane/anaconda3/lib/python3.6/site-packages/awscli/clidriver.py", line 345, in __call__
    return command_table[parsed_args.operation](remaining, parsed_globals)
  File "/home/lestephane/anaconda3/lib/python3.6/site-packages/awscli/customizations/commands.py", line 187, in __call__
    return self._run_main(parsed_args, parsed_globals)
  File "/home/lestephane/anaconda3/lib/python3.6/site-packages/awscli/customizations/cloudformation/package.py", line 138, in _run_main
    exported_str = self._export(template_path, use_json)
  File "/home/lestephane/anaconda3/lib/python3.6/site-packages/awscli/customizations/cloudformation/package.py", line 154, in _export
    exported_template = template.export()
  File "/home/lestephane/anaconda3/lib/python3.6/site-packages/awscli/customizations/cloudformation/artifact_exporter.py", line 443, in export
    resource_type = resource.get("Type", None)
AttributeError: 'str' object has no attribute 'get'
2018-04-25 19:41:11,990 - MainThread - awscli.clidriver - DEBUG - Exiting with rc 255

'str' object has no attribute 'get'

Now I know you can use Code with either ZipFile (python or nodejs only, NOT java), or S3Key + S3Bucket (i don't have those, this is why I'm using aws cloudformation package). What is the correct way to pass a local jar?

This issue looks a lot like #3280, but since 3280 does not have enough information for me to tell if it's the same, i created this issue instead.

@lestephane
Copy link
Author

Ok I found the problem, a syntax error in my yaml template 200 lines below the resource in question. I guess i need to add the CF validate step in my pipeline to avoid this kind of problem in future.

@justnance justnance added lambda cloudformation guidance Question that needs advice or information. labels Dec 7, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cloudformation guidance Question that needs advice or information. lambda
Projects
None yet
Development

No branches or pull requests

2 participants