Skip to content

Commit

Permalink
add hostname to communication service resource and data source (hashi…
Browse files Browse the repository at this point in the history
…corp#28620)

Signed-off-by: Aidan Jensen <[email protected]>
  • Loading branch information
artificial-aidan authored and hqhqhqhqhqhqhqhqhqhqhq committed Feb 26, 2025
1 parent e44cad4 commit e0ab6e3
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ type CommunicationServiceDataSourceModel struct {
SecondaryConnectionString string `tfschema:"secondary_connection_string"`
SecondaryKey string `tfschema:"secondary_key"`
Tags map[string]string `tfschema:"tags"`
HostName string `tfschema:"hostname"`
}

func (CommunicationServiceDataSource) Arguments() map[string]*pluginsdk.Schema {
Expand Down Expand Up @@ -77,6 +78,11 @@ func (CommunicationServiceDataSource) Attributes() map[string]*pluginsdk.Schema
},

"tags": commonschema.TagsDataSource(),

"hostname": {
Type: pluginsdk.TypeString,
Computed: true,
},
}
}

Expand Down Expand Up @@ -114,6 +120,7 @@ func (CommunicationServiceDataSource) Read() sdk.ResourceFunc {
if model := resp.Model; model != nil {
if props := model.Properties; props != nil {
state.DataLocation = props.DataLocation
state.HostName = pointer.From(props.HostName)
}

state.Tags = pointer.From(model.Tags)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ func TestAccCommunicationServiceDataSource_basic(t *testing.T) {
check.That(data.ResourceName).Key("secondary_connection_string").Exists(),
check.That(data.ResourceName).Key("primary_key").Exists(),
check.That(data.ResourceName).Key("secondary_key").Exists(),
check.That(data.ResourceName).Key("hostname").Exists(),
),
},
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ type CommunicationServiceResourceModel struct {
SecondaryConnectionString string `tfschema:"secondary_connection_string"`
PrimaryKey string `tfschema:"primary_key"`
SecondaryKey string `tfschema:"secondary_key"`
HostName string `tfschema:"hostname"`
}

func (CommunicationServiceResource) StateUpgraders() sdk.StateUpgradeData {
Expand Down Expand Up @@ -115,6 +116,11 @@ func (CommunicationServiceResource) Attributes() map[string]*pluginsdk.Schema {
Computed: true,
Sensitive: true,
},

"hostname": {
Type: pluginsdk.TypeString,
Computed: true,
},
}
}

Expand Down Expand Up @@ -246,6 +252,7 @@ func (CommunicationServiceResource) Read() sdk.ResourceFunc {
if model := resp.Model; model != nil {
if props := model.Properties; props != nil {
state.DataLocation = props.DataLocation
state.HostName = pointer.From(props.HostName)
}

state.Tags = pointer.From(model.Tags)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ func TestAccCommunicationService_complete(t *testing.T) {
check.That(data.ResourceName).Key("secondary_connection_string").Exists(),
check.That(data.ResourceName).Key("primary_key").Exists(),
check.That(data.ResourceName).Key("secondary_key").Exists(),
check.That(data.ResourceName).Key("hostname").Exists(),
),
},
data.ImportStep(),
Expand Down
2 changes: 2 additions & 0 deletions website/docs/d/communication_service.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ In addition to the Arguments listed above - the following Attributes are exporte

* `tags` - A mapping of tags assigned to the Communication Service.

* `hostname` - The hostname of the Communication Service

## Timeouts

The `timeouts` block allows you to specify [timeouts](https://www.terraform.io/language/resources/syntax#operation-timeouts) for certain actions:
Expand Down
1 change: 1 addition & 0 deletions website/docs/r/communication_service.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ In addition to the Arguments listed above - the following Attributes are exporte
* `secondary_connection_string` - The secondary connection string of the Communication Service.
* `primary_key` - The primary key of the Communication Service.
* `secondary_key` - The secondary key of the Communication Service.
* `hostname` - The hostname of the Communication Service

## Timeouts

Expand Down

0 comments on commit e0ab6e3

Please sign in to comment.