sparse-intern-71089
12/07/2022, 5:11 PMmany-telephone-49025
12/07/2022, 6:34 PMinstallDocker, err := remote.NewCommand(ctx, "install-docker", &remote.CommandArgs{
Connection: &remote.ConnectionArgs{
Host: instance.Ipv4Address,
PrivateKey: readFileOrPanic("~/.ssh/id_rsa"),
User: pulumi.String("root"),
},
Create: pulumi.String("cloud-init status --wait && sleep 30s"),
})
if err != nil {
return err
}
And then I have a pulumi.DependsOn([]pulumi.Resource{installDocker})
in the next resource.proud-art-41399
12/07/2022, 6:52 PMfierce-ability-58936
12/07/2022, 7:41 PMmany-telephone-49025
12/07/2022, 7:45 PMproud-art-41399
12/08/2022, 7:14 AMproud-art-41399
12/11/2022, 7:08 PMwait_for_instance_command = command.local.Command(
"wait-for-instance-command",
create=pulumi.Output.format(
"aws ec2 wait instance-status-ok --instance-ids {instance_id}",
instance_id=run_instance_command.stdout,
),
triggers=[run_instance_command.stdout],
opts=pulumi.ResourceOptions(depends_on=[run_instance_command]),
)
For a bit more context. I realized that I don't even want the EC2 instance managed by Pulumi because the only resource I care about is the created AMI. So I start the EC2 instance also with local command (the run_instance_command
) and get the instance ID from the command output. Then I wait to the instance to come up and report successful status check. The ec2.AmiFromInstance
specifies the wait command as an explicit dependency. The final local command in the chain is the terminate_instance_command
which terminates the ephemeral instance.No matter how you like to participate in developer communities, Pulumi wants to meet you there. If you want to meet other Pulumi users to share use-cases and best practices, contribute code or documentation, see us at an event, or just tell a story about something cool you did with Pulumi, you are part of our community.
Powered by