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

Ensure that disabled rules don't execute while running a sls remove #124

Merged
merged 2 commits into from
Jan 28, 2024

Conversation

VirtualVirtuoso
Copy link
Contributor

There's a bug where if you have a disabled sync rule, like so:

  s3Sync:
    - bucketName: ${self:custom.hostingBucketName}
    - bucketName: ${self:custom.storybookBucketName}
      enabled: false
      localDir: storybook-static

And you try to run sls remove, if that bucket doesn't exist in the CloudFormation stack, s3-sync throws the following error:

Error:
NoSuchBucket: The specified bucket does not exist
    at Request.extractError ([snipped]/lib/node_modules/serverless/node_modules/aws-sdk/lib/services/s3.js:715:35)
    at Request.callListeners ([snipped]/lib/node_modules/serverless/node_modules/aws-sdk/lib/sequential_executor.js:106:20)

The problem is due to the fact that in the clear command, the process doesn't exit out early if the disabled flag is set. The fix is simply to add a guard clause in the clear() function, and exit if the enabled field is false. This means s3-sync won't try to retrieve the bucket, causing the above error.

@@ -46,7 +46,7 @@ custom:
- bucketName: my-other-site
localDir: path/to/other-site
deleteRemoved: true # optional, indicates whether sync deletes files no longer present in localDir. Defaults to 'true'
     acl: public-read # optional
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Change here is removing some non breaking spaces someone had introduced to the README

image

Copy link
Owner

@k1LoW k1LoW left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!

@k1LoW k1LoW merged commit 3a24785 into k1LoW:master Jan 28, 2024
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

Successfully merging this pull request may close these issues.

2 participants