How to get private IPs for AWS ElastiGroup created using Terraform SpotInst provider

I am trying to create an AWS elasigroup using terraform spotinst provider in TS. it is getting created but not giving privateIps using cdktf TerraformOutput and giving an error that it is encoded and not an scaler array. how to get PrivateIps of elastigroup created through terraform spotInst provider ? anyone can help ?

const instance = new ElastigroupAws(this, name, config);
		new TerraformOutput(this, 'PrivateIps', {
			value: instance.privateIps
		})

That looks like the correct way to have it be printed as an output when deploying. If you can provide the exact error / how you are wanting to use it, we can probably help troubleshoot further.

@jsteinich , By this way nothing is being printed. As privateIPs is an array if i try to use like this, shows the attached error.

const instance = new ElastigroupAws(this, name, config);
		new TerraformOutput(this, 'PrivateIps', {
			value: instance.privateIps[0]
		})

I also tried this another way and got the same error :

const instance = new ElastigroupAws(this, name, config);
		new TerraformOutput(this, 'Name', {
			value: _.nth(instance.privateIps, 0)
		})

If you just want the first ip from the list, you can use

new TerraformOutput(this, 'PrivateIps', {
        value: Fn.element(instance.privateIps, 0)
    });

Looking at the provider schema, private_ips is marked as
computed: false, optional: true, required: false.
This means that unless you have specified them in your configuration, none will be returned.

How to specify private_ips in config ? and what is Fn here ?

Populate the privateIps property of your config object.

Fn provides access to Terraform’s built-in functions.

Populate the privateIps property of your config object.

Using this i am getting the IPs which i am putting in config but i don’t want to do that. when we create spot elastigroup without privateIps in config, it automatically assigns IP to instance. i want to print and store that. how to get that privateIp ?

Apologizes as I am not familiar with this provider.
It looks like you may be able to specify PersistPrivateIp in your config in order to get private ips returned.

This is not wokring, this returns only the given privateIps not the auto assigned one.

Just to double check, the code that you initially posted results in an empty PrivateIps output?
If so, you may want to ask on the provider repo.