Hi, I have deployed 5 EC2 VM using the Automation ...
# general
l
Hi, I have deployed 5 EC2 VM using the Automation API , After deploying the I am looking to extract the following info for each machine using the code. Public IPv4 DNS Private IP DNS name (IPv4 only) Public IPv4 address Hostname type and Stack URN associated with particular machine . First of i would like to check if its possible using the automation api or do I need to use vanilla aws api . if yes , what would be the best approach as starting point .
l
It is possible. In the Pulumi program (inline or external), add those properties as exports. In the automation-api wrapped, you can then access them and log them to stdout or similar.
l
Thanks @little-cartoon-10569, Any example I can follow as a starting point . I am trying to print the res.Outputs . But dont see any thing on the console . But see the EC2 machine provisioned .
Copy code
// wire up our update to stream progress to stdout
stdoutStreamer := optup.ProgressStreams(os.Stdout)

res, err := s.Up(ctx, stdoutStreamer)
if err != nil {
   fmt.Printf("Failed to deploy vm stack: %v\n", err)
   os.Exit(1)
}
time.Sleep(60 * time.Second)

for key, element := range res.Outputs {
   fmt.Println("key", key, "=>", element.Value)
}
fmt.Println("Update succeeded!")
l
Did you export them from the project? I'm not familiar with golang, but most examples at https://github.com/pulumi/examples should have some project exports... onesec...
l
I am trying to fine some example as well which i ca follow
This is a simple Pulumi program that exports two values, the bucket name and websiteUrl.
l
Let me have a look Thanks
Also any idea how would I get the URN for the every resource in the stack
l
Then your automation-api app would be able to access the values via the Stack object
l
i see
Thanks
l
To get the URN for every resource, there's a
--show-urns
option you can pass to
pulumi stack
l
thanks , is that the cli command right ?
l
Yes.
You can probably do it within an autoamtion-api program too. It'll be in the Stack object.