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

v4 Upgrade Guide? #140

Closed
blakelthaus opened this issue Jan 6, 2023 · 8 comments
Closed

v4 Upgrade Guide? #140

blakelthaus opened this issue Jan 6, 2023 · 8 comments

Comments

@blakelthaus
Copy link

blakelthaus commented Jan 6, 2023

Hi, we are currently using Lamby v3 for a rails application and I am interested in upgrading to v4 but I can't seem to find anything on how one might go about that. Any plans for an upgrade guide doc??

@metaskills
Copy link
Member

Hey @blakelthaus should be a no-op upgrade if all you want to do is update the gem. No internal changes on how the gem works were made. The v4 is a marketing technique on how we can use containers in future projects. See details here in the CHANGELOG.md https://github.com/customink/lamby/blob/master/CHANGELOG.md To reiterate, update at will, but if you want to modernize, there are two layers at which you can do so.

The first is the way to use the Lamby gem.

  • Remove require: false from lamby in Gemfile.
  • Remove app.rb file and add CMD ["config/environment.Lamby.cmd"] to your Dockerfile.

The second is how you use the containers for your dev, CI, and CD. The cookiecutter project pull request here details all that. Remember there is a commit at the bottom too that should have been part of the PR.

This outlines lots of ways you can update your containers from Ruby 2.7 (from Amazon) to any container. I used official Ruby images since, but your mileage may vary. The key points are outlined in the PR. So an upgrade for folks may be switching to new images keeping 2.7 and then upgrading ruby from there. But in general:

  • Use new base images.
  • Install RIC into that image.
  • Add the .devcontainer stuff for easy Codespaces or local VS Code without Codespaces.
  • Leverage Crypteia vs manual SSM .env files in build step.
  • Remove Docker-in-Docker bin/_script patterns.
  • Remove bin/_build and simplify the bin/deploy.
  • Only have one Docker file. No second build one needed.
  • Switch to Function URLs. If you want, or keep API Gateway. Up to you.

The internals will be different for folks depending on how much they kept the orig cookiecutter patterns. Does that help?

@metaskills metaskills changed the title Upgrade Guide? v4 Upgrade Guide? Jan 10, 2023
@blakelthaus
Copy link
Author

Hey @metaskills ,

Thank you, this info is super helpful, managed to upgrade to v4 just by upgrading the Gem and forgot to close the request. Glad I didn't though because your info on the ruby upgrades in the pull request will come in handy as we are still just using 2.7 atm.

One thing I did run into when deploying is that the lamby:ssm:dotenv doesn't seem to be supported anymore, when running the sam build I got Don't know how to build task 'lamby:ssm:dotenv' (See the list of available tasks with rails --tasks). Switching to Crypteia was a relatively easy fix though.

Also, I'm currently working on updating our deployment pipeline and I wanted to see if you have any suggestions for instantiating Secrets Manager Secrets as environment variables? I am realized the AWS CDK has deprecated the ability to create secure string params and we will be deploying our app to multiple environments and don't particularly want to be manually creating the DB SSM params in every account. If not no worries, just figured I would ask while we are here :)

Thanks again, and really appreciate all your work on Lamby, it is an awesome tool!

@metaskills
Copy link
Member

Switching to Crypteia was a relatively easy fix though.

That was a big breaking change. I'm happy the switch to Crypteia was easy!

if you have any suggestions for instantiating Secrets Manager Secrets as environment variables?

Yes, that should be Crypteia too. Have you seen this issue? There seems to be a few ways forward and that SSM stuff looked interesting.

@blakelthaus
Copy link
Author

Sweet, gonna be digging into this a little bit more tomorrow! Will try to follow up with whatever I end up doing! Thanks again!

@blakelthaus
Copy link
Author

Update, couldn't manage to get the SSM Path to work for pulling AWS Secrets Manager Secrets. I ended up just writing some code in application.rb to pull the Secret and initialize for now.

After doing this I've run into the issue that all of my environment variables for Crypteia are no longer pulling from SSM. Spent the better half of the afternoon trying to figure out why to no avail, made sure that my lambdas have ssm permissions and tried a just about every implementation of Crypteia from the README. When trying to use the ENV Variables I just get the string x-crypteia-ssm:/VARIABLE_NAME. Any tips for debugging this?

@metaskills
Copy link
Member

metaskills commented Jan 12, 2023

Hard to say, were the ENV variables working prior to code you added to application.rb? If so, I'd have to see that code. In ruby ENV enumerable methods like .each do NOT get the values, only the index operator [] hits the low level getenv where Crypteia overrides come thru. Does that help?

@metaskills
Copy link
Member

☝🏼 Fixed a few typos.

@blakelthaus
Copy link
Author

Yes, that is helpful, thank you. Ended up being a total bonehead move on my part. Accidentally moved the Crypteia setup into the wrong Dockerfile, makes the move to one Dockerfile all that much more attractive.

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

No branches or pull requests

2 participants