Skip to content

Commit

Permalink
azurerm_cosmosdb_cassandra_datacenter - expose `seed_node_ip_addres…
Browse files Browse the repository at this point in the history
…ses` property (#24076)

* azurerm_cosmosdb_cassandra_datacenter - expose seed_node_ip_addresses

* update code

* update coe

* update code
  • Loading branch information
neil-yechenwei authored Dec 4, 2023
1 parent 464aa0e commit eea8db7
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 0 deletions.
27 changes: 27 additions & 0 deletions internal/services/cosmos/cosmosdb_cassandra_datacenter_resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,14 @@ func resourceCassandraDatacenter() *pluginsdk.Resource {
Optional: true,
Default: true,
},

"seed_node_ip_addresses": {
Type: pluginsdk.TypeList,
Computed: true,
Elem: &pluginsdk.Schema{
Type: pluginsdk.TypeString,
},
},
},
}

Expand Down Expand Up @@ -226,6 +234,10 @@ func resourceCassandraDatacenterRead(d *pluginsdk.ResourceData, meta interface{}
d.Set("disk_sku", props.DiskSku)
d.Set("sku_name", props.Sku)
d.Set("availability_zones_enabled", props.AvailabilityZone)

if err := d.Set("seed_node_ip_addresses", flattenCassandraDatacenterSeedNodes(props.SeedNodes)); err != nil {
return fmt.Errorf("setting `seed_node_ip_addresses`: %+v", err)
}
}
}
return nil
Expand Down Expand Up @@ -319,3 +331,18 @@ func cassandraDatacenterStateRefreshFunc(ctx context.Context, client *managedcas
return nil, "", fmt.Errorf("unable to read provisioning state")
}
}

func flattenCassandraDatacenterSeedNodes(input *[]managedcassandras.SeedNode) []interface{} {
results := make([]interface{}, 0)
if input == nil {
return results
}

for _, item := range *input {
if item.IPAddress != nil {
results = append(results, item.IPAddress)
}
}

return results
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ func testAccCassandraDatacenter_basic(t *testing.T) {
Check: acceptance.ComposeAggregateTestCheckFunc(
check.That(data.ResourceName).ExistsInAzure(r),
check.That(data.ResourceName).Key("sku_name").IsNotEmpty(),
check.That(data.ResourceName).Key("seed_node_ip_addresses.#").HasValue("3"),
),
},
data.ImportStep(),
Expand Down
2 changes: 2 additions & 0 deletions website/docs/r/cosmosdb_cassandra_datacenter.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,8 @@ In addition to the Arguments listed above - the following Attributes are exporte

* `id` - The ID of the Cassandra Datacenter.

* `seed_node_ip_addresses` - A list of IP Address for the seed nodes in this Cassandra Datacenter.

## Timeouts

The `timeouts` block allows you to specify [timeouts](https://www.terraform.io/language/resources/syntax#operation-timeouts) for certain actions:
Expand Down

0 comments on commit eea8db7

Please sign in to comment.