Skip to content

Commit

Permalink
aws_chime_voice_connector_logging - Enable Media Metrics Logging (#26283
Browse files Browse the repository at this point in the history
)

* enable media metrics logs

* appease terrafmt

* changelog
  • Loading branch information
breathingdust authored Aug 15, 2022
1 parent 3d5d750 commit 8ba2eb8
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 11 deletions.
3 changes: 3 additions & 0 deletions .changelog/26283.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:enhancement
resource/aws_chime_voice_connector_logging: Add `enable_media_metric_logs` argument
```
18 changes: 13 additions & 5 deletions internal/service/chime/voice_connector_logging.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ func ResourceVoiceConnectorLogging() *schema.Resource {
},

Schema: map[string]*schema.Schema{
"enable_media_metric_logs": {
Type: schema.TypeBool,
Optional: true,
Default: false,
},
"enable_sip_logs": {
Type: schema.TypeBool,
Optional: true,
Expand All @@ -45,7 +50,8 @@ func resourceVoiceConnectorLoggingCreate(ctx context.Context, d *schema.Resource
input := &chime.PutVoiceConnectorLoggingConfigurationInput{
VoiceConnectorId: aws.String(vcId),
LoggingConfiguration: &chime.LoggingConfiguration{
EnableSIPLogs: aws.Bool(d.Get("enable_sip_logs").(bool)),
EnableMediaMetricLogs: aws.Bool(d.Get("enable_media_metric_logs").(bool)),
EnableSIPLogs: aws.Bool(d.Get("enable_sip_logs").(bool)),
},
}

Expand Down Expand Up @@ -74,7 +80,7 @@ func resourceVoiceConnectorLoggingRead(ctx context.Context, d *schema.ResourceDa
if err != nil || resp.LoggingConfiguration == nil {
return diag.Errorf("error getting Chime Voice Connector (%s) logging configuration: %s", d.Id(), err)
}

d.Set("enable_media_metric_logs", resp.LoggingConfiguration.EnableMediaMetricLogs)
d.Set("enable_sip_logs", resp.LoggingConfiguration.EnableSIPLogs)
d.Set("voice_connector_id", d.Id())

Expand All @@ -84,11 +90,12 @@ func resourceVoiceConnectorLoggingRead(ctx context.Context, d *schema.ResourceDa
func resourceVoiceConnectorLoggingUpdate(ctx context.Context, d *schema.ResourceData, meta interface{}) diag.Diagnostics {
conn := meta.(*conns.AWSClient).ChimeConn

if d.HasChange("enable_sip_logs") {
if d.HasChanges("enable_sip_logs", "enable_media_metric_logs") {
input := &chime.PutVoiceConnectorLoggingConfigurationInput{
VoiceConnectorId: aws.String(d.Id()),
LoggingConfiguration: &chime.LoggingConfiguration{
EnableSIPLogs: aws.Bool(d.Get("enable_sip_logs").(bool)),
EnableMediaMetricLogs: aws.Bool(d.Get("enable_media_metric_logs").(bool)),
EnableSIPLogs: aws.Bool(d.Get("enable_sip_logs").(bool)),
},
}

Expand All @@ -106,7 +113,8 @@ func resourceVoiceConnectorLoggingDelete(ctx context.Context, d *schema.Resource
input := &chime.PutVoiceConnectorLoggingConfigurationInput{
VoiceConnectorId: aws.String(d.Id()),
LoggingConfiguration: &chime.LoggingConfiguration{
EnableSIPLogs: aws.Bool(false),
EnableSIPLogs: aws.Bool(false),
EnableMediaMetricLogs: aws.Bool(false),
},
}

Expand Down
12 changes: 8 additions & 4 deletions internal/service/chime/voice_connector_logging_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ func TestAccChimeVoiceConnectorLogging_basic(t *testing.T) {
Check: resource.ComposeAggregateTestCheckFunc(
testAccCheckVoiceConnectorLoggingExists(resourceName),
resource.TestCheckResourceAttr(resourceName, "enable_sip_logs", "true"),
resource.TestCheckResourceAttr(resourceName, "enable_media_metric_logs", "true"),
),
},
{
Expand Down Expand Up @@ -83,6 +84,7 @@ func TestAccChimeVoiceConnectorLogging_update(t *testing.T) {
Check: resource.ComposeAggregateTestCheckFunc(
testAccCheckVoiceConnectorLoggingExists(resourceName),
resource.TestCheckResourceAttr(resourceName, "enable_sip_logs", "false"),
resource.TestCheckResourceAttr(resourceName, "enable_media_metric_logs", "false"),
),
},
{
Expand All @@ -102,8 +104,9 @@ resource "aws_chime_voice_connector" "chime" {
}
resource "aws_chime_voice_connector_logging" "test" {
voice_connector_id = aws_chime_voice_connector.chime.id
enable_sip_logs = true
voice_connector_id = aws_chime_voice_connector.chime.id
enable_sip_logs = true
enable_media_metric_logs = true
}
`, name)
}
Expand All @@ -116,8 +119,9 @@ resource "aws_chime_voice_connector" "chime" {
}
resource "aws_chime_voice_connector_logging" "test" {
voice_connector_id = aws_chime_voice_connector.chime.id
enable_sip_logs = false
voice_connector_id = aws_chime_voice_connector.chime.id
enable_sip_logs = false
enable_media_metric_logs = false
}
`, name)
}
Expand Down
6 changes: 4 additions & 2 deletions website/docs/r/chime_voice_connector_logging.html.markdown
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ resource "aws_chime_voice_connector" "default" {
}
resource "aws_chime_voice_connector_logging" "default" {
enable_sip_logs = true
voice_connector_id = aws_chime_voice_connector.default.id
enable_sip_logs = true
enable_media_metric_logs = true
voice_connector_id = aws_chime_voice_connector.default.id
}
```

Expand All @@ -30,6 +31,7 @@ The following arguments are supported:

* `voice_connector_id` - (Required) The Amazon Chime Voice Connector ID.
* `enable_sip_logs` - (Optional) When true, enables SIP message logs for sending to Amazon CloudWatch Logs.
* `enable_media_metric_logs` - (Optional) When true, enables logging of detailed media metrics for Voice Connectors to Amazon CloudWatch logs.

## Attributes Reference

Expand Down

0 comments on commit 8ba2eb8

Please sign in to comment.