I need to setup aws s3 access points for each data_uri passed in the inference variable; this is to provide a cross-account uri(s). I need to parse out just the bucket name from each of these data_uri and then create resources for each. How would I go about doing that?
Here is what I have so far:
resource "aws_s3_access_point" "s3_access_point" {
count = var.create ? 1 : 0
for_each = var.inference
bucket = split("/", replace(each.value.image_uri, "s3://", ""))[0]
name = format("%s-%s", split("/", replace(each.value.image_uri, "s3://", ""))[0], "-access-point")
}
The variable would look like this:
{
"inference": [
{
"data_uri": "s3://my_bucket/model.tar.gz"
},
{
"data_uri": "s3://my_bucket_2/model.tar.gz"
},
{
"data_uri": "s3://my_bucket_3/model.tar.gz"
}
]
}