serverless-heaven / serverless-aws-alias

Alias support for Serverless 1.x
MIT License
189 stars 68 forks source link

Unresolved resource dependencies #125

Open AnthonyWC opened 6 years ago

AnthonyWC commented 6 years ago

Using a combination of the alias + stepfunction plugin caused the following error:

(I am guessing that alias plugin doesn't understand that stepfunction plugin has changed the resource name, e.g. - to Dash)

/app # serverless deploy
Serverless: Packaging service...
Serverless: Excluding development dependencies...
Serverless: Tracing ENABLED for function "dataeng-buildkite-test"
AWS Pseudo Parameters
AWS Pseudo Parameter: Resources::IamRoleLambdaExecution::Properties::Policies::0::PolicyDocument::Statement::3::Resource Replaced AWS::Region wi
th ${AWS::Region}
AWS Pseudo Parameter: Resources::IamRoleLambdaExecution::Properties::RoleName::Fn::Join::1::2 Replaced AWS::Region with ${AWS::Region}
AWS Pseudo Parameter: Resources::IamRoleStateMachineExecution::Properties::AssumeRolePolicyDocument::Statement::0::Principal::Service Replaced A
WS::Region with ${AWS::Region}
AWS Pseudo Parameter: Resources::IamRoleStateMachineExecution::Properties::Policies::0::PolicyName Replaced AWS::Region with ${AWS::Region}
AWS Pseudo Parameter: Resources::DataengDashbuildkiteDashtest::Properties::DefinitionString Replaced AWS::Region with ${AWS::Region}
AWS Pseudo Parameter: Resources::DataengDashbuildkiteDashtest::Properties::DefinitionString Replaced AWS::AccountId with ${AWS::AccountId}
AWS Pseudo Parameter: Resources::DataengDashsitetrackerDashrtDashatDashingestScheduleToStepFunctionsRole::Properties::Policies::0::PolicyName Re
placed AWS::Region with ${AWS::Region}
Serverless: Preparing alias ...
Serverless: Uploading CloudFormation file to S3...
Serverless: Uploading artifacts...
Serverless: Uploading service .zip file to S3 (29.34 MB)...
Serverless: Validating template...
Serverless: Updating Stack...
Serverless: Checking Stack update progress...
...........
Serverless: Stack update finished...
Serverless: Uploading CloudFormation alias file to S3...
Serverless: Updating alias stack...

  Serverless Error ---------------------------------------

  Template format error: Unresolved resource dependencies [DataengDashbuildkiteDashtestAlias, DataengDashsitetrackerDashrtDashatDashingestSchedu
leToStepFunctionsRoleAlias] in the Resources block of the template

  Get Support --------------------------------------------
     Docs:          docs.serverless.com
     Bugs:          github.com/serverless/serverless/issues
     Issues:        forum.serverless.com

  Your Environment Information -----------------------------
     OS:                     linux
     Node Version:           8.11.2
     Serverless Version:     1.27.3
---
service: dataeng-buildkite-test

provider:
  name: aws
  runtime: nodejs8.10
  stage: dev
  region: us-east-1
  tracing: true
  iamRoleStatements:
    - Sid: CloudWatchLog
      Effect: Allow
      Action:
        - logs:*
      Resource:
        "arn:aws:logs:::*"

functions:
  default:
    name: ${self:service}
    handler: src/index.handler

stepFunctions: ${file(./state-machine.yml)}
---
stateMachines:
  dataeng-state-machine:
    name: "${self:service}"
    definition:
      Comment: "Test stage"
      StartAt: LoadConfiguration
      States:
        LoadConfiguration:
          Type: Task
          Resource: arn:aws:lambda:#{AWS::Region}:#{AWS::AccountId}:function:dataeng-buildkite-test:${self:provider.stage}
          End: true

Also if step-function itself reference an alias version of the function; then deployment will also fail since the alias function has not been created yet; and one cannot deploy alias version of function without first deploying service. So I had to deploy the service w/o step-function first then add the step-function part also but it still fails w/ above.

Also opened issue here: https://github.com/horike37/serverless-step-functions/issues/127

HyperBrain commented 6 years ago

Hi @AnthonyWC , regarding the dash I can confirm that it is a bug in the alias plugin, because it does not use the Serverless function name transform. This has to be fixed.

For the step-functions, did you try to reverse the order of the two plugins in serverless.yml?

AnthonyWC commented 6 years ago

If you mean the order under plugins in serverless.yml; I wasn't aware that the order makes a difference (is that documented anywhere..) but I did try both as you suggested; it still gave me error though.

Since step-function itself reference lambda arn resource that itself is aliased, in order for the plugin to work it will have to reference the actual arn with alias in the arn:alias format.

HyperBrain commented 6 years ago

Yes, the order is important and defines the order of the hook executions, so the order in which the plugins are called.

Regarding the dashes, there is a workaround: You can define your function (the property) in your serverless.yml without dashes, but add a name property to the function where you set the name with dashes. Serverless will use that name to create the function and the alias plugin will reference it correctly.

Do you use @horike37 's step function plugin?

AnthonyWC commented 6 years ago

ok good to know there is a workaround; although I am no longer using alias. And yes I am using the step-function from horike37.

ericson-cepeda commented 5 years ago

ok good to know there is a workaround; although I am no longer using alias. And yes I am using the step-function from horike37.

@AnthonyWC, what lib did you decide to use instead?

marcossantiago commented 4 years ago

I was facing the exact same issue and the workaround for me was to disable the events portion of the Step function.

      # events:
      # - schedule: rate(2 hours)
      #   enabled: true