https://pulumi.com logo
#aws
Title
# aws
h

high-holiday-63390

11/25/2021, 11:23 AM
Copy code
const environment = new aws.elasticbeanstalk.Environment(appName, {
        name: appName,
        application: application.name,
        solutionStackName: solutionStack.name,
        settings: devSettings,
    })

    const instance = aws.ec2.getInstance({
        instanceId: environment.instances[0]
    }).then(instance => instance.privateDns)
l

little-cartoon-10569

11/25/2021, 8:16 PM
Don't use
getInstance
, that looks up instances using the AWS SDK and returns the current state. You could try using
aws.ec2.Instance.get()
. It uses Pulumi's outputs to wait for values to be available. I haven't tried it in this use case though...
h

high-holiday-63390

11/26/2021, 1:43 AM
I thought you could not use get in a pulumi run
l

little-cartoon-10569

11/26/2021, 1:48 AM
You can always use <client>.get. You cannot use <output>.get().
Alternatively: `aws.ec2.Instance.get()`: 👍 . `aws.ec2.Instance.get().id.get()`: 👎
h

high-holiday-63390

11/26/2021, 1:52 AM
The tricky thing here is that the instances will not be available until you deploy something in Beanstalk. So I don’t really want to wait in the pulumi run
Here’s what I ended up doing
Copy code
if (environment.instances[0].length > 0) {
        instance = await aws.ec2.getInstance({
            instanceId: environment.instances[0]
        })
        exports["instance"] = instance.privateDns
    }
l

little-cartoon-10569

11/26/2021, 1:52 AM
Then there won't be in
id
, will there?
h

high-holiday-63390

11/26/2021, 1:53 AM
instances
just ends up being empty. I guess this situation is a special case
l

little-cartoon-10569

11/26/2021, 1:54 AM
That's probably the right thing to do. If you use
Instance.get()
, it goes into your stack as a read-only resource. And if the id changes, it might count as an update, and mess up your CI comments, etc.
h

high-holiday-63390

11/26/2021, 1:55 AM
👍