What's the best way to include the following steps...
# general
p
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
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
Thank you!
p
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