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

Function creation failed because the function already exists #416

Closed
paul-uz opened this issue Oct 25, 2021 · 2 comments
Closed

Function creation failed because the function already exists #416

paul-uz opened this issue Oct 25, 2021 · 2 comments

Comments

@paul-uz
Copy link

paul-uz commented Oct 25, 2021

I'm coming back to an alexa project after 9 months, and I'm having issues deploying it from my machine using the ask cli.

Previously, in #336 I had asked about deploying using the CFN deployer but using a pre-existing lambda function.

I have created my function in AWS, and added a Alexa Skill Set trigger.

I have then ran ask init and used the skill Id from the alexa dashboard.

I have modified the following files:

stack-skill.yaml

Parameters:
  ...
  LambdaName:
    Type: String
  ...
Resources:
  ...
  AlexaSkillFunction:
    Type: AWS::Lambda::Function
    Properties:
      FunctionName: !Ref LambdaName
      ...

ask-resources.json

      "skillInfrastructure": {
        "type": "@ask-cli/cfn-deployer",
        "userConfig": {
          "runtime": "nodejs12.x",
          "handler": "index.handler",
          "templatePath": "./infrastructure/cfn-deployer/skill-stack.yaml",
          "awsRegion": "eu-west-1",
          "cfn": {
            "parameters": {
              "LambdaName": "My-Amazon-Alexa-Skill"
            }
          }
        }
      }

skill.json

"apis": {
      "custom": {
        "endpoint": {
          "uri": "arn:aws:lambda:eu-west-1:XXXXXXXXXXXX:function:My-Amazon-Alexa-Skill"
        }
      }
    },

The error I get in the CLI is as follows:

The CloudFormation deploy failed for Alexa region "default": AlexaSkillFunction[AWS::Lambda::Function] CREATE_FAILED (Resource handler returned message: "Function creation failed because the function already exists" (RequestToken: e89dd224-baa8-8980-fff1-28a49d3dcbca, HandlerErrorCode: AlreadyExists))

There is no AlexaSkillFunction lambda for eu-west-1 in that account. It should also be using the pre-exisitng lambda anyway.

Can someone help me figure out how to use th cfn deployer with my pre-existing lambda?

@jsetton
Copy link
Contributor

jsetton commented Oct 27, 2021

Can someone help me figure out how to use th cfn deployer with my pre-existing lambda?

This is how CloudFormation stack deployment works. You are better off using @ask-cli/lambda-deployer instead to achieve what you want.

@CamdenFoucht
Copy link
Contributor

@jsetton is correct, that is the expected behavior of CloudFormation. If you have any problems using the lambda-deployer to achieve this please create a new issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants