Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

resource/aws_cloudfront_distribution: Adjust TypeSet and TypeList attributes for better difference handling #7732

Merged
merged 1 commit into from
Feb 27, 2019

Conversation

bflad
Copy link
Contributor

@bflad bflad commented Feb 26, 2019

Closes #7709
Closes #5526
Closes #4338
Closes #3842
Closes #3766
Closes #3256
Closes #1194
Closes #824
Closes #416

The usage of TypeSet for single container block attributes can cause unnecessary problems with Terraform's difference logic and makes plan output unnecessarily more difficult to read. Here we adjust these to TypeList.

Converted the following from Type: schema.TypeSet and MaxItems: 1 to Type: schema.TypeList:

  • default_cache_behavior configuration block
  • default_cache_behavior configuration block forwarded_values configuration block
  • default_cache_behavior configuration block forwarded_values configuration block cookies configuration block
  • logging_config configuration block
  • origin configuration block custom_origin_config configuration block
  • origin configuration block s3_origin_config configuration block
  • ordered_cache_behavior configuration block forwarded_values configuration block
  • ordered_cache_behavior configuration block forwarded_values configuration block cookies configuration block
  • restrictions configuration block
  • restrictions configuration block geo_restriction configuration block
  • viewer_certificate configuration block

The usage of TypeList for arguments where ordering does not matter causes unnecessary hassle for operators to match their configuration to the CloudFront API. Here we replace these with TypeSet to ignore ordering.

Converted the following from Type: schema.TypeList to Type: schema.TypeSet:

  • default_cache_behavior configuration block allowed_methods argument
  • default_cache_behavior configuration block cached_methods argument
  • origin configuration block custom_origin_config configuration block origin_ssl_protocols argument
  • restrictions configuration block geo_restriction configuration block locations argument

This change was verified with a live configuration outside the acceptance testing framework with Terraform 0.11 as effectively a no-op for the most common use case configurations that do not later reference these attributes.

$ terraform apply
...
aws_cloudfront_distribution.test: Creating...
  active_trusted_signers.%:                                                                             "" => "<computed>"
  arn:                                                                                                  "" => "<computed>"
  caller_reference:                                                                                     "" => "<computed>"
  default_cache_behavior.#:                                                                             "0" => "1"
  default_cache_behavior.1848826977.allowed_methods.#:                                                  "0" => "7"
  default_cache_behavior.1848826977.allowed_methods.0:                                                  "" => "DELETE"
  default_cache_behavior.1848826977.allowed_methods.1:                                                  "" => "GET"
  default_cache_behavior.1848826977.allowed_methods.2:                                                  "" => "HEAD"
  default_cache_behavior.1848826977.allowed_methods.3:                                                  "" => "OPTIONS"
  default_cache_behavior.1848826977.allowed_methods.4:                                                  "" => "PATCH"
  default_cache_behavior.1848826977.allowed_methods.5:                                                  "" => "POST"
  default_cache_behavior.1848826977.allowed_methods.6:                                                  "" => "PUT"
  default_cache_behavior.1848826977.cached_methods.#:                                                   "0" => "2"
  default_cache_behavior.1848826977.cached_methods.0:                                                   "" => "GET"
  default_cache_behavior.1848826977.cached_methods.1:                                                   "" => "HEAD"
  default_cache_behavior.1848826977.compress:                                                           "" => "false"
  default_cache_behavior.1848826977.default_ttl:                                                        "" => "100"
  default_cache_behavior.1848826977.field_level_encryption_id:                                          "" => ""
  default_cache_behavior.1848826977.forwarded_values.#:                                                 "0" => "1"
  default_cache_behavior.1848826977.forwarded_values.2510654351.cookies.#:                              "0" => "1"
  default_cache_behavior.1848826977.forwarded_values.2510654351.cookies.1870923232.forward:             "" => "all"
  default_cache_behavior.1848826977.forwarded_values.2510654351.cookies.1870923232.whitelisted_names.#: "0" => "0"
  default_cache_behavior.1848826977.forwarded_values.2510654351.headers.#:                              "0" => "0"
  default_cache_behavior.1848826977.forwarded_values.2510654351.query_string:                           "" => "false"
  default_cache_behavior.1848826977.forwarded_values.2510654351.query_string_cache_keys.#:              "0" => "0"
  default_cache_behavior.1848826977.lambda_function_association.#:                                      "0" => "0"
  default_cache_behavior.1848826977.max_ttl:                                                            "" => "100"
  default_cache_behavior.1848826977.min_ttl:                                                            "" => "100"
  default_cache_behavior.1848826977.smooth_streaming:                                                   "" => "true"
  default_cache_behavior.1848826977.target_origin_id:                                                   "" => "myCustomOrigin"
  default_cache_behavior.1848826977.trusted_signers.#:                                                  "0" => "0"
  default_cache_behavior.1848826977.viewer_protocol_policy:                                             "" => "allow-all"
  domain_name:                                                                                          "" => "<computed>"
  enabled:                                                                                              "" => "true"
  etag:                                                                                                 "" => "<computed>"
  hosted_zone_id:                                                                                       "" => "<computed>"
  http_version:                                                                                         "" => "http2"
  in_progress_validation_batches:                                                                       "" => "<computed>"
  is_ipv6_enabled:                                                                                      "" => "false"
  last_modified_time:                                                                                   "" => "<computed>"
  ordered_cache_behavior.#:                                                                             "0" => "2"
  ordered_cache_behavior.0.allowed_methods.#:                                                           "0" => "7"
  ordered_cache_behavior.0.allowed_methods.1012961568:                                                  "" => "POST"
  ordered_cache_behavior.0.allowed_methods.1040875975:                                                  "" => "GET"
  ordered_cache_behavior.0.allowed_methods.1445840968:                                                  "" => "HEAD"
  ordered_cache_behavior.0.allowed_methods.1741119464:                                                  "" => "PATCH"
  ordered_cache_behavior.0.allowed_methods.348445828:                                                   "" => "DELETE"
  ordered_cache_behavior.0.allowed_methods.3982006612:                                                  "" => "OPTIONS"
  ordered_cache_behavior.0.allowed_methods.4024585617:                                                  "" => "PUT"
  ordered_cache_behavior.0.cached_methods.#:                                                            "0" => "2"
  ordered_cache_behavior.0.cached_methods.1040875975:                                                   "" => "GET"
  ordered_cache_behavior.0.cached_methods.1445840968:                                                   "" => "HEAD"
  ordered_cache_behavior.0.compress:                                                                    "" => "false"
  ordered_cache_behavior.0.default_ttl:                                                                 "" => "50"
  ordered_cache_behavior.0.forwarded_values.#:                                                          "0" => "1"
  ordered_cache_behavior.0.forwarded_values.2555876073.cookies.#:                                       "0" => "1"
  ordered_cache_behavior.0.forwarded_values.2555876073.cookies.2625240281.forward:                      "" => "none"
  ordered_cache_behavior.0.forwarded_values.2555876073.cookies.2625240281.whitelisted_names.#:          "0" => "0"
  ordered_cache_behavior.0.forwarded_values.2555876073.headers.#:                                       "0" => "0"
  ordered_cache_behavior.0.forwarded_values.2555876073.query_string:                                    "" => "true"
  ordered_cache_behavior.0.forwarded_values.2555876073.query_string_cache_keys.#:                       "0" => "0"
  ordered_cache_behavior.0.max_ttl:                                                                     "" => "50"
  ordered_cache_behavior.0.min_ttl:                                                                     "" => "50"
  ordered_cache_behavior.0.path_pattern:                                                                "" => "images1/*.jpg"
  ordered_cache_behavior.0.target_origin_id:                                                            "" => "myCustomOrigin"
  ordered_cache_behavior.0.viewer_protocol_policy:                                                      "" => "allow-all"
  ordered_cache_behavior.1.allowed_methods.#:                                                           "0" => "7"
  ordered_cache_behavior.1.allowed_methods.1012961568:                                                  "" => "POST"
  ordered_cache_behavior.1.allowed_methods.1040875975:                                                  "" => "GET"
  ordered_cache_behavior.1.allowed_methods.1445840968:                                                  "" => "HEAD"
  ordered_cache_behavior.1.allowed_methods.1741119464:                                                  "" => "PATCH"
  ordered_cache_behavior.1.allowed_methods.348445828:                                                   "" => "DELETE"
  ordered_cache_behavior.1.allowed_methods.3982006612:                                                  "" => "OPTIONS"
  ordered_cache_behavior.1.allowed_methods.4024585617:                                                  "" => "PUT"
  ordered_cache_behavior.1.cached_methods.#:                                                            "0" => "2"
  ordered_cache_behavior.1.cached_methods.1040875975:                                                   "" => "GET"
  ordered_cache_behavior.1.cached_methods.1445840968:                                                   "" => "HEAD"
  ordered_cache_behavior.1.compress:                                                                    "" => "false"
  ordered_cache_behavior.1.default_ttl:                                                                 "" => "51"
  ordered_cache_behavior.1.forwarded_values.#:                                                          "0" => "1"
  ordered_cache_behavior.1.forwarded_values.2555876073.cookies.#:                                       "0" => "1"
  ordered_cache_behavior.1.forwarded_values.2555876073.cookies.2625240281.forward:                      "" => "none"
  ordered_cache_behavior.1.forwarded_values.2555876073.cookies.2625240281.whitelisted_names.#:          "0" => "0"
  ordered_cache_behavior.1.forwarded_values.2555876073.headers.#:                                       "0" => "0"
  ordered_cache_behavior.1.forwarded_values.2555876073.query_string:                                    "" => "true"
  ordered_cache_behavior.1.forwarded_values.2555876073.query_string_cache_keys.#:                       "0" => "0"
  ordered_cache_behavior.1.max_ttl:                                                                     "" => "51"
  ordered_cache_behavior.1.min_ttl:                                                                     "" => "51"
  ordered_cache_behavior.1.path_pattern:                                                                "" => "images2/*.jpg"
  ordered_cache_behavior.1.target_origin_id:                                                            "" => "myCustomOrigin"
  ordered_cache_behavior.1.viewer_protocol_policy:                                                      "" => "allow-all"
  origin.#:                                                                                             "0" => "1"
  origin.1857972443.custom_header.#:                                                                    "0" => "0"
  origin.1857972443.custom_origin_config.#:                                                             "0" => "1"
  origin.1857972443.custom_origin_config.3832794885.http_port:                                          "" => "80"
  origin.1857972443.custom_origin_config.3832794885.https_port:                                         "" => "443"
  origin.1857972443.custom_origin_config.3832794885.origin_keepalive_timeout:                           "" => "5"
  origin.1857972443.custom_origin_config.3832794885.origin_protocol_policy:                             "" => "http-only"
  origin.1857972443.custom_origin_config.3832794885.origin_read_timeout:                                "" => "30"
  origin.1857972443.custom_origin_config.3832794885.origin_ssl_protocols.#:                             "0" => "2"
  origin.1857972443.custom_origin_config.3832794885.origin_ssl_protocols.0:                             "" => "SSLv3"
  origin.1857972443.custom_origin_config.3832794885.origin_ssl_protocols.1:                             "" => "TLSv1"
  origin.1857972443.domain_name:                                                                        "" => "www.example.com"
  origin.1857972443.origin_id:                                                                          "" => "myCustomOrigin"
  origin.1857972443.origin_path:                                                                        "" => ""
  origin.1857972443.s3_origin_config.#:                                                                 "0" => "0"
  price_class:                                                                                          "" => "PriceClass_All"
  restrictions.#:                                                                                       "0" => "1"
  restrictions.811065190.geo_restriction.#:                                                             "0" => "1"
  restrictions.811065190.geo_restriction.1303118592.locations.#:                                        "0" => "4"
  restrictions.811065190.geo_restriction.1303118592.locations.0:                                        "" => "US"
  restrictions.811065190.geo_restriction.1303118592.locations.1:                                        "" => "CA"
  restrictions.811065190.geo_restriction.1303118592.locations.2:                                        "" => "GB"
  restrictions.811065190.geo_restriction.1303118592.locations.3:                                        "" => "DE"
  restrictions.811065190.geo_restriction.1303118592.restriction_type:                                   "" => "whitelist"
  retain_on_delete:                                                                                     "" => "false"
  status:                                                                                               "" => "<computed>"
  viewer_certificate.#:                                                                                 "0" => "1"
  viewer_certificate.69840937.acm_certificate_arn:                                                      "" => ""
  viewer_certificate.69840937.cloudfront_default_certificate:                                           "" => "true"
  viewer_certificate.69840937.iam_certificate_id:                                                       "" => ""
  viewer_certificate.69840937.minimum_protocol_version:                                                 "" => "TLSv1"
  viewer_certificate.69840937.ssl_support_method:                                                       "" => ""
aws_cloudfront_distribution.test: Creation complete after 0s (ID: E3K1GJF3SSNJRN)

Apply complete! Resources: 1 added, 0 changed, 0 destroyed.

$ cp ~/go/bin/terraform-provider-aws .terraform/plugins/darwin_amd64/terraform-provider-aws_v1.60.0_x4; terraform init # this binary is an updated Terraform AWS Provider built with these changes

$ terraform apply # Here we see no state migration required
aws_cloudfront_distribution.test: Refreshing state... (ID: E3K1GJF3SSNJRN)

Apply complete! Resources: 0 added, 0 changed, 0 destroyed.

$ terraform state show aws_cloudfront_distribution.test # Here we see a successful state refresh with the new layout
id                                                                        = E3K1GJF3SSNJRN
active_trusted_signers.%                                                  = 2
active_trusted_signers.enabled                                            = false
active_trusted_signers.items.#                                            = 0
aliases.#                                                                 = 0
arn                                                                       = arn:aws:cloudfront::187416307283:distribution/E3K1GJF3SSNJRN
caller_reference                                                          = 2019-02-25T14:51:42.674464-05:00
custom_error_response.#                                                   = 0
default_cache_behavior.#                                                  = 1
default_cache_behavior.0.allowed_methods.#                                = 7
default_cache_behavior.0.allowed_methods.1012961568                       = POST
default_cache_behavior.0.allowed_methods.1040875975                       = GET
default_cache_behavior.0.allowed_methods.1445840968                       = HEAD
default_cache_behavior.0.allowed_methods.1741119464                       = PATCH
default_cache_behavior.0.allowed_methods.348445828                        = DELETE
default_cache_behavior.0.allowed_methods.3982006612                       = OPTIONS
default_cache_behavior.0.allowed_methods.4024585617                       = PUT
default_cache_behavior.0.cached_methods.#                                 = 2
default_cache_behavior.0.cached_methods.1040875975                        = GET
default_cache_behavior.0.cached_methods.1445840968                        = HEAD
default_cache_behavior.0.compress                                         = false
default_cache_behavior.0.default_ttl                                      = 100
default_cache_behavior.0.field_level_encryption_id                        =
default_cache_behavior.0.forwarded_values.#                               = 1
default_cache_behavior.0.forwarded_values.0.cookies.#                     = 1
default_cache_behavior.0.forwarded_values.0.cookies.0.forward             = all
default_cache_behavior.0.forwarded_values.0.cookies.0.whitelisted_names.# = 0
default_cache_behavior.0.forwarded_values.0.headers.#                     = 0
default_cache_behavior.0.forwarded_values.0.query_string                  = false
default_cache_behavior.0.forwarded_values.0.query_string_cache_keys.#     = 0
default_cache_behavior.0.lambda_function_association.#                    = 0
default_cache_behavior.0.max_ttl                                          = 100
default_cache_behavior.0.min_ttl                                          = 100
default_cache_behavior.0.smooth_streaming                                 = true
default_cache_behavior.0.target_origin_id                                 = myCustomOrigin
default_cache_behavior.0.trusted_signers.#                                = 0
default_cache_behavior.0.viewer_protocol_policy                           = allow-all
default_root_object                                                       =
domain_name                                                               = dot6h04nf0cmx.cloudfront.net
enabled                                                                   = true
etag                                                                      = E33ZADXZHBHVXT
hosted_zone_id                                                            = Z2FDTNDATAQYW2
http_version                                                              = http2
in_progress_validation_batches                                            = 0
is_ipv6_enabled                                                           = false
last_modified_time                                                        = 2019-02-26 02:22:40.558 +0000 UTC
logging_config.#                                                          = 0
ordered_cache_behavior.#                                                  = 2
ordered_cache_behavior.0.allowed_methods.#                                = 7
ordered_cache_behavior.0.allowed_methods.1012961568                       = POST
ordered_cache_behavior.0.allowed_methods.1040875975                       = GET
ordered_cache_behavior.0.allowed_methods.1445840968                       = HEAD
ordered_cache_behavior.0.allowed_methods.1741119464                       = PATCH
ordered_cache_behavior.0.allowed_methods.348445828                        = DELETE
ordered_cache_behavior.0.allowed_methods.3982006612                       = OPTIONS
ordered_cache_behavior.0.allowed_methods.4024585617                       = PUT
ordered_cache_behavior.0.cached_methods.#                                 = 2
ordered_cache_behavior.0.cached_methods.1040875975                        = GET
ordered_cache_behavior.0.cached_methods.1445840968                        = HEAD
ordered_cache_behavior.0.compress                                         = false
ordered_cache_behavior.0.default_ttl                                      = 50
ordered_cache_behavior.0.field_level_encryption_id                        =
ordered_cache_behavior.0.forwarded_values.#                               = 1
ordered_cache_behavior.0.forwarded_values.0.cookies.#                     = 1
ordered_cache_behavior.0.forwarded_values.0.cookies.0.forward             = none
ordered_cache_behavior.0.forwarded_values.0.cookies.0.whitelisted_names.# = 0
ordered_cache_behavior.0.forwarded_values.0.headers.#                     = 0
ordered_cache_behavior.0.forwarded_values.0.query_string                  = true
ordered_cache_behavior.0.forwarded_values.0.query_string_cache_keys.#     = 0
ordered_cache_behavior.0.lambda_function_association.#                    = 0
ordered_cache_behavior.0.max_ttl                                          = 50
ordered_cache_behavior.0.min_ttl                                          = 50
ordered_cache_behavior.0.path_pattern                                     = images1/*.jpg
ordered_cache_behavior.0.smooth_streaming                                 = false
ordered_cache_behavior.0.target_origin_id                                 = myCustomOrigin
ordered_cache_behavior.0.trusted_signers.#                                = 0
ordered_cache_behavior.0.viewer_protocol_policy                           = allow-all
ordered_cache_behavior.1.allowed_methods.#                                = 7
ordered_cache_behavior.1.allowed_methods.1012961568                       = POST
ordered_cache_behavior.1.allowed_methods.1040875975                       = GET
ordered_cache_behavior.1.allowed_methods.1445840968                       = HEAD
ordered_cache_behavior.1.allowed_methods.1741119464                       = PATCH
ordered_cache_behavior.1.allowed_methods.348445828                        = DELETE
ordered_cache_behavior.1.allowed_methods.3982006612                       = OPTIONS
ordered_cache_behavior.1.allowed_methods.4024585617                       = PUT
ordered_cache_behavior.1.cached_methods.#                                 = 2
ordered_cache_behavior.1.cached_methods.1040875975                        = GET
ordered_cache_behavior.1.cached_methods.1445840968                        = HEAD
ordered_cache_behavior.1.compress                                         = false
ordered_cache_behavior.1.default_ttl                                      = 51
ordered_cache_behavior.1.field_level_encryption_id                        =
ordered_cache_behavior.1.forwarded_values.#                               = 1
ordered_cache_behavior.1.forwarded_values.0.cookies.#                     = 1
ordered_cache_behavior.1.forwarded_values.0.cookies.0.forward             = none
ordered_cache_behavior.1.forwarded_values.0.cookies.0.whitelisted_names.# = 0
ordered_cache_behavior.1.forwarded_values.0.headers.#                     = 0
ordered_cache_behavior.1.forwarded_values.0.query_string                  = true
ordered_cache_behavior.1.forwarded_values.0.query_string_cache_keys.#     = 0
ordered_cache_behavior.1.lambda_function_association.#                    = 0
ordered_cache_behavior.1.max_ttl                                          = 51
ordered_cache_behavior.1.min_ttl                                          = 51
ordered_cache_behavior.1.path_pattern                                     = images2/*.jpg
ordered_cache_behavior.1.smooth_streaming                                 = false
ordered_cache_behavior.1.target_origin_id                                 = myCustomOrigin
ordered_cache_behavior.1.trusted_signers.#                                = 0
ordered_cache_behavior.1.viewer_protocol_policy                           = allow-all
origin.#                                                                  = 1
origin.1857972443.custom_header.#                                         = 0
origin.1857972443.custom_origin_config.#                                  = 1
origin.1857972443.custom_origin_config.0.http_port                        = 80
origin.1857972443.custom_origin_config.0.https_port                       = 443
origin.1857972443.custom_origin_config.0.origin_keepalive_timeout         = 5
origin.1857972443.custom_origin_config.0.origin_protocol_policy           = http-only
origin.1857972443.custom_origin_config.0.origin_read_timeout              = 30
origin.1857972443.custom_origin_config.0.origin_ssl_protocols.#           = 2
origin.1857972443.custom_origin_config.0.origin_ssl_protocols.1162609714  = TLSv1
origin.1857972443.custom_origin_config.0.origin_ssl_protocols.2159350162  = SSLv3
origin.1857972443.domain_name                                             = www.example.com
origin.1857972443.origin_id                                               = myCustomOrigin
origin.1857972443.origin_path                                             =
origin.1857972443.s3_origin_config.#                                      = 0
price_class                                                               = PriceClass_All
restrictions.#                                                            = 1
restrictions.0.geo_restriction.#                                          = 1
restrictions.0.geo_restriction.0.locations.#                              = 4
restrictions.0.geo_restriction.0.locations.3034033770                     = DE
restrictions.0.geo_restriction.0.locations.3047936762                     = US
restrictions.0.geo_restriction.0.locations.3589570027                     = CA
restrictions.0.geo_restriction.0.locations.4191192820                     = GB
restrictions.0.geo_restriction.0.restriction_type                         = whitelist
retain_on_delete                                                          = false
status                                                                    = Deployed
tags.%                                                                    = 0
viewer_certificate.#                                                      = 1
viewer_certificate.0.acm_certificate_arn                                  =
viewer_certificate.0.cloudfront_default_certificate                       = true
viewer_certificate.0.iam_certificate_id                                   =
viewer_certificate.0.minimum_protocol_version                             = TLSv1
viewer_certificate.0.ssl_support_method                                   =
web_acl_id                                                                =

Output from acceptance testing:

--- PASS: TestAccAWSCloudFrontDistribution_Origin_EmptyOriginID (1.04s)
--- PASS: TestAccAWSCloudFrontDistribution_Origin_EmptyDomainName (1.12s)
--- PASS: TestAccAWSCloudFrontDistribution_orderedCacheBehavior (1082.43s)
--- PASS: TestAccAWSCloudFrontDistribution_HTTP11Config (1082.47s)
--- PASS: TestAccAWSCloudFrontDistribution_noCustomErrorResponseConfig (1083.16s)
--- PASS: TestAccAWSCloudFrontDistribution_noOptionalItemsConfig (1083.56s)
--- PASS: TestAccAWSCloudFrontDistribution_S3OriginWithTags (1084.20s)
--- PASS: TestAccAWSCloudFrontDistribution_IsIPV6EnabledConfig (1089.11s)
--- PASS: TestAccAWSCloudFrontDistribution_S3Origin (1090.38s)
--- PASS: TestAccAWSCloudFrontDistribution_customOrigin (1092.54s)
--- PASS: TestAccAWSCloudFrontDistribution_multiOrigin (1093.67s)

…ributes for better difference handling

References:
* #7709
* #5526
* #4338
* #3842
* #3766
* #3256
* #1194
* #824
* #416

The usage of `TypeSet` for single container block attributes can cause unnecessary problems with Terraform's difference logic and makes plan output unnecessarily more difficult to read. Here we adjust these to `TypeList`.

Converted the following from `Type: schema.TypeSet` and `MaxItems: 1` to `Type: schema.TypeList`:

* `default_cache_behavior` configuration block
* `default_cache_behavior` configuration block `forwarded_values` configuration block
* `default_cache_behavior` configuration block `forwarded_values` configuration block `cookies` configuration block
* `logging_config` configuration block
* `origin` configuration block `custom_origin_config` configuration block
* `origin` configuration block `s3_origin_config` configuration block
* `ordered_cache_behavior` configuration block `forwarded_values` configuration block
* `ordered_cache_behavior` configuration block `forwarded_values` configuration block `cookies` configuration block
* `restrictions` configuration block
* `restrictions` configuration block `geo_restriction` configuration block
* `viewer_certificate` configuration block

The usage of `TypeList` for arguments where ordering does not matter causes unnecessary hassle for operators to match their configuration to the CloudFront API. Here we replace these with `TypeSet` to ignore ordering.

Converted the following from `Type: schema.TypeList` to `Type: schema.TypeSet`:

* `default_cache_behavior` configuration block `allowed_methods` argument
* `default_cache_behavior` configuration block `cached_methods` argument
* `origin` configuration block `custom_origin_config` configuration block `origin_ssl_protocols` argument
* `restrictions` configuration block `geo_restriction` configuration block `locations` argument

This change was verified with a live configuration outside the acceptance testing framework with Terraform 0.11 as effectively a no-op for the most common use case configurations that do not later reference these attributes.

```console
$ terraform apply
...
aws_cloudfront_distribution.test: Creating...
  active_trusted_signers.%:                                                                             "" => "<computed>"
  arn:                                                                                                  "" => "<computed>"
  caller_reference:                                                                                     "" => "<computed>"
  default_cache_behavior.#:                                                                             "0" => "1"
  default_cache_behavior.1848826977.allowed_methods.#:                                                  "0" => "7"
  default_cache_behavior.1848826977.allowed_methods.0:                                                  "" => "DELETE"
  default_cache_behavior.1848826977.allowed_methods.1:                                                  "" => "GET"
  default_cache_behavior.1848826977.allowed_methods.2:                                                  "" => "HEAD"
  default_cache_behavior.1848826977.allowed_methods.3:                                                  "" => "OPTIONS"
  default_cache_behavior.1848826977.allowed_methods.4:                                                  "" => "PATCH"
  default_cache_behavior.1848826977.allowed_methods.5:                                                  "" => "POST"
  default_cache_behavior.1848826977.allowed_methods.6:                                                  "" => "PUT"
  default_cache_behavior.1848826977.cached_methods.#:                                                   "0" => "2"
  default_cache_behavior.1848826977.cached_methods.0:                                                   "" => "GET"
  default_cache_behavior.1848826977.cached_methods.1:                                                   "" => "HEAD"
  default_cache_behavior.1848826977.compress:                                                           "" => "false"
  default_cache_behavior.1848826977.default_ttl:                                                        "" => "100"
  default_cache_behavior.1848826977.field_level_encryption_id:                                          "" => ""
  default_cache_behavior.1848826977.forwarded_values.#:                                                 "0" => "1"
  default_cache_behavior.1848826977.forwarded_values.2510654351.cookies.#:                              "0" => "1"
  default_cache_behavior.1848826977.forwarded_values.2510654351.cookies.1870923232.forward:             "" => "all"
  default_cache_behavior.1848826977.forwarded_values.2510654351.cookies.1870923232.whitelisted_names.#: "0" => "0"
  default_cache_behavior.1848826977.forwarded_values.2510654351.headers.#:                              "0" => "0"
  default_cache_behavior.1848826977.forwarded_values.2510654351.query_string:                           "" => "false"
  default_cache_behavior.1848826977.forwarded_values.2510654351.query_string_cache_keys.#:              "0" => "0"
  default_cache_behavior.1848826977.lambda_function_association.#:                                      "0" => "0"
  default_cache_behavior.1848826977.max_ttl:                                                            "" => "100"
  default_cache_behavior.1848826977.min_ttl:                                                            "" => "100"
  default_cache_behavior.1848826977.smooth_streaming:                                                   "" => "true"
  default_cache_behavior.1848826977.target_origin_id:                                                   "" => "myCustomOrigin"
  default_cache_behavior.1848826977.trusted_signers.#:                                                  "0" => "0"
  default_cache_behavior.1848826977.viewer_protocol_policy:                                             "" => "allow-all"
  domain_name:                                                                                          "" => "<computed>"
  enabled:                                                                                              "" => "true"
  etag:                                                                                                 "" => "<computed>"
  hosted_zone_id:                                                                                       "" => "<computed>"
  http_version:                                                                                         "" => "http2"
  in_progress_validation_batches:                                                                       "" => "<computed>"
  is_ipv6_enabled:                                                                                      "" => "false"
  last_modified_time:                                                                                   "" => "<computed>"
  ordered_cache_behavior.#:                                                                             "0" => "2"
  ordered_cache_behavior.0.allowed_methods.#:                                                           "0" => "7"
  ordered_cache_behavior.0.allowed_methods.1012961568:                                                  "" => "POST"
  ordered_cache_behavior.0.allowed_methods.1040875975:                                                  "" => "GET"
  ordered_cache_behavior.0.allowed_methods.1445840968:                                                  "" => "HEAD"
  ordered_cache_behavior.0.allowed_methods.1741119464:                                                  "" => "PATCH"
  ordered_cache_behavior.0.allowed_methods.348445828:                                                   "" => "DELETE"
  ordered_cache_behavior.0.allowed_methods.3982006612:                                                  "" => "OPTIONS"
  ordered_cache_behavior.0.allowed_methods.4024585617:                                                  "" => "PUT"
  ordered_cache_behavior.0.cached_methods.#:                                                            "0" => "2"
  ordered_cache_behavior.0.cached_methods.1040875975:                                                   "" => "GET"
  ordered_cache_behavior.0.cached_methods.1445840968:                                                   "" => "HEAD"
  ordered_cache_behavior.0.compress:                                                                    "" => "false"
  ordered_cache_behavior.0.default_ttl:                                                                 "" => "50"
  ordered_cache_behavior.0.forwarded_values.#:                                                          "0" => "1"
  ordered_cache_behavior.0.forwarded_values.2555876073.cookies.#:                                       "0" => "1"
  ordered_cache_behavior.0.forwarded_values.2555876073.cookies.2625240281.forward:                      "" => "none"
  ordered_cache_behavior.0.forwarded_values.2555876073.cookies.2625240281.whitelisted_names.#:          "0" => "0"
  ordered_cache_behavior.0.forwarded_values.2555876073.headers.#:                                       "0" => "0"
  ordered_cache_behavior.0.forwarded_values.2555876073.query_string:                                    "" => "true"
  ordered_cache_behavior.0.forwarded_values.2555876073.query_string_cache_keys.#:                       "0" => "0"
  ordered_cache_behavior.0.max_ttl:                                                                     "" => "50"
  ordered_cache_behavior.0.min_ttl:                                                                     "" => "50"
  ordered_cache_behavior.0.path_pattern:                                                                "" => "images1/*.jpg"
  ordered_cache_behavior.0.target_origin_id:                                                            "" => "myCustomOrigin"
  ordered_cache_behavior.0.viewer_protocol_policy:                                                      "" => "allow-all"
  ordered_cache_behavior.1.allowed_methods.#:                                                           "0" => "7"
  ordered_cache_behavior.1.allowed_methods.1012961568:                                                  "" => "POST"
  ordered_cache_behavior.1.allowed_methods.1040875975:                                                  "" => "GET"
  ordered_cache_behavior.1.allowed_methods.1445840968:                                                  "" => "HEAD"
  ordered_cache_behavior.1.allowed_methods.1741119464:                                                  "" => "PATCH"
  ordered_cache_behavior.1.allowed_methods.348445828:                                                   "" => "DELETE"
  ordered_cache_behavior.1.allowed_methods.3982006612:                                                  "" => "OPTIONS"
  ordered_cache_behavior.1.allowed_methods.4024585617:                                                  "" => "PUT"
  ordered_cache_behavior.1.cached_methods.#:                                                            "0" => "2"
  ordered_cache_behavior.1.cached_methods.1040875975:                                                   "" => "GET"
  ordered_cache_behavior.1.cached_methods.1445840968:                                                   "" => "HEAD"
  ordered_cache_behavior.1.compress:                                                                    "" => "false"
  ordered_cache_behavior.1.default_ttl:                                                                 "" => "51"
  ordered_cache_behavior.1.forwarded_values.#:                                                          "0" => "1"
  ordered_cache_behavior.1.forwarded_values.2555876073.cookies.#:                                       "0" => "1"
  ordered_cache_behavior.1.forwarded_values.2555876073.cookies.2625240281.forward:                      "" => "none"
  ordered_cache_behavior.1.forwarded_values.2555876073.cookies.2625240281.whitelisted_names.#:          "0" => "0"
  ordered_cache_behavior.1.forwarded_values.2555876073.headers.#:                                       "0" => "0"
  ordered_cache_behavior.1.forwarded_values.2555876073.query_string:                                    "" => "true"
  ordered_cache_behavior.1.forwarded_values.2555876073.query_string_cache_keys.#:                       "0" => "0"
  ordered_cache_behavior.1.max_ttl:                                                                     "" => "51"
  ordered_cache_behavior.1.min_ttl:                                                                     "" => "51"
  ordered_cache_behavior.1.path_pattern:                                                                "" => "images2/*.jpg"
  ordered_cache_behavior.1.target_origin_id:                                                            "" => "myCustomOrigin"
  ordered_cache_behavior.1.viewer_protocol_policy:                                                      "" => "allow-all"
  origin.#:                                                                                             "0" => "1"
  origin.1857972443.custom_header.#:                                                                    "0" => "0"
  origin.1857972443.custom_origin_config.#:                                                             "0" => "1"
  origin.1857972443.custom_origin_config.3832794885.http_port:                                          "" => "80"
  origin.1857972443.custom_origin_config.3832794885.https_port:                                         "" => "443"
  origin.1857972443.custom_origin_config.3832794885.origin_keepalive_timeout:                           "" => "5"
  origin.1857972443.custom_origin_config.3832794885.origin_protocol_policy:                             "" => "http-only"
  origin.1857972443.custom_origin_config.3832794885.origin_read_timeout:                                "" => "30"
  origin.1857972443.custom_origin_config.3832794885.origin_ssl_protocols.#:                             "0" => "2"
  origin.1857972443.custom_origin_config.3832794885.origin_ssl_protocols.0:                             "" => "SSLv3"
  origin.1857972443.custom_origin_config.3832794885.origin_ssl_protocols.1:                             "" => "TLSv1"
  origin.1857972443.domain_name:                                                                        "" => "www.example.com"
  origin.1857972443.origin_id:                                                                          "" => "myCustomOrigin"
  origin.1857972443.origin_path:                                                                        "" => ""
  origin.1857972443.s3_origin_config.#:                                                                 "0" => "0"
  price_class:                                                                                          "" => "PriceClass_All"
  restrictions.#:                                                                                       "0" => "1"
  restrictions.811065190.geo_restriction.#:                                                             "0" => "1"
  restrictions.811065190.geo_restriction.1303118592.locations.#:                                        "0" => "4"
  restrictions.811065190.geo_restriction.1303118592.locations.0:                                        "" => "US"
  restrictions.811065190.geo_restriction.1303118592.locations.1:                                        "" => "CA"
  restrictions.811065190.geo_restriction.1303118592.locations.2:                                        "" => "GB"
  restrictions.811065190.geo_restriction.1303118592.locations.3:                                        "" => "DE"
  restrictions.811065190.geo_restriction.1303118592.restriction_type:                                   "" => "whitelist"
  retain_on_delete:                                                                                     "" => "false"
  status:                                                                                               "" => "<computed>"
  viewer_certificate.#:                                                                                 "0" => "1"
  viewer_certificate.69840937.acm_certificate_arn:                                                      "" => ""
  viewer_certificate.69840937.cloudfront_default_certificate:                                           "" => "true"
  viewer_certificate.69840937.iam_certificate_id:                                                       "" => ""
  viewer_certificate.69840937.minimum_protocol_version:                                                 "" => "TLSv1"
  viewer_certificate.69840937.ssl_support_method:                                                       "" => ""
aws_cloudfront_distribution.test: Creation complete after 0s (ID: E3K1GJF3SSNJRN)

Apply complete! Resources: 1 added, 0 changed, 0 destroyed.

$ cp ~/go/bin/terraform-provider-aws .terraform/plugins/darwin_amd64/terraform-provider-aws_v1.60.0_x4; terraform init # this binary is an updated Terraform AWS Provider built with these changes

$ terraform apply # Here we see no state migration required
aws_cloudfront_distribution.test: Refreshing state... (ID: E3K1GJF3SSNJRN)

Apply complete! Resources: 0 added, 0 changed, 0 destroyed.

$ terraform state show aws_cloudfront_distribution.test # Here we see a successful state refresh with the new layout
id                                                                        = E3K1GJF3SSNJRN
active_trusted_signers.%                                                  = 2
active_trusted_signers.enabled                                            = false
active_trusted_signers.items.#                                            = 0
aliases.#                                                                 = 0
arn                                                                       = arn:aws:cloudfront::187416307283:distribution/E3K1GJF3SSNJRN
caller_reference                                                          = 2019-02-25T14:51:42.674464-05:00
custom_error_response.#                                                   = 0
default_cache_behavior.#                                                  = 1
default_cache_behavior.0.allowed_methods.#                                = 7
default_cache_behavior.0.allowed_methods.1012961568                       = POST
default_cache_behavior.0.allowed_methods.1040875975                       = GET
default_cache_behavior.0.allowed_methods.1445840968                       = HEAD
default_cache_behavior.0.allowed_methods.1741119464                       = PATCH
default_cache_behavior.0.allowed_methods.348445828                        = DELETE
default_cache_behavior.0.allowed_methods.3982006612                       = OPTIONS
default_cache_behavior.0.allowed_methods.4024585617                       = PUT
default_cache_behavior.0.cached_methods.#                                 = 2
default_cache_behavior.0.cached_methods.1040875975                        = GET
default_cache_behavior.0.cached_methods.1445840968                        = HEAD
default_cache_behavior.0.compress                                         = false
default_cache_behavior.0.default_ttl                                      = 100
default_cache_behavior.0.field_level_encryption_id                        =
default_cache_behavior.0.forwarded_values.#                               = 1
default_cache_behavior.0.forwarded_values.0.cookies.#                     = 1
default_cache_behavior.0.forwarded_values.0.cookies.0.forward             = all
default_cache_behavior.0.forwarded_values.0.cookies.0.whitelisted_names.# = 0
default_cache_behavior.0.forwarded_values.0.headers.#                     = 0
default_cache_behavior.0.forwarded_values.0.query_string                  = false
default_cache_behavior.0.forwarded_values.0.query_string_cache_keys.#     = 0
default_cache_behavior.0.lambda_function_association.#                    = 0
default_cache_behavior.0.max_ttl                                          = 100
default_cache_behavior.0.min_ttl                                          = 100
default_cache_behavior.0.smooth_streaming                                 = true
default_cache_behavior.0.target_origin_id                                 = myCustomOrigin
default_cache_behavior.0.trusted_signers.#                                = 0
default_cache_behavior.0.viewer_protocol_policy                           = allow-all
default_root_object                                                       =
domain_name                                                               = dot6h04nf0cmx.cloudfront.net
enabled                                                                   = true
etag                                                                      = E33ZADXZHBHVXT
hosted_zone_id                                                            = Z2FDTNDATAQYW2
http_version                                                              = http2
in_progress_validation_batches                                            = 0
is_ipv6_enabled                                                           = false
last_modified_time                                                        = 2019-02-26 02:22:40.558 +0000 UTC
logging_config.#                                                          = 0
ordered_cache_behavior.#                                                  = 2
ordered_cache_behavior.0.allowed_methods.#                                = 7
ordered_cache_behavior.0.allowed_methods.1012961568                       = POST
ordered_cache_behavior.0.allowed_methods.1040875975                       = GET
ordered_cache_behavior.0.allowed_methods.1445840968                       = HEAD
ordered_cache_behavior.0.allowed_methods.1741119464                       = PATCH
ordered_cache_behavior.0.allowed_methods.348445828                        = DELETE
ordered_cache_behavior.0.allowed_methods.3982006612                       = OPTIONS
ordered_cache_behavior.0.allowed_methods.4024585617                       = PUT
ordered_cache_behavior.0.cached_methods.#                                 = 2
ordered_cache_behavior.0.cached_methods.1040875975                        = GET
ordered_cache_behavior.0.cached_methods.1445840968                        = HEAD
ordered_cache_behavior.0.compress                                         = false
ordered_cache_behavior.0.default_ttl                                      = 50
ordered_cache_behavior.0.field_level_encryption_id                        =
ordered_cache_behavior.0.forwarded_values.#                               = 1
ordered_cache_behavior.0.forwarded_values.0.cookies.#                     = 1
ordered_cache_behavior.0.forwarded_values.0.cookies.0.forward             = none
ordered_cache_behavior.0.forwarded_values.0.cookies.0.whitelisted_names.# = 0
ordered_cache_behavior.0.forwarded_values.0.headers.#                     = 0
ordered_cache_behavior.0.forwarded_values.0.query_string                  = true
ordered_cache_behavior.0.forwarded_values.0.query_string_cache_keys.#     = 0
ordered_cache_behavior.0.lambda_function_association.#                    = 0
ordered_cache_behavior.0.max_ttl                                          = 50
ordered_cache_behavior.0.min_ttl                                          = 50
ordered_cache_behavior.0.path_pattern                                     = images1/*.jpg
ordered_cache_behavior.0.smooth_streaming                                 = false
ordered_cache_behavior.0.target_origin_id                                 = myCustomOrigin
ordered_cache_behavior.0.trusted_signers.#                                = 0
ordered_cache_behavior.0.viewer_protocol_policy                           = allow-all
ordered_cache_behavior.1.allowed_methods.#                                = 7
ordered_cache_behavior.1.allowed_methods.1012961568                       = POST
ordered_cache_behavior.1.allowed_methods.1040875975                       = GET
ordered_cache_behavior.1.allowed_methods.1445840968                       = HEAD
ordered_cache_behavior.1.allowed_methods.1741119464                       = PATCH
ordered_cache_behavior.1.allowed_methods.348445828                        = DELETE
ordered_cache_behavior.1.allowed_methods.3982006612                       = OPTIONS
ordered_cache_behavior.1.allowed_methods.4024585617                       = PUT
ordered_cache_behavior.1.cached_methods.#                                 = 2
ordered_cache_behavior.1.cached_methods.1040875975                        = GET
ordered_cache_behavior.1.cached_methods.1445840968                        = HEAD
ordered_cache_behavior.1.compress                                         = false
ordered_cache_behavior.1.default_ttl                                      = 51
ordered_cache_behavior.1.field_level_encryption_id                        =
ordered_cache_behavior.1.forwarded_values.#                               = 1
ordered_cache_behavior.1.forwarded_values.0.cookies.#                     = 1
ordered_cache_behavior.1.forwarded_values.0.cookies.0.forward             = none
ordered_cache_behavior.1.forwarded_values.0.cookies.0.whitelisted_names.# = 0
ordered_cache_behavior.1.forwarded_values.0.headers.#                     = 0
ordered_cache_behavior.1.forwarded_values.0.query_string                  = true
ordered_cache_behavior.1.forwarded_values.0.query_string_cache_keys.#     = 0
ordered_cache_behavior.1.lambda_function_association.#                    = 0
ordered_cache_behavior.1.max_ttl                                          = 51
ordered_cache_behavior.1.min_ttl                                          = 51
ordered_cache_behavior.1.path_pattern                                     = images2/*.jpg
ordered_cache_behavior.1.smooth_streaming                                 = false
ordered_cache_behavior.1.target_origin_id                                 = myCustomOrigin
ordered_cache_behavior.1.trusted_signers.#                                = 0
ordered_cache_behavior.1.viewer_protocol_policy                           = allow-all
origin.#                                                                  = 1
origin.1857972443.custom_header.#                                         = 0
origin.1857972443.custom_origin_config.#                                  = 1
origin.1857972443.custom_origin_config.0.http_port                        = 80
origin.1857972443.custom_origin_config.0.https_port                       = 443
origin.1857972443.custom_origin_config.0.origin_keepalive_timeout         = 5
origin.1857972443.custom_origin_config.0.origin_protocol_policy           = http-only
origin.1857972443.custom_origin_config.0.origin_read_timeout              = 30
origin.1857972443.custom_origin_config.0.origin_ssl_protocols.#           = 2
origin.1857972443.custom_origin_config.0.origin_ssl_protocols.1162609714  = TLSv1
origin.1857972443.custom_origin_config.0.origin_ssl_protocols.2159350162  = SSLv3
origin.1857972443.domain_name                                             = www.example.com
origin.1857972443.origin_id                                               = myCustomOrigin
origin.1857972443.origin_path                                             =
origin.1857972443.s3_origin_config.#                                      = 0
price_class                                                               = PriceClass_All
restrictions.#                                                            = 1
restrictions.0.geo_restriction.#                                          = 1
restrictions.0.geo_restriction.0.locations.#                              = 4
restrictions.0.geo_restriction.0.locations.3034033770                     = DE
restrictions.0.geo_restriction.0.locations.3047936762                     = US
restrictions.0.geo_restriction.0.locations.3589570027                     = CA
restrictions.0.geo_restriction.0.locations.4191192820                     = GB
restrictions.0.geo_restriction.0.restriction_type                         = whitelist
retain_on_delete                                                          = false
status                                                                    = Deployed
tags.%                                                                    = 0
viewer_certificate.#                                                      = 1
viewer_certificate.0.acm_certificate_arn                                  =
viewer_certificate.0.cloudfront_default_certificate                       = true
viewer_certificate.0.iam_certificate_id                                   =
viewer_certificate.0.minimum_protocol_version                             = TLSv1
viewer_certificate.0.ssl_support_method                                   =
web_acl_id                                                                =
```

Output from acceptance testing:

```
--- PASS: TestAccAWSCloudFrontDistribution_Origin_EmptyOriginID (1.04s)
--- PASS: TestAccAWSCloudFrontDistribution_Origin_EmptyDomainName (1.12s)
--- PASS: TestAccAWSCloudFrontDistribution_orderedCacheBehavior (1082.43s)
--- PASS: TestAccAWSCloudFrontDistribution_HTTP11Config (1082.47s)
--- PASS: TestAccAWSCloudFrontDistribution_noCustomErrorResponseConfig (1083.16s)
--- PASS: TestAccAWSCloudFrontDistribution_noOptionalItemsConfig (1083.56s)
--- PASS: TestAccAWSCloudFrontDistribution_S3OriginWithTags (1084.20s)
--- PASS: TestAccAWSCloudFrontDistribution_IsIPV6EnabledConfig (1089.11s)
--- PASS: TestAccAWSCloudFrontDistribution_S3Origin (1090.38s)
--- PASS: TestAccAWSCloudFrontDistribution_customOrigin (1092.54s)
--- PASS: TestAccAWSCloudFrontDistribution_multiOrigin (1093.67s)
```
@bflad bflad added bug Addresses a defect in current functionality. service/cloudfront Issues and PRs that pertain to the cloudfront service. labels Feb 26, 2019
@bflad bflad added this to the v2.0.0 milestone Feb 26, 2019
@bflad bflad requested a review from a team February 26, 2019 16:15
@ghost ghost added size/XL Managed by automation to categorize the size of a PR. tests PRs: expanded test coverage. Issues: expanded coverage, enhancements to test infrastructure. labels Feb 26, 2019
Copy link
Contributor Author

@bflad bflad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Annotations now provided.

cb.AllowedMethods.CachedMethods = expandCachedMethodsDeprecated(v.([]interface{}))
}
if v, ok := m["path_pattern"]; ok {
cb.PathPattern = aws.String(v.(string))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if v, ok := d.GetOk("comment"); ok {
distributionConfig.Comment = aws.String(v.(string))
} else {
distributionConfig.Comment = aws.String("")
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The if/else logic here was extraneous as d.Get("ATTR").(string) will return the zero value (""), so moved above into DistributionConfig struct creation above.

m["min_ttl"] = int(*cb.MinTTL)
func flattenCloudFrontDefaultCacheBehavior(dcb *cloudfront.DefaultCacheBehavior) map[string]interface{} {
m := map[string]interface{}{
"compress": aws.BoolValue(dcb.Compress),
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using AWS Go SDK functions for nil deference safety.

if cb.AllowedMethods.CachedMethods != nil {
m["cached_methods"] = flattenCachedMethodsDeprecated(cb.AllowedMethods.CachedMethods)
}
if cb.PathPattern != nil {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same note about PathPattern here.

@@ -763,15 +606,15 @@ func originHash(v interface{}) int {
buf.WriteString(fmt.Sprintf("%d-", customHeadersHash(v.(*schema.Set))))
}
if v, ok := m["custom_origin_config"]; ok {
if s := v.(*schema.Set).List(); len(s) > 0 {
if s := v.([]interface{}); len(s) > 0 && s[0] != nil {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nil checks specifically added here as I was able to coerce a panic during testing.

@@ -585,9 +574,6 @@ func TestCloudFrontStructure_flattenOrigin(t *testing.T) {
if out["origin_path"] != "/" {
t.Fatalf("Expected out[origin_path] to be /, got %v", out["origin_path"])
}
if !out["custom_origin_config"].(*schema.Set).Equal(in["custom_origin_config"].(*schema.Set)) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

custom_origin_config itself contains the origin_ssl_protocols set, which are not stable to test in this manner.

@@ -860,8 +836,8 @@ func TestCloudFrontStructure_expandGeoRestriction_whitelist(t *testing.T) {
if *gr.Quantity != 3 {
t.Fatalf("Expected Quantity to be 3, got %v", *gr.Quantity)
}
if !reflect.DeepEqual(gr.Items, aws.StringSlice([]string{"CA", "GB", "US"})) {
t.Fatalf("Expected Items be [CA, GB, US], got %v", gr.Items)
if !reflect.DeepEqual(aws.StringValueSlice(gr.Items), []string{"GB", "US", "CA"}) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The previous resource logic sorted the slice, which is no longer the case for TypeSet usage.

@@ -67,14 +67,12 @@ func resourceAwsCloudFrontDistribution() *schema.Resource {
"forwarded_values": {
Type: schema.TypeSet,
Required: true,
Set: forwardedValuesHash,
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missed during conversion of Deprecated to Removed in previous pull request.

@@ -75,29 +75,6 @@ func testSweepCloudFrontDistributions(region string) error {
return nil
}

func TestAccAWSCloudFrontDistribution_importBasic(t *testing.T) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved import state verification to all acceptance tests to ensure we are consistently reading into the Terraform state from all API responses.

@bflad bflad merged commit d2759ea into master Feb 27, 2019
@bflad bflad deleted the td-aws_cloudfront_distribution-typelist branch February 27, 2019 19:35
bflad added a commit that referenced this pull request Feb 27, 2019
@ghost
Copy link

ghost commented Mar 31, 2020

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.

If you feel this issue should be reopened, we encourage creating a new issue linking back to this one for added context. Thanks!

@ghost ghost locked and limited conversation to collaborators Mar 31, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.