Skip to content

Commit

Permalink
r/aws_cloudfront_distribution: Avoid raw pointer dereferences (hashic…
Browse files Browse the repository at this point in the history
  • Loading branch information
ewbankkit committed Aug 25, 2020
1 parent b8e69a1 commit d107cb1
Showing 1 changed file with 21 additions and 21 deletions.
42 changes: 21 additions & 21 deletions aws/cloudfront_distribution_configuration_structure.go
Original file line number Diff line number Diff line change
Expand Up @@ -297,12 +297,12 @@ func flattenCloudFrontDefaultCacheBehavior(dcb *cloudfront.DefaultCacheBehavior)
func flattenCacheBehavior(cb *cloudfront.CacheBehavior) map[string]interface{} {
m := make(map[string]interface{})

m["compress"] = *cb.Compress
m["compress"] = aws.BoolValue(cb.Compress)
m["field_level_encryption_id"] = aws.StringValue(cb.FieldLevelEncryptionId)
m["viewer_protocol_policy"] = *cb.ViewerProtocolPolicy
m["target_origin_id"] = *cb.TargetOriginId
m["viewer_protocol_policy"] = aws.StringValue(cb.ViewerProtocolPolicy)
m["target_origin_id"] = aws.StringValue(cb.TargetOriginId)
m["forwarded_values"] = []interface{}{flattenForwardedValues(cb.ForwardedValues)}
m["min_ttl"] = int(*cb.MinTTL)
m["min_ttl"] = int(aws.Int64Value(cb.MinTTL))

if len(cb.TrustedSigners.Items) > 0 {
m["trusted_signers"] = flattenTrustedSigners(cb.TrustedSigners)
Expand Down Expand Up @@ -402,9 +402,9 @@ func flattenLambdaFunctionAssociations(lfa *cloudfront.LambdaFunctionAssociation
func flattenLambdaFunctionAssociation(lfa *cloudfront.LambdaFunctionAssociation) map[string]interface{} {
m := map[string]interface{}{}
if lfa != nil {
m["event_type"] = *lfa.EventType
m["lambda_arn"] = *lfa.LambdaFunctionARN
m["include_body"] = *lfa.IncludeBody
m["event_type"] = aws.StringValue(lfa.EventType)
m["lambda_arn"] = aws.StringValue(lfa.LambdaFunctionARN)
m["include_body"] = aws.BoolValue(lfa.IncludeBody)
}
return m
}
Expand All @@ -427,7 +427,7 @@ func expandForwardedValues(m map[string]interface{}) *cloudfront.ForwardedValues

func flattenForwardedValues(fv *cloudfront.ForwardedValues) map[string]interface{} {
m := make(map[string]interface{})
m["query_string"] = *fv.QueryString
m["query_string"] = aws.BoolValue(fv.QueryString)
if fv.Cookies != nil {
m["cookies"] = []interface{}{flattenCookiePreference(fv.Cookies)}
}
Expand Down Expand Up @@ -480,7 +480,7 @@ func expandCookiePreference(m map[string]interface{}) *cloudfront.CookiePreferen

func flattenCookiePreference(cp *cloudfront.CookiePreference) map[string]interface{} {
m := make(map[string]interface{})
m["forward"] = *cp.Forward
m["forward"] = aws.StringValue(cp.Forward)
if cp.WhitelistedNames != nil {
m["whitelisted_names"] = schema.NewSet(schema.HashString, flattenCookieNames(cp.WhitelistedNames))
}
Expand Down Expand Up @@ -636,7 +636,7 @@ func expandOriginGroup(m map[string]interface{}) *cloudfront.OriginGroup {

func flattenOriginGroup(og *cloudfront.OriginGroup) map[string]interface{} {
m := make(map[string]interface{})
m["origin_id"] = *og.Id
m["origin_id"] = aws.StringValue(og.Id)
if og.FailoverCriteria != nil {
m["failover_criteria"] = flattenOriginGroupFailoverCriteria(og.FailoverCriteria)
}
Expand Down Expand Up @@ -666,7 +666,7 @@ func flattenOriginGroupFailoverCriteria(ogfc *cloudfront.OriginGroupFailoverCrit
if ogfc.StatusCodes.Items != nil {
l := []interface{}{}
for _, i := range ogfc.StatusCodes.Items {
l = append(l, int(*i))
l = append(l, int(aws.Int64Value(i)))
}
m["status_codes"] = schema.NewSet(schema.HashInt, l)
}
Expand All @@ -693,7 +693,7 @@ func flattenOriginGroupMembers(ogm *cloudfront.OriginGroupMembers) []interface{}
s := []interface{}{}
for _, i := range ogm.Items {
m := map[string]interface{}{
"origin_id": *i.OriginId,
"origin_id": aws.StringValue(i.OriginId),
}
s = append(s, m)
}
Expand Down Expand Up @@ -794,8 +794,8 @@ func expandOriginCustomHeader(m map[string]interface{}) *cloudfront.OriginCustom

func flattenOriginCustomHeader(och *cloudfront.OriginCustomHeader) map[string]interface{} {
return map[string]interface{}{
"name": *och.HeaderName,
"value": *och.HeaderValue,
"name": aws.StringValue(och.HeaderName),
"value": aws.StringValue(och.HeaderValue),
}
}

Expand Down Expand Up @@ -836,12 +836,12 @@ func expandCustomOriginConfig(m map[string]interface{}) *cloudfront.CustomOrigin
func flattenCustomOriginConfig(cor *cloudfront.CustomOriginConfig) map[string]interface{} {

customOrigin := map[string]interface{}{
"origin_protocol_policy": *cor.OriginProtocolPolicy,
"http_port": int(*cor.HTTPPort),
"https_port": int(*cor.HTTPSPort),
"origin_protocol_policy": aws.StringValue(cor.OriginProtocolPolicy),
"http_port": int(aws.Int64Value(cor.HTTPPort)),
"https_port": int(aws.Int64Value(cor.HTTPSPort)),
"origin_ssl_protocols": flattenCustomOriginConfigSSL(cor.OriginSslProtocols),
"origin_read_timeout": int(*cor.OriginReadTimeout),
"origin_keepalive_timeout": int(*cor.OriginKeepaliveTimeout),
"origin_read_timeout": int(aws.Int64Value(cor.OriginReadTimeout)),
"origin_keepalive_timeout": int(aws.Int64Value(cor.OriginKeepaliveTimeout)),
}

return customOrigin
Expand Down Expand Up @@ -884,7 +884,7 @@ func expandS3OriginConfig(m map[string]interface{}) *cloudfront.S3OriginConfig {

func flattenS3OriginConfig(s3o *cloudfront.S3OriginConfig) map[string]interface{} {
return map[string]interface{}{
"origin_access_identity": *s3o.OriginAccessIdentity,
"origin_access_identity": aws.StringValue(s3o.OriginAccessIdentity),
}
}

Expand Down Expand Up @@ -939,7 +939,7 @@ func expandCustomErrorResponse(m map[string]interface{}) *cloudfront.CustomError

func flattenCustomErrorResponse(er *cloudfront.CustomErrorResponse) map[string]interface{} {
m := make(map[string]interface{})
m["error_code"] = int(*er.ErrorCode)
m["error_code"] = int(aws.Int64Value(er.ErrorCode))
if er.ErrorCachingMinTTL != nil {
m["error_caching_min_ttl"] = int(*er.ErrorCachingMinTTL)
}
Expand Down

0 comments on commit d107cb1

Please sign in to comment.