Search code examples
ruby-on-railsamazon-web-servicesconsoleamazon-ecsaws-fargate

How to launch a rails console in a Fargate container


I would like to open a Rails console in a Fargate container to interact with my production installation

However after searching the web and posting in the AWS forum I could not find an answer to this question

Does anyone know how I can do this? This seems like a mandatory thing to have in any production environment and having no easy way to do it is kind of surprising coming from such a respected cloud provider as AWS

Thanks


Solution

  • After trying lots of things, I found a way to open a Rails console pointing to my production environment, so I will post it here in case somebody come accross the same issues

    To summarise I add a rails application deployed on Fargate connected to a RDS postgres database

    What I did is creating a VPN client endpoint to the VPC hosting my Rails app and my RDS database

    Then after being connected to this VPN, I simply run my rails production container (with the same environment variables) overriding the container command to run the console startup script (bundle exec rails c production)

    Being run on my local machine I can normally attach a TTY to this container and access my production console

    I think this solution is good because it allow any developper working on the project to open a console without any costs incurred and a well-though security policy on the AWS end ensure that the console access is secure, plus you don't have to expose your database outside of your VPC

    Hope this helped someone