Skip to content
This repository has been archived by the owner on Jan 28, 2025. It is now read-only.

SLS will create a new cloudfront distribution even if one already exists for your lambda and error when associating it with a domain #554

Closed
danjiro opened this issue Aug 20, 2020 · 3 comments

Comments

@danjiro
Copy link

danjiro commented Aug 20, 2020

Describe the bug
You will get a CNAMEAlreadyExists: One or more of the CNAMEs you provided are already associated with a different resource. when you are doing a fresh deploy (one without the .serverless folder with existing config info) and the lambda already exists. Serverless docs say you shouldnt commit your .serverless folder but in this case you would have to or else it will create a new cloudfront distribution and try to assign that new one to your domain and you get the error. Normal SLS avoids these issues because it uses cloudformation?

@dphang
Copy link
Collaborator

dphang commented Aug 21, 2020

I believe this plugin needs to use new version of Serverless Components: #415 (comment) to sync the state, though it needs to be upgraded as per the issue.

You can commit the .serverless folder each time but will be hard to manage while in a CI/CD pipeline, especially if you have multiple deployment stages (test, prod, etc.). If you have a single stage, you can do something like the following:

# Before running serverless fetch remotely stored folders
aws s3 sync "s3://my-serverless-state-bucket/my-component/${STAGE}/.serverless" .serverless

serverless

# After running serverless sync it's folders back to S3 bucket
aws s3 sync .serverless "s3://my-serverless-state-bucket/my-component/${STAGE}/.serverless"

This is the solution from: #328 (comment). If you have multiple stages it might be useful to create a custom deployment script that will sync to different S3 buckets/paths based on stage (you would also need to programmatically generate different serverless.yml files for each stage).

@ezalorsara
Copy link

I'm also in this situation having multi stages. I'm still thinking what the best approach to this Issue

@danjiro
Copy link
Author

danjiro commented Aug 25, 2020 via email

@dphang dphang closed this as completed Aug 31, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants