Is there any way to deploy containers to EC2 instance using pulumi_aws.ec2.Instance without using user_data?
03/29/2023, 6:55 PM
You want to install Docker / podman / something else, then run an image on an EC2 instance? You'll need to connect to the instance somehow. You could use ansible, ssh, or similar.
If you just want to "hide" user_data, you could use CloudInit, which is a wrapper around user_data: https://www.pulumi.com/registry/packages/cloudinit/
Have you considered ECS instead of EC2? That will look after most of the configuration for you.
03/29/2023, 7:06 PM
Yes, I was considering ECS, but I thought that it would be more costly to use it. I was thinking to use aws.ecs.EC2Service and define containers there, but any ideas on how much more than just using an EC2 instance would it cost?
And thanks a lot for your answer!! Appreciate it.
03/29/2023, 7:08 PM
I don't know how to measure how much it'll cost to write and maintain the equivalent EC2 code 🙂 The ECS service costs more because it's a managed service, so you're paying AWS to look after the nitty-gritty for you. And ECS can be cheaper than EC2, if your container runs only rarely.
AWS provides calculators for a lot of their costs, but I don't know if there's one for ECS.
You might consider doing it in ECS and allocating a Budget; that way, AWS will inform you if ECS gets too expensive, and you can put the effort into an EC2 solution then?
And Budgets are a good idea in general; once you've seen the benefit of one, you might start creating more and more, and getting better and better cost analysis from AWS.
03/29/2023, 7:23 PM
That sounds reasonable. Thanks you for the recommendations, will definitely consider this option 🙌