Skip to content

Commit f4b5507

Browse files
[CLOUD-1300] add nil check before accessing inside items (#1)
* add nil check before accessing inside items * address PR comment * update codeowners
1 parent 61ce7cc commit f4b5507

2 files changed

Lines changed: 10 additions & 10 deletions

File tree

CODEOWNERS

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
* @hashicorp/terraform-aws
2-
/.github/ @breathingdust @justinretzolk @hashicorp/terraform-aws
1+
# Global owners (fallback for unmatched files)
2+
* @sks @nasir-rabbani @Rchanger @vishwajeetk1160

internal/service/cloudfront/distribution.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1496,15 +1496,15 @@ func flattenCacheBehavior(apiObject *awstypes.CacheBehavior) map[string]interfac
14961496
tfMap["forwarded_values"] = []interface{}{flattenForwardedValues(apiObject.ForwardedValues)}
14971497
}
14981498

1499-
if len(apiObject.FunctionAssociations.Items) > 0 {
1499+
if apiObject.FunctionAssociations != nil && len(apiObject.FunctionAssociations.Items) > 0 {
15001500
tfMap["function_association"] = flattenFunctionAssociations(apiObject.FunctionAssociations)
15011501
}
15021502

15031503
if apiObject.GrpcConfig != nil {
15041504
tfMap["grpc_config"] = []interface{}{flattenGRPCConfig(apiObject.GrpcConfig)}
15051505
}
15061506

1507-
if len(apiObject.LambdaFunctionAssociations.Items) > 0 {
1507+
if apiObject.LambdaFunctionAssociations != nil && len(apiObject.LambdaFunctionAssociations.Items) > 0 {
15081508
tfMap["lambda_function_association"] = flattenLambdaFunctionAssociations(apiObject.LambdaFunctionAssociations)
15091509
}
15101510

@@ -1520,11 +1520,11 @@ func flattenCacheBehavior(apiObject *awstypes.CacheBehavior) map[string]interfac
15201520
tfMap["smooth_streaming"] = aws.ToBool(apiObject.SmoothStreaming)
15211521
}
15221522

1523-
if len(apiObject.TrustedKeyGroups.Items) > 0 {
1523+
if apiObject.TrustedKeyGroups != nil && len(apiObject.TrustedKeyGroups.Items) > 0 {
15241524
tfMap["trusted_key_groups"] = flattenTrustedKeyGroups(apiObject.TrustedKeyGroups)
15251525
}
15261526

1527-
if len(apiObject.TrustedSigners.Items) > 0 {
1527+
if apiObject.TrustedSigners != nil && len(apiObject.TrustedSigners.Items) > 0 {
15281528
tfMap["trusted_signers"] = flattenTrustedSigners(apiObject.TrustedSigners)
15291529
}
15301530

@@ -1646,15 +1646,15 @@ func flattenDefaultCacheBehavior(apiObject *awstypes.DefaultCacheBehavior) map[s
16461646
tfMap["forwarded_values"] = []interface{}{flattenForwardedValues(apiObject.ForwardedValues)}
16471647
}
16481648

1649-
if len(apiObject.FunctionAssociations.Items) > 0 {
1649+
if apiObject.FunctionAssociations != nil && len(apiObject.FunctionAssociations.Items) > 0 {
16501650
tfMap["function_association"] = flattenFunctionAssociations(apiObject.FunctionAssociations)
16511651
}
16521652

16531653
if apiObject.GrpcConfig != nil {
16541654
tfMap["grpc_config"] = []interface{}{flattenGRPCConfig(apiObject.GrpcConfig)}
16551655
}
16561656

1657-
if len(apiObject.LambdaFunctionAssociations.Items) > 0 {
1657+
if apiObject.LambdaFunctionAssociations != nil && len(apiObject.LambdaFunctionAssociations.Items) > 0 {
16581658
tfMap["lambda_function_association"] = flattenLambdaFunctionAssociations(apiObject.LambdaFunctionAssociations)
16591659
}
16601660

@@ -1666,11 +1666,11 @@ func flattenDefaultCacheBehavior(apiObject *awstypes.DefaultCacheBehavior) map[s
16661666
tfMap["smooth_streaming"] = aws.ToBool(apiObject.SmoothStreaming)
16671667
}
16681668

1669-
if len(apiObject.TrustedKeyGroups.Items) > 0 {
1669+
if apiObject.TrustedKeyGroups != nil && len(apiObject.TrustedKeyGroups.Items) > 0 {
16701670
tfMap["trusted_key_groups"] = flattenTrustedKeyGroups(apiObject.TrustedKeyGroups)
16711671
}
16721672

1673-
if len(apiObject.TrustedSigners.Items) > 0 {
1673+
if apiObject.TrustedSigners != nil && len(apiObject.TrustedSigners.Items) > 0 {
16741674
tfMap["trusted_signers"] = flattenTrustedSigners(apiObject.TrustedSigners)
16751675
}
16761676

0 commit comments

Comments
 (0)