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.
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.
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.