简体   繁体   中英

Ask-cli lambda command uses wrong region setting

I am trying to set up a workflow via the ask-cli for developing an Amazon skill with an Amazon lambda backend. I have created a skill and it works fine when using "ask api ..." commands, but when I use an "ask lambda ..." command, such as "ask lambda download -f MySkill", it uses the wrong region setting. I get the error:

ResourceNotFoundException: Function not found: arn:aws:lambda:us-east-1:123456789:function:MySkill

As you can see, it is looking for the lambda instance in us-east-1. But My lambda instance is in eu-west-1, as specified in my skill.json file below. This questions is pretty much a duplicate of https://forums.developer.amazon.com/questions/87922/ask-cli-does-not-use-region-setting-from-aws-confi.html . The answer in that question implies that you can add a region field somewhere in one of the json files, but I can't figure out where. Any help would be appreciated.

This is my ~/.ask/cli_config

{
  "profiles": {
    "default": {
      "aws_profile": "default",
      "token": {
        "access_token": "My_access_token",
        "refresh_token": "My_refresh_token",
        "token_type": "bearer",
        "expires_in": 3600,
        "expires_at": "2017-10-06T14:12:26.171Z"
      },
      "vendor_id": "My_vendor_id"
    }
  }
}

this is my ~/.aws/config

[default]
output = text
region = eu-west-1

This is my skill.json, that i get when i call: "ask api get-skill -s skill_id > skill.json"

{
  "skillManifest": {
    "publishingInformation": {
      "locales": {
        "en-GB": {
          "name": "My Skill"
        }
      },
      "isAvailableWorldwide": true,
      "category": "PUBLIC_TRANSPORTATION",
      "distributionCountries": []
    },
    "apis": {
      "custom": {
        "endpoint": {
          "uri": "arn:aws:lambda:eu-west-1:123456789:function:MySkill"
        },
        "interfaces": []
      }
    },
    "manifestVersion": "1.0"
  }
}

for me it works if I edit the following file:

~/.aws/credentials (Linux, macOS, or Unix)

C:\\Users\\USERNAME\\.aws\\credentials (Windows)

[ask_cli_default]
aws_access_key_id=YOUR_AWS_ACCESS_KEY
aws_secret_access_key=YOUR_AWS_SECRET_KEY
region=eu-west-1

The region os specified in the lambda section of .ask/config . Example:

        "lambda": [
          {
            "alexaUsage": [
              "custom/default"
            ],
            "arn": "arn:aws:lambda:eu-west-1:XXXXXXXXX:function:ask-premium-hello-world",
            "awsRegion": "eu-west-1",
            "codeUri": "lambda/custom",
            "functionName": "ask-premium-hello-world",
            "handler": "index.handler",
            "revisionId": "XXXXXXXXXXXXXXXXXX",
            "runtime": "nodejs8.10"
          }
        ]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM