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

Create CloudFront distribution OR get the bucket ARN #3

Open
cdelgadob opened this issue Sep 15, 2017 · 19 comments
Open

Create CloudFront distribution OR get the bucket ARN #3

cdelgadob opened this issue Sep 15, 2017 · 19 comments

Comments

@cdelgadob
Copy link

It would be nice to be able to choose how to serve the content, either via S3 with Static Web Hosting (as it is now), or via Cloudfront distribution.

If this is too much, it would be a good start to be able to retrieve the bucket ARN, so one could do the CloudFront provisioning via extra CloudFormation code.

Is there a way to achieve this?

Thanks!

@fernando-mc
Copy link
Owner

@cdelgadob Sounds like a great idea. I'm a bit busy right now so I've paused active development on many of my projects for the next month or two. The best way to have this happen would be to give this a shot yourself and then submit a PR. Feel free to let me know if you have any questions.

@constb
Copy link

constb commented Feb 1, 2018

I'm not sure if creating a CF distribution on S3-deploy is a good idea. Maybe it's better create a bucket and a distribution via cloudformation template as part of sls deploy, not sls client deploy.

Creating an invalidation for a preexisting CF distribution on the other hand would be a very good thing to do, right after S3 upload…

@lrholmes
Copy link

lrholmes commented Mar 8, 2018

Agree with @constb that an automated CF invalidation feature would be really handy! Should this be put into a new issue or is it relevant enough to this one?

@linusmarco
Copy link
Contributor

@lrholmes, I think that probably makes sense as a separate issue. Any interest in implementing this?

@lrholmes
Copy link

lrholmes commented Mar 9, 2018

@linusmarco great, just made one here: #40.

I am just getting started with Serverless, so don't have a great amount of knowledge yet and wouldn't know exactly where to start, but I'm eager to learn more so I might have a go at it when I find some time over the weekend. If you could comment any pointers on the new issue that would be great!

@fernando-mc
Copy link
Owner

@lrholmes thanks for opening #40 ! I'm not sure where we landed with that so let any of the collaborators or maintainers know if you have questions on how to proceed. We're doing a fairly substantial refactor so it may require changes after today.

@fernando-mc
Copy link
Owner

@cdelgadob Since you requested the feature I've assigned it to you to follow up with the relevant folks on #40 and work with @lrholmes who seems to have started to work on this. Let us know if you have any questions!

@kyledgreen
Copy link

kyledgreen commented May 30, 2018

Hi, I'm trying to setup Serverless to deploy my client stack which includes a S3 static site, a CloudFront Distribution, and Route 53 records for custom domain name for the CFD. It made sense using the s3 plugin since I could setup my 'stack' without the CI/CD portion that finch has added, but now on finch i dont get the separate stack initialization piece since the s3 bucket is not in the resource section. Is there any intent on implementing such a feature? I may need to duplicate the work that finch is doing and only use it for the CI/CD portion it provides so that sls gets the resource ref to the s3 bucket when creating my CFD.

TLDR:
When I run "sls deploy" I want the finch plugin to do all the s3 creation and setup, but not deploy the content and also provide a output or ref to the resource so I can get the BucketName, ARN, Static Site URL, etc for use in my CFD creation.

@sprockow
Copy link
Contributor

Is anyone still working on this? Also, would it be worth trying to integrate this with an existing cloudfront serverless plugin, like https://github.com/Droplr/serverless-api-cloudfront?

I imagine that placing lambda-powered api endpoints and a s3 site behind a single cloudfront distribution to be a common use case. I imagine that the first missing integration piece is getting the bucket arn as an output?

@fernando-mc
Copy link
Owner

fernando-mc commented Sep 27, 2018

@kyledgreen sorry about the delay here. The use case makes sense to me. I'm not opposed to having something like that added. Seems like you could specify that no files be uploaded and then add a config value to have a function run to output all that metadata. The outputting to the CI/CD solutions would probably be the most tricky. It might end up being easier to use CloudFormation in the serverless.yml file to do what you describe because you can actually get outputs from that that can work into a CI/CD flow a little easier.

@sprockow I don't think anyone is working on this feature at the moment as I haven't heard anything from the requester. If you're interested in implementing it, it's yours!

@sprockow
Copy link
Contributor

sprockow commented Oct 7, 2018

Just saw this. Yeah, I think I'll take a look this weekend.

@superandrew213
Copy link

@fernando-mc
Copy link
Owner

@sprockow are you still interested in this?

@sprockow
Copy link
Contributor

sprockow commented Feb 5, 2019

@fernando-mc - it's been a really long time since I've looked at this project. I am interested, and I do have more bandwidth now than last year, so I will commit to at least unearthing my notes from October.

@superandrew213 - Fullstack-serverless does set up an cloudfront cdn and s3 bucket pair, but it lacked some of the additional s3 specific features that this plugin provided, which is why I looked at finch initially for a project.

@sprockow
Copy link
Contributor

So, a couple questions about approach...

The most flexible way of achieving the ability to create a cloudfront distribution for this bucket, would be to give users the ability to opt out of having the plugin create the bucket for us, and instead leverage cloudformation via the serverless.yml 's "Resources" section. This way, a user can set up the bucket, and cdn exactly how they want via Cloudformation, but still use this plugin's features to upload content to that target bucket.

Perhaps this "opt out" behavior would be controlled by a parameter such as "manageResources: false"? In order to not break existing behavior, manageResources would default to true.

However, this would require that the user first deploy all of the resources via "serverless deploy", before running "serverless client deploy". Some helpful warnings could be added to the cli the bucket does not exist. (for example Bucket does not exist, and manageResources has been set to "false". Ensure that bucket exists or that all resources are deployed first )

@sprockow
Copy link
Contributor

I can put together a PR with the above + an example of how a serverless project could use this new behavior.

@sprockow
Copy link
Contributor

#75 - Here's my first draft PR. Let me know if you think this is an acceptable strategy, and I can put some effort into refining it and adding some readme docs.

@sprockow
Copy link
Contributor

Here's an example on how I would use severless-finch with this sort of flag: https://github.com/sprockow/serverless-finch-example

@fernando-mc
Copy link
Owner

This is partially solved by @sprockow's PR in #75 .

We still don't do much with CloudFormation or Route 53 so I'll leave this open in case folks want to add functionality there later.

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

No branches or pull requests

8 participants