In terraform's documentation it states:
A single item list of HLS ingest information
And then, a nested value of:
A list of the ingest endpoints
How can I get the first item entry of the list of endpoints?
CodePudding user response:
Since the resource was not provided, we will assume the example in the documentation:
resource "aws_media_package_channel" "kittens" {
channel_id = "kitten-channel"
description = "A channel dedicated to amusing videos of kittens."
}
Given that resource, we can access the exported resource attribute with the normal namespace of aws_media_package_channel.kittens.hls_ingest
. Since this is a single item list containing a map, we would then access aws_media_package_channel.kittens.hls_ingest[0].ingest_endpoints
. You stated that you want the first element of this nested list, and therefore with the customary syntax for the zeroth element:
aws_media_package_channel.kittens.hls_ingest[0].ingest_endpoints[0]
where you can then access values of that map by referencing the key e.g. url
as per normal.