https://pulumi.com logo
#aws
Title
# aws
c

cold-sundown-35940

03/29/2023, 5:21 PM
Hi all! Is there any way to deploy containers to EC2 instance using pulumi_aws.ec2.Instance without using user_data?
l

little-cartoon-10569

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/
There's also Pulumi Command, which is kind of a supercharged ssh: https://www.pulumi.com/registry/packages/command/
Have you considered ECS instead of EC2? That will look after most of the configuration for you.
c

cold-sundown-35940

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.
l

little-cartoon-10569

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.
c

cold-sundown-35940

03/29/2023, 7:23 PM
That sounds reasonable. Thanks you for the recommendations, will definitely consider this option 🙌
g

great-sunset-355

04/04/2023, 12:50 PM
Another option is to look at AWS App Runner