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

polite-helicopter-45187

01/12/2024, 3:32 PM
What's the best way to include the following steps in my deployment: • Once an EC2 instance is up, copy a shell script over to it over SSH • After the copy is complete, run the shell script on the EC2 instance. Is it https://github.com/pulumi/pulumi-command ?
c

cool-scientist-53915

01/12/2024, 5:59 PM
That's what I do. I first have some code that checks the instance state in a loop until it returns "running". In javascript, you'd get the ec2 instance via:
Copy code
let instance = await aws.ec2.getInstance({ instanceId: id });
And then look at
instance.instanceState
. After that equals "running", I use a pulumi remote
Command
that executes
timeout 15m cloud-init status --wait
to ensure that the instance is fully booted and done with running any init scripts. Then any later commands/file copies simply have a dependency on the
Command
that waits for cloud-init to be done.
p

polite-helicopter-45187

01/12/2024, 7:46 PM
Thank you!
p

proud-twilight-52651

01/13/2024, 5:11 AM
or you could give a cloud-init script when you create the instance cloud-init is included in the major cloud distributions, and its purpose is exactly that : run a script on the first boot