alexa / ask-cli

Alexa Skills Kit Command Line Interface

Home Page:https://developer.amazon.com/en-US/docs/alexa/smapi/ask-cli-intro.html

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

CFN Deployer Multi Region Stack Conflict Errors

jsetton opened this issue · comments

I'm submitting a...


[ ] Regression (a behavior that used to work and stopped working in a new release)
[x] Bug report  
[ ] Performance issue
[ ] Feature request
[ ] Documentation issue or request 
[ ] Other... Please describe: 

Current Behavior

When using a CFN deployer to deploy to all regions, it creates unnecessarily two separate stacks in the same region where the default region is located. This is causing duplicate resources being created in that region and more importantly stack conflict errors when non-unique resource names are configured in the stack template. Such as using the custom Lambda function name solution listed here for example.

$ ask deploy
Deploy configuration loaded from ask-resources.json
Deploy project for profile [default]

==================== Deploy Skill Metadata ====================
[Warn]: The hash of current skill package folder does not change compared to the last deploy hash result, CLI will skip the deploy of skill package.
Skill ID: <skillId>

==================== Build Skill Code ====================
Skill code built successfully.
Code for region default+NA+EU+FE built to <skillPath/lambda/build.zip successfully with build flow NodeJsNpmBuildFlow.

==================== Deploy Skill Infrastructure ====================
  ✔ Deploy Alexa skill infrastructure for region "default"
  ✖ Deploy Alexa skill infrastructure for region "NA"
  ✔ Deploy Alexa skill infrastructure for region "EU"
  ✔ Deploy Alexa skill infrastructure for region "FE"
[Error]: CliError: The CloudFormation deploy failed for Alexa region "NA": AlexaSkillFunction[AWS::Lambda::Function]  CREATE_FAILED (<functionName> already exists in stack <stackArn>)

Expected Behavior

The CFN deployer should only create one stack in the default region when it is setup to deploy to all regions. The resources for the default region should be shared with the relevant region (e.g. default <-> NA). This is how it was working in ASK CLI v1.

Your Environment and Context

  • ask-cli version: 2.22.4

To add to the fact it was working in ASK CLI v1, here is a snippet of the .ask/config showing that a given Lambda function could have both the default and the relevant region preventing unnecessary resources from being deployed.

{
  "deploy_settings": {
    "default": {
        [...]
        "lambda": [
          {
            "alexaUsage": [
              "custom/default",
              "custom/NA"
            ],
            "arn": "<lambdaArnNA>",
            "awsRegion": "us-east-1",
            "codeUri": "lambda/custom",
            "functionName": "<functionName>",
            "handler": "<handler>",
            "revisionId": "<revisionId>",
            "runtime": "<runtime>"
          },
          {
            "alexaUsage": [
              "custom/EU"
            ],
            "arn": "<lambdaArnEU>",
            "awsRegion": "eu-west-1",
            "codeUri": "lambda/custom",
            "functionName": "<functionName>",
            "handler": "<handler>",
            "revisionId": "<revisionId>",
            "runtime": "<runtime>"
          },
          {
            "alexaUsage": [
              "custom/FE"
            ],
            "arn": "<lambdaArnFE>",
            "awsRegion": "us-west-2",
            "codeUri": "lambda/custom",
            "functionName": "<functionName>",
            "handler": "<handler>",
            "revisionId": "<revisionId>",
            "runtime": "<runtime>"
          }
        ]
      }
    }
  }
}