Skip to content

Unsuccessful stack creates being seen as successful in certain scenarios #2087

Closed

Description

@colbywhite

This is a Bug

Description

If the initial CREATE of the stack fails and successfully rolls back, sls thinks the CREATE succeeded and continues on when it shouldn't. You can recreate this by using an AWS user that doesn't have s3:CreateBucket permission. The initial bucket will fail to create, then the stack will successfully rollback. But sls thinks the operation was successful and continues on.

    $ sls deploy -v
Serverless: Creating Stack...
Serverless: Checking Stack create progress...
CloudFormation - CREATE_IN_PROGRESS - AWS::CloudFormation::Stack - why82-lambda-prod
CloudFormation - CREATE_IN_PROGRESS - AWS::S3::Bucket - ServerlessDeploymentBucket
CloudFormation - CREATE_FAILED - AWS::S3::Bucket - ServerlessDeploymentBucket
CloudFormation - DELETE_IN_PROGRESS - AWS::CloudFormation::Stack - why82-lambda-prod
CloudFormation - DELETE_COMPLETE - AWS::S3::Bucket - ServerlessDeploymentBucket
CloudFormation - DELETE_COMPLETE - AWS::CloudFormation::Stack - why82-lambda-prod
Serverless: Stack create finished...
Serverless: Packaging service...
Serverless Error ---------------------------------------

 Stack with id myservice-prod does not exist

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

Since the user I was using didn't have the correct AWS perms, the bucket had a CREATE_FAILED. I'd expect it to detect that even though it successfully completed in the sense it successfully deleted itself (aka rolled back), it did not successfully create the stack and thus future commands are going to fail. So fail right when the stack is done rolling back.

Additional Data

  • _Serverless Framework Version you're using_: 1.0.0-rc.1
  • _Operating System_: Mac
  • _Stack Trace_: Above
  • _Provider Error messages_: It complained that it couldn't create the bucket because of my AWS perms, which is expected.

Activity

  1. added this to the V1.0 milestone on Sep 12, 2016
  2. flomotlik commented on Sep 12, 2016

    @flomotlik
    Contributor

    Yup thanks for reporting. Definitely a bug that needs to be fixed!

  3. rowanu commented on Sep 13, 2016

    @rowanu
    Contributor

    In my testing for this problem, I also discovered an intermittent race-condition - sometimes the CREATE_FAILED bucket error happens in-between the polling interval, so sls doesn't know why the stack is being deleted.

    Fixing the original issue seems to be a simple as adding DELETE_COMPLETE to the list of invalidStatuses (which could probably be more appropriately named failureStatuses - they're completely valid CFN statuses, just indicative of a failure), as that's the status an initial failed deployment due to lack of S3 permissions ends up with.

    Handling the race condition (when sls never sees the error) would be considerably harder and more complex. @flomotlik are you happy with just a fix for the reported bug?

  4. flomotlik commented on Sep 13, 2016

    @flomotlik
    Contributor

    Imho we should change the onFailure behaviour of the create-stack call from Delete to Do_Nothing or Rollback because I think the Delete is causing more trouble than its worth. It hides the stack and makes debugging much harder.

    Then this bug and the race condition you mentioned should also be gone

  5. rowanu commented on Sep 13, 2016

    @rowanu
    Contributor

    @flomotlik I like it; It will make failures easier to troubleshoot (because you'll be able to see the results immediately in the console), and it will remove this (and future similar) race conditions.

    I will PR.

  6. M1chaelTran commented on Sep 21, 2016

    @M1chaelTran

    @colbywhite how did you end up resolving the error? CREATE_FAILED - AWS::S3::Bucket - ServerlessDeploymentBucket

    What is the minimum permission required for it to work?

  7. colbywhite commented on Sep 21, 2016

    @colbywhite
    ContributorAuthor

    The minimum for exact part where it borked for me is simply a s3:CreateBucket. But if you're looking for the minimum for SLS to do it's full suite of things, there are some tickets around where I think people figured that out. I think this comment on #1439 may be the most thorough I've seen.

    To be more direct about your question though, I ended up with a hacky troposphere script to create my user with the set of perms that I needed. For the full suite of perms SLS needs for everything it does, start with that above comment.

  8. ilyakatz commented on Oct 4, 2016

    @ilyakatz

    so is it required to have s3:CreateBucket permissions to be able to deploy? Does the deploy create a new bucket for each deploy?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions