Skip to content

issues with blank-nodejs #193

@furnaceX

Description

@furnaceX

I had trouble doing the tutorial for blank-nodejs.

First, it didn't work with AWS CLI v1. Step 3 (./3-deploy.sh) failed as the command aws cloudformation wasn't supported. So I updated to CLI v2.

Then on the Invoke step (./4-invoke.sh), I got the following response, which doesn't match the results listed in the tutorial:

Invalid base64: "{
  "Records": [
    {
      "messageId": "19dd0b57-b21e-4ac1-bd88-01bbb068cb78",
      "receiptHandle": "MessageReceiptHandle",
      "body": "Hello from SQS!",
      "attributes": {
        "ApproximateReceiveCount": "1",
        "SentTimestamp": "1523232000000",
        "SenderId": "123456789012",
        "ApproximateFirstReceiveTimestamp": "1523232000001"
      },
      "messageAttributes": {},
      "md5OfBody": "7b270e59b47ff90a553787216d55d91d",
      "eventSource": "aws:sqs",
      "eventSourceARN": "arn:aws:sqs:us-west-2:123456789012:MyQueue",
      "awsRegion": "us-west-2"
    }
  ]
}
"

So then I ran the tests:

./0-run-tests.sh
Installing libraries...
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@2.1.3 (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.1.3: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

added 539 packages from 416 contributors and audited 540 packages in 11.206s

12 packages are looking for funding
  run `npm fund` for details

found 0 vulnerabilities


> blank-nodejs@1.0.0 test /development/aws-lambda-developer-guide/sample-apps/blank-nodejs
> jest

 PASS  function/index.test.js
  ✓ Runs function handler (97ms)

  console.log
    Hello from SQS!

      at forEach (function/index.js:10:13)
          at Array.forEach (<anonymous>)

  console.log
    ## ENVIRONMENT VARIABLES: {
      "LESSOPEN": "| /usr/bin/lesspipe %s",
      "npm_package_devDependencies_aws_sdk": "2.631.0",
      "npm_package_dependencies_aws_xray_sdk_core": "1.1.2",
      "npm_config_cache_lock_stale": "60000",
      "npm_config_ham_it_up": "",
      "CURL_CA_BUNDLE": "/opt/bitnami/common/openssl/certs/curl-ca-bundle.crt",
      "npm_config_legacy_bundling": "",
      "npm_config_sign_git_tag": "",
      "MAIL": "/var/mail/scott",
      "SSH_CLIENT": "97.118.111.213 51125 22",
      "USER": "scott",
      "BITNAMI_ROOT": "/opt/bitnami",
      "LANGUAGE": "en_US.UTF-8",
      "GIT_TEMPLATE_DIR": "/opt/bitnami/git/share/git-core/templates",
      "SASL_CONF_PATH": "/opt/bitnami/common/etc",
      "npm_package_devDependencies_jest": "25.4.0",
      "npm_config_user_agent": "npm/6.14.5 node/v12.14.1 linux x64",
      "npm_config_always_auth": "",
      "FONTCONFIG_PATH": "/opt/bitnami/common/etc/fonts",
      "GIT_EXEC_PATH": "/opt/bitnami/git/libexec/git-core/",
      "SASL_PATH": "/opt/bitnami/common/lib/sasl2",
      "CXXFLAGS": "-I/opt/bitnami/common/include -I/opt/bitnami/common/include ",
      "npm_config_bin_links": "true",
      "npm_config_key": "",
      "npm_config_allow_same_version": "",
      "npm_config_description": "true",
      "npm_config_fetch_retries": "2",
      "npm_config_heading": "npm",
      "npm_config_if_present": "",
      "npm_config_init_version": "1.0.0",
      "npm_config_user": "",
      "npm_node_execpath": "/opt/bitnami/nodejs/bin/.node.bin",
      "SHLVL": "2",
      "LD_LIBRARY_PATH": "/opt/bitnami/redis/lib:/opt/bitnami/python/lib:/opt/bitnami/git/lib:/opt/bitnami/apache2/lib:/opt/bitnami/common/lib:/opt/bitnami/common/lib64",
      "GIT_SSL_CAINFO": "/opt/bitnami/common/openssl/certs/curl-ca-bundle.crt",
      "LDAPCONF": "/opt/bitnami/common/etc/openldap/ldap.conf",
      "npm_config_prefer_online": "",
      "npm_config_noproxy": "",
      "HOME": "/home/scott",
      "TERMINFO": "/opt/bitnami/common/share/terminfo",
      "npm_config_force": "",
      "SSH_TTY": "/dev/pts/0",
      "npm_config_only": "",
      "npm_config_read_only": "",
      "npm_config_cache_min": "10",
      "npm_config_init_license": "ISC",
      "LDFLAGS": "-L/opt/bitnami/common/lib -L/opt/bitnami/common/lib ",
      "npm_config_editor": "vi",
      "npm_config_rollback": "true",
      "npm_config_tag_version_prefix": "v",
      "SSL_CERT_FILE": "/opt/bitnami/common/openssl/certs/curl-ca-bundle.crt",
      "OPENSSL_ENGINES": "/opt/bitnami/common/lib/engines",
      "npm_config_cache_max": "Infinity",
      "npm_config_timing": "",
      "npm_config_userconfig": "/home/scott/.npmrc",
      "npm_config_engine_strict": "",
      "npm_config_init_author_name": "",
      "npm_config_init_author_url": "",
      "npm_config_preid": "",
      "npm_config_tmp": "/tmp",
      "npm_package_description": "This sample application is a Lambda function that calls the Lambda API. It shows the use of logging, environment variables, AWS X-Ray tracing, layers, unit tests and the AWS SDK. You can use it to learn about Lambda features or use it as a starting point for your own projects.",
      "npm_config_depth": "Infinity",
      "npm_config_package_lock_only": "",
      "npm_config_save_dev": "",
      "npm_config_usage": "",
      "npm_package_readmeFilename": "README.md",
      "npm_config_metrics_registry": "https://registry.npmjs.org/",
      "npm_config_cafile": "",
      "npm_config_otp": "",
      "npm_config_package_lock": "true",
      "npm_config_progress": "true",
      "npm_config_https_proxy": "",
      "npm_config_save_prod": "",
      "npm_config_audit": "true",
      "npm_config_cidr": "",
      "npm_config_onload_script": "",
      "npm_config_sso_type": "oauth",
      "LOGNAME": "scott",
      "npm_config_rebuild_bundle": "true",
      "npm_config_save_bundle": "",
      "npm_config_shell": "/bin/bash",
      "_": "/opt/bitnami/nodejs/bin/npm",
      "npm_package_private": "true",
      "npm_config_dry_run": "",
      "npm_config_format_package_lock": "true",
      "npm_config_prefix": "/opt/bitnami/nodejs",
      "MAGICK_CONFIGURE_PATH": "/opt/bitnami/common/lib/ImageMagick-6.9.8/config-Q16:/opt/bitnami/common/",
      "OPENSSL_CONF": "/opt/bitnami/common/openssl/openssl.cnf",
      "PKG_CONFIG_PATH": "/opt/bitnami/common/lib64/pkgconfig:/opt/bitnami/common/lib/pkgconfig",
      "npm_config_scope": "",
      "npm_config_browser": "",
      "npm_config_cache_lock_wait": "10000",
      "npm_config_ignore_prepublish": "",
      "npm_config_registry": "https://registry.npmjs.org/",
      "npm_config_save_optional": "",
      "npm_config_searchopts": "",
      "npm_config_versions": "",
      "XDG_SESSION_ID": "195",
      "TERM": "xterm",
      "npm_config_cache": "/home/scott/.npm",
      "npm_config_proxy": "",
      "npm_config_send_metrics": "",
      "npm_config_global_style": "",
      "npm_config_ignore_scripts": "",
      "npm_config_version": "",
      "npm_config_local_address": "",
      "npm_config_viewer": "man",
      "npm_config_node_gyp": "/opt/bitnami/nodejs/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js",
      "PATH": "/opt/bitnami/nodejs/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/development/aws-lambda-developer-guide/sample-apps/blank-nodejs/node_modules/.bin:/home/scott/bin:/home/scott/.local/bin:/opt/bitnami/redis/bin:/opt/bitnami/python/bin:/opt/bitnami/nodejs/bin:/opt/bitnami/git/bin:/opt/bitnami/letsencrypt/:/opt/bitnami/apache2/bin:/opt/bitnami/common/bin:/opt/bitnami/redis/bin:/opt/bitnami/python/bin:/opt/bitnami/nodejs/bin:/opt/bitnami/git/bin:/opt/bitnami/letsencrypt/:/opt/bitnami/apache2/bin:/opt/bitnami/common/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin",
      "npm_package_name": "blank-nodejs",
      "npm_config_audit_level": "low",
      "npm_config_prefer_offline": "",
      "NODE": "/opt/bitnami/nodejs/bin/.node.bin",
      "XDG_RUNTIME_DIR": "/run/user/1001",
      "CFLAGS": "-I/opt/bitnami/common/include/ImageMagick -I/opt/bitnami/common/include -I/opt/bitnami/common/include/ImageMagick -I/opt/bitnami/common/include ",
      "npm_config_color": "true",
      "npm_config_sign_git_commit": "",
      "MAGICK_CODER_MODULE_PATH": "/opt/bitnami/common/lib/ImageMagick-6.9.8/modules-Q16/coders",
      "npm_config_fetch_retry_mintimeout": "10000",
      "npm_config_maxsockets": "50",
      "npm_config_offline": "",
      "npm_config_sso_poll_frequency": "500",
      "LANG": "en_US.UTF-8",
      "MAGICK_HOME": "/opt/bitnami/common",
      "npm_config_umask": "0002",
      "LS_COLORS": "rs=0:di=01;34:ln=01;36:mh=00:pi=40;33:so=01;35:do=01;35:bd=40;33;01:cd=40;33;01:or=40;31;01:mi=00:su=37;41:sg=30;43:ca=30;41:tw=30;42:ow=34;42:st=37;44:ex=01;32:*.tar=01;31:*.tgz=01;31:*.arc=01;31:*.arj=01;31:*.taz=01;31:*.lha=01;31:*.lz4=01;31:*.lzh=01;31:*.lzma=01;31:*.tlz=01;31:*.txz=01;31:*.tzo=01;31:*.t7z=01;31:*.zip=01;31:*.z=01;31:*.Z=01;31:*.dz=01;31:*.gz=01;31:*.lrz=01;31:*.lz=01;31:*.lzo=01;31:*.xz=01;31:*.bz2=01;31:*.bz=01;31:*.tbz=01;31:*.tbz2=01;31:*.tz=01;31:*.deb=01;31:*.rpm=01;31:*.jar=01;31:*.war=01;31:*.ear=01;31:*.sar=01;31:*.rar=01;31:*.alz=01;31:*.ace=01;31:*.zoo=01;31:*.cpio=01;31:*.7z=01;31:*.rz=01;31:*.cab=01;31:*.jpg=01;35:*.jpeg=01;35:*.gif=01;35:*.bmp=01;35:*.pbm=01;35:*.pgm=01;35:*.ppm=01;35:*.tga=01;35:*.xbm=01;35:*.xpm=01;35:*.tif=01;35:*.tiff=01;35:*.png=01;35:*.svg=01;35:*.svgz=01;35:*.mng=01;35:*.pcx=01;35:*.mov=01;35:*.mpg=01;35:*.mpeg=01;35:*.m2v=01;35:*.mkv=01;35:*.webm=01;35:*.ogm=01;35:*.mp4=01;35:*.m4v=01;35:*.mp4v=01;35:*.vob=01;35:*.qt=01;35:*.nuv=01;35:*.wmv=01;35:*.asf=01;35:*.rm=01;35:*.rmvb=01;35:*.flc=01;35:*.avi=01;35:*.fli=01;35:*.flv=01;35:*.gl=01;35:*.dl=01;35:*.xcf=01;35:*.xwd=01;35:*.yuv=01;35:*.cgm=01;35:*.emf=01;35:*.ogv=01;35:*.ogx=01;35:*.aac=00;36:*.au=00;36:*.flac=00;36:*.m4a=00;36:*.mid=00;36:*.midi=00;36:*.mka=00;36:*.mp3=00;36:*.mpc=00;36:*.ogg=00;36:*.ra=00;36:*.wav=00;36:*.oga=00;36:*.opus=00;36:*.spx=00;36:*.xspf=00;36:",
      "npm_config_fund": "true",
      "npm_config_fetch_retry_maxtimeout": "60000",
      "npm_config_loglevel": "notice",
      "npm_config_logs_max": "10",
      "npm_config_message": "%s",
      "npm_lifecycle_script": "jest",
      "npm_package_scripts_test": "jest",
      "npm_config_ca": "",
      "npm_config_cert": "",
      "npm_config_global": "",
      "npm_config_link": "",
      "SHELL": "/bin/bash",
      "NODE_PATH": "/opt/bitnami/nodejs/lib/node_modules",
      "npm_package_version": "1.0.0",
      "npm_config_access": "",
      "npm_config_also": "",
      "npm_config_save": "true",
      "npm_config_unicode": "true",
      "npm_lifecycle_event": "test",
      "AWS_REGION": "us-east-2",
      "npm_config_argv": "{\"remain\":[],\"cooked\":[\"run\",\"test\"],\"original\":[\"run\",\"test\"]}",
      "npm_config_before": "",
      "npm_config_long": "",
      "npm_config_production": "",
      "npm_config_searchlimit": "20",
      "npm_config_unsafe_perm": "true",
      "npm_config_update_notifier": "true",
      "LESSCLOSE": "/usr/bin/lesspipe %s %s",
      "npm_config_auth_type": "legacy",
      "npm_config_node_version": "12.14.1",
      "npm_config_tag": "latest",
      "npm_config_git_tag_version": "true",
      "npm_config_commit_hooks": "true",
      "npm_config_script_shell": "",
      "npm_config_shrinkwrap": "true",
      "npm_config_fetch_retry_factor": "10",
      "npm_config_save_exact": "",
      "npm_config_strict_ssl": "true",
      "npm_config_dev": "",
      "npm_config_globalconfig": "/opt/bitnami/nodejs/etc/npmrc",
      "npm_config_init_module": "/home/scott/.npm-init.js",
      "npm_config_parseable": "",
      "LC_ALL": "en_US.UTF-8",
      "PWD": "/development/aws-lambda-developer-guide/sample-apps/blank-nodejs",
      "npm_config_globalignorefile": "/opt/bitnami/nodejs/etc/npmignore",
      "npm_execpath": "/opt/bitnami/nodejs/lib/node_modules/npm/bin/npm-cli.js",
      "SSH_CONNECTION": "97.118.111.213 51125 172.31.20.187 22",
      "XDG_DATA_DIRS": "/usr/local/share:/usr/share:/var/lib/snapd/desktop",
      "npm_config_cache_lock_retries": "10",
      "npm_config_searchstaleness": "900",
      "npm_config_node_options": "",
      "npm_config_save_prefix": "^",
      "npm_config_scripts_prepend_node_path": "warn-only",
      "npm_config_group": "1003",
      "npm_config_init_author_email": "",
      "npm_config_searchexclude": "",
      "npm_config_git": "git",
      "npm_config_optional": "true",
      "npm_config_json": "",
      "INIT_CWD": "/development/aws-lambda-developer-guide/sample-apps/blank-nodejs",
      "NODE_ENV": "test",
      "JEST_WORKER_ID": "1"
    }

      at Object.handler (function/index.js:12:11)

  console.log
    ## CONTEXT: null

      at Object.handler (function/index.js:13:11)

  console.log
    ## EVENT: {
      "Records": [
        {
          "messageId": "19dd0b57-b21e-4ac1-bd88-01bbb068cb78",
          "receiptHandle": "MessageReceiptHandle",
          "body": "Hello from SQS!",
          "attributes": {
            "ApproximateReceiveCount": "1",
            "SentTimestamp": "1523232000000",
            "SenderId": "123456789012",
            "ApproximateFirstReceiveTimestamp": "1523232000001"
          },
          "messageAttributes": {},
          "md5OfBody": "7b270e59b47ff90a553787216d55d91d",
          "eventSource": "aws:sqs",
          "eventSourceARN": "arn:aws:sqs:us-west-2:123456789012:MyQueue",
          "awsRegion": "us-west-2"
        }
      ]
    }

      at Object.handler (function/index.js:14:11)

Test Suites: 1 passed, 1 total
Tests:       1 passed, 1 total
Snapshots:   0 total
Time:        1.895s
Ran all test suites.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions