Skip to content

Commit 41aa352

Browse files
committed
fix: nil checks for source location optional params
OTT-6870
1 parent 898bde5 commit 41aa352

File tree

2 files changed

+42
-2
lines changed

2 files changed

+42
-2
lines changed

awsmt/helpers_source_location.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,14 @@ func getCreateSourceLocationInput(model sourceLocationModel) mediatailor.CreateS
1212
var params mediatailor.CreateSourceLocationInput
1313

1414
// Access Configuration
15-
params.AccessConfiguration = getAccessConfigurationInput(model.AccessConfiguration)
15+
if model.AccessConfiguration != nil {
16+
params.AccessConfiguration = getAccessConfigurationInput(model.AccessConfiguration)
17+
}
1618

1719
// Default Segment Delivery Configuration
18-
params.DefaultSegmentDeliveryConfiguration = getDefaultSegmentDeliveryConfigurationInput(model.DefaultSegmentDeliveryConfiguration)
20+
if model.DefaultSegmentDeliveryConfiguration != nil {
21+
params.DefaultSegmentDeliveryConfiguration = getDefaultSegmentDeliveryConfigurationInput(model.DefaultSegmentDeliveryConfiguration)
22+
}
1923

2024
// HTTP Configuration
2125
params.HttpConfiguration = getHttpConfigurationInput(model.HttpConfiguration)

awsmt/resource_source_location_test.go

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,24 @@ import (
77
"testing"
88
)
99

10+
func TestAccSourceLocationResourceMinimal(t *testing.T) {
11+
resourceName := "awsmt_source_location.test_source_location"
12+
name := "minimalSourceLocation"
13+
resource.Test(t, resource.TestCase{
14+
PreCheck: func() { testAccPreCheck(t) },
15+
ProtoV6ProviderFactories: testAccProtoV6ProviderFactories,
16+
Steps: []resource.TestStep{
17+
{
18+
Config: minimalSourceLocation(name),
19+
Check: resource.ComposeAggregateTestCheckFunc(
20+
resource.TestCheckResourceAttr(resourceName, "id", name),
21+
resource.TestCheckResourceAttr(resourceName, "default_segment_delivery_configuration.base_url", "https://ott-mediatailor-test.s3.eu-central-1.amazonaws.com"),
22+
),
23+
},
24+
},
25+
})
26+
}
27+
1028
func TestAccSourceLocationResourceBasic(t *testing.T) {
1129
resourceName := "awsmt_source_location.test_source_location"
1230
name := "test_source_location"
@@ -130,6 +148,24 @@ func TestAccSourceLocationDeleteVodResource(t *testing.T) {
130148
})
131149
}
132150

151+
func minimalSourceLocation(name string) string {
152+
return fmt.Sprintf(`
153+
resource "awsmt_source_location" "test_source_location"{
154+
name = "%[1]s"
155+
http_configuration = {
156+
base_url = "https://ott-mediatailor-test.s3.eu-central-1.amazonaws.com"
157+
}
158+
}
159+
data "awsmt_source_location" "read" {
160+
name = awsmt_source_location.test_source_location.name
161+
}
162+
output "awsmt_source_location" {
163+
value = data.awsmt_source_location.read
164+
}
165+
`, name)
166+
167+
}
168+
133169
func basicSourceLocation(name, baseUrl, k1, v1, k2, v2 string) string {
134170
return fmt.Sprintf(`
135171
resource "awsmt_source_location" "test_source_location"{

0 commit comments

Comments
 (0)