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

Fix aws_serverless config when api folder missing #1553

Merged
merged 5 commits into from Dec 12, 2020

Conversation

bennettrogers
Copy link
Contributor

Fixes #1550

Note: The ternary in the template string isn't necessarily the cleanest looking solution, but it seems to be the simplest.

@github-actions
Copy link

github-actions bot commented Dec 5, 2020

@Tobbe
Copy link
Member

Tobbe commented Dec 5, 2020

Thanks for taking the time to submit this PR. Have you tried it, so it still works to deploy to AWS?

@bennettrogers
Copy link
Contributor Author

I did try to run the Redwood AWS deploy generator, but that fails due to the api workspace being missing in the first place.

I did not try manually writing an AWS deploy config and triggering that, nor did I try generating an AWS deploy config before deleting the api workspace and then triggering the deploy. It seems like neither of those would work or make sense without the existence of an api side.

@Tobbe
Copy link
Member

Tobbe commented Dec 6, 2020

I didn't realize we only supported deploying the api side to AWS. I thought we deployed the web side to an s3 bucket as well... If it's just the API side, then, yeah, not much to test if there is no api side 😀

@Tobbe
Copy link
Member

Tobbe commented Dec 6, 2020

I generated aws deploy config (with the api stuff in place) and renamed the file to serverless.yml_. Then I installed the PR packages for this PR (need to be on latest canary release for that to work) and ran the generator again.

image

Want to tweak that, and then I think this is ready to merge!

Just to be clear, it's indented now, and it shouldn't be. This is what it looks with this PR installed (note line 32)

image

@bennettrogers
Copy link
Contributor Author

I did notice that it was indenting that line, but forgot that it would be a problem since the result is a YAML file...

What's the best way to fix this? If I just try to move the functions: bit to its own line, the configured Prettier setup just puts it right back where it is. I guess // prettier-ignore would work? Is there a better way?

@Tobbe
Copy link
Member

Tobbe commented Dec 7, 2020

What's the best way to fix this? If I just try to move the functions: bit to its own line, the configured Prettier setup just puts it right back where it is. I guess // prettier-ignore would work? Is there a better way?

This seems to work for me, no prettier-ignore needed

package:
  individually: true

${
  fs.existsSync(path.resolve(getPaths().api.functions))
    ? `functions:
  ${fs
    .readdirSync(path.resolve(getPaths().api.functions))
    .map((file) => {

@Tobbe Tobbe merged commit bbfbd88 into redwoodjs:main Dec 12, 2020
@Tobbe
Copy link
Member

Tobbe commented Dec 12, 2020

Thanks for the fix Bennett!

@thedavidprice thedavidprice added this to the Next Release milestone Jan 6, 2021
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.

Generators don't work if the api folder is missing
3 participants