https://pulumi.com logo
#general
Title
# general
s

stale-minister-93676

04/15/2020, 12:42 PM
Can Pulumi handle configuring a VM it just created? IE installing apt packages, copying config files into it etc. Or is there a better tool suited for that?
c

colossal-room-15708

04/15/2020, 1:29 PM
Depends on how you do it, technically, sure, you can execute any code you like, including ssh / winrm into a new VM. AWS and Azure also have ways to execute code (user data / Custom Script Extension) when VMs come up. The latter would be the preferred and more managed way.
r

rhythmic-camera-25993

04/15/2020, 2:21 PM
@stale-minister-93676 AWS for example can use the
userData
on an instance to support the
cloud-init
mechanism for instance initialization. Terraform has a resource for userdata customization that I found pretty handy (https://www.terraform.io/docs/providers/template/d/cloudinit_config.html) but you can also craft your own string and set the
userData
field directly from that. In case you're on AWS, here's the docs for cloud-init on ec2: https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/user-data.html#user-data-cloud-init
s

stale-minister-93676

04/15/2020, 2:22 PM
Thanks guys. I was hoping I could get similar functionality to Ansible but in javascript.
r

rhythmic-camera-25993

04/15/2020, 2:23 PM
that's essentially what I use these
cloud-init
yamls for, so you're in the right space. the string you'd end up setting would be a cloud-init yaml, which then would get run on instance standup. I've been using this for a few months now and been very happy to remove ansible from my instance configurations 😄
s

stale-minister-93676

04/15/2020, 2:25 PM
nice
c

colossal-room-15708

04/15/2020, 2:27 PM
Cloud init and user data are two things though. Former doesn't work on Windows.
r

rhythmic-camera-25993

04/15/2020, 2:29 PM
yeah, good point. I always forget about windows 🙂
b

broad-dog-22463

04/15/2020, 2:40 PM
@stale-minister-93676 there is a way to do this in Pulumi
it shows how to write code to connect to the VM and "provision" it
it's not a built in mechanism to Pulumi, it's just using the power of the language ecosystem you are writing on
h

high-jackal-29091

04/15/2020, 3:02 PM
You can also use Packer to create aws AMI or VM image. This way you can spin up your instances faster if init code is complex and takes time to execute. And that works for Windows, except you have to script init in powershell (although choco works like a charm for installing packages).
👍 1