question

Randy Thompson avatar image
Randy Thompson asked

sourceDir moved in v1?

After updating my ASK CLI to v1 (aka, 1.1.2), my lambda uploads...

ask deploy -t lambda

...kept resulting in a "Path must be a string" error. I discovered that ASK CLI now looks for the sourceDir field inside skill.json's apis.custom.regions[region].endpoint as opposed to apis.custom.endpoint.

  1. Is this documented somewhere (I had to sift through the ask-cli Javascript to debug this)?
  2. Am I doing this correctly now, or is there a better place to put the path to my lambda code than in apis.custom.regions[region].endpoint.sourceDir ?
  3. Did apis.custom.endpoint die with ASK CLI v0 (can I remove it from the skill.json manifest now that I'm using v1)?

Thanks,

-Randy

alexa skills kitlambdaask cli
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Ron Wang avatar image
Ron Wang answered

Hi Randy,

Thanks for providing your opinions to us! I think for your issue, we need to clarify 2 aspects. Hope this will solve your questions:

1. Usage of sourceDir and URI. It's obvious those fields come as a pair to indicate the local and remote information of Lambda function. However, we still recommend store sourceDir in skill.json and uri in .ask/config, because in this way we can promise the portability of skill package by setting the internal package relationship to skill.json.

.ask/config
  "endpoint": {
    "uri": "arn:aws:lambda:......"
  }

skill.json
  "apis": {
    "custom": {
      "endpoint": {
        "sourceDir": "./lambda"
      }
    }
  }

2. For a valid skill using Lambda function, it must have a default endpoint. If you want to specify the endpoint for certain region, you can explicitly set it inside "regions" field, which is not a required field.

"apis": { 
  "custom": {
    "endpoint": {
      "sourceDir": "./lambda"       // defalt endpoint
    },
    "regions": {
      "NA": {
        "endpoint": {
          "sourceDit": "./another_lambda_folder"     // Regional endpoint
        }
      }
    }
  }
}

Let us know if this two tips would help you!

Thanks,

Ron

10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Brian@Amazon avatar image
Brian@Amazon answered

Hello, I'm looking into this and will get back to you when I have more information.

10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

AwesomeAaron@AMZN avatar image
AwesomeAaron@AMZN answered

There should not be any differences between those two versions.

Do you mind to share your skill.json (delete all the confidential stuff) to help us debug this issue?

Thank you very much

Aaron

10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Randy Thompson avatar image
Randy Thompson answered

>Do you mind to share your skill.json

Sure.

When my skill.json file had an apis section that looked like this:

"apis": {
            "custom": {
                "endpoint": {
                    "sourceDir": "./lambda",
                    "uri": "arn:aws:lambda:blahblahblah:MySkill"
                },
                "interfaces": []
            }
        },

I received a "Path must be a string" error when I issued this ASK CLI command to upload the code found in ./lambda:

ask deploy -t lambda

I did not have this issue in the older (v0) version of ASK CLI. With v1 (aka, 1.1.2) of ASK CLI, I had to change the apis section of my skill.json file to this:

"apis": {
      "custom": {
        "regions": {
            "NA": {
                "endpoint": {
                  "sourceDir": "./lambda",
                  "uri": "arn:aws:lambda:blahblahblah:MySkill"
                }
            }
        },
        "interfaces": []
      }
    },

Then, issuing an "ask deploy -t lambda" worked.

I could provide much more of the skill.json file if you think it relevant.

-Randy

10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

AwesomeAaron@AMZN avatar image
AwesomeAaron@AMZN answered

Hi Randy,

We cannot reproduce this error. Might it be the config problem? Do you mind sharing the config file which located at {theSkillPackage}/.ask/config

Note: CLI will look at the "merge" object inside the config file and combine it with the skill.json at runtime. I think that could be the problem.

1 comment
10 |5000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Ah, I'll bet you're right. Here is my config file:

{
  "deploy_settings": {
    "default": {
      "skill_id": "amzn1.ask.skill....",
      "was_cloned": false,
      "merge": {
        "manifest": {
          "apis": {
            "custom": {
              "endpoint": {
                "sourceDir": "./lambda",
                "uri": "arn:aws:lambda:blahblahblah:MySkill"
              },
              "regions": {
                "NA": {
                  "endpoint": {
                    "uri": "arn:aws:lambda:blahblahblah:MySkill"
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}

I should probably have the sourceDir field in the regions.NA.endpoint section as well? In any case, I'm not sure why upgrading to ASK CLI v1 made an issue out of this.

Where is the "official" place to specify the sourceDir? I'm a big fan of minimalism, so if it can be in just one file -- either config or skill.json -- and one place in that file, please let me know where that would be.

Thanks again.

-Randy

0 Likes 0 ·