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

Adding https_config options to the alicloud_cdn_domain resource #605

Merged
merged 2 commits into from
Jan 10, 2019

Conversation

chanind
Copy link
Contributor

@chanind chanind commented Dec 27, 2018

This PR adds the ability to set a SSL certificate and enable HTTPs on the alicloud_cdn_domain resource. Previously it was not possible to enable SSL through terraform.

This is my first time both writing Go and working on a terraform provider, so apologies if the code is strange!

Fixes https://github.com/terraform-providers/terraform-provider-alicloud/issues/591

@xiaozhu36
Copy link
Member

HI @chanind Thanks for your contribution. Can you add a testcase for this PR?

@ghost ghost added size/L and removed size/M labels Dec 31, 2018
@chanind
Copy link
Contributor Author

chanind commented Dec 31, 2018

@xiaozhu36 added a test case in d41d271 and fixed up some minor issues I found in the process

@@ -164,6 +164,32 @@ func resourceAlicloudCdnDomain() *schema.Resource {
MaxItems: 1,
},

"https_config": &schema.Schema{
Copy link
Member

Choose a reason for hiding this comment

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

I think certificate_config will be better.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

no problem, I'll change that

if d.IsNewResource() {
err := WaitForDomainStatus(d.Id(), Online, 360, meta)
if err != nil {
return fmt.Errorf("Timeout when Cdn Domain Online")
Copy link
Member

Choose a reason for hiding this comment

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

Please print err details before return err.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This behavior was copied from https://github.com/terraform-providers/terraform-provider-alicloud/blob/master/alicloud/resource_alicloud_cdn_domain.go#L295. Should that part of the provider also be changed?

Copy link
Member

Choose a reason for hiding this comment

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

yes

"server_certificate": domain.ServerCertificate,
"server_certificate_status": domain.ServerCertificateStatus,
}
if oldConfig != nil && oldConfig.Len() > 0 {
Copy link
Member

Choose a reason for hiding this comment

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

I think condition if oldConfig != nil && oldConfig.Len() > 0 is redundant. private_key is sensitive and it is no need to return.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I didn't want to put private_key into the state, but I find that if I don't write it then terraform always says it changed. Is there a way to not write private_key but also not have terraform keep thinking there are new changes?

Copy link
Member

Choose a reason for hiding this comment

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

you can set private_key "Compute: true"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I tried setting Compute: true, but the same thing happens. If I don't put private_key into the state, then every run terraform thinks the private key has changed and tries to recreate the certificate. This is what is output every run if I add Compute: true and don't put private_key in the state:

screen shot 2019-01-04 at 11 23 49

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@xiaozhu36 maybe it's easier if you change this PR so it works the way you suggest? You should be able to push changes. When I added Compute: true and removed private_key from the state terraform thinks the resource has changed every run. If I'm doing something wrong it's probably easier for you to push a fix since you're more experienced than I am.

Copy link
Member

Choose a reason for hiding this comment

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

OK

})
if err != nil {
return err
}
Copy link
Member

Choose a reason for hiding this comment

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

Line 788 needs set partial after ser domain config.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I used authConfigUpdate as a template, from here: https://github.com/terraform-providers/terraform-provider-alicloud/blob/master/alicloud/resource_alicloud_cdn_domain.go#L663. There is a d.SetPartial("https_config") on line 792. Why does one also need to be on line 788? It seems like in authConfigUpdate there is only 1 SetPartial. Sorry if this is a dumb question, I don't fully understand what SetPartial does.

Copy link
Member

Choose a reason for hiding this comment

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

When one config has been changed successfully by invoking API, SetPartial will write down it to state even if the next change failed.

Copy link
Contributor Author

@chanind chanind Jan 4, 2019

Choose a reason for hiding this comment

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

Ok, I added it to line 788 in c14ad1c, but I'm still confused why it's only needed on line 788 and not for the other config blocks of the CDN? For example, why is it not needed here: https://github.com/terraform-providers/terraform-provider-alicloud/blob/master/alicloud/resource_alicloud_cdn_domain.go#L676 and here: https://github.com/terraform-providers/terraform-provider-alicloud/blob/master/alicloud/resource_alicloud_cdn_domain.go#L643

if okServerCertificate {
err := WaitForHttpsServerCertificate(client, d.Id(), args.ServerCertificate, 360)
if err != nil {
return fmt.Errorf("Timeout waiting for Cdn server certificate")
Copy link
Member

Choose a reason for hiding this comment

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

Please print error details when returning error.

if okServerCertificate {
err := WaitForHttpsServerCertificate(client, d.Id(), args.ServerCertificate, 360)
if err != nil {
return fmt.Errorf("Timeout waiting for Cdn server certificate")
Copy link
Member

Choose a reason for hiding this comment

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

Please print error details when returning error.

resource.TestCheckResourceAttr("alicloud_cdn_domain.domain", "https_config.#", "1"),
resource.TestCheckResourceAttr("alicloud_cdn_domain.domain", "https_config.3358202545.server_certificate_status", "on"),
resource.TestCheckResourceAttr("alicloud_cdn_domain.domain", "https_config.3358202545.server_certificate", strings.Replace(testServerCertificate, `\n`, "\n", -1)),
resource.TestCheckResourceAttr("alicloud_cdn_domain.domain", "https_config.3358202545.private_key", strings.Replace(testPrivateKey, `\n`, "\n", -1)),
Copy link
Member

Choose a reason for hiding this comment

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

I think the hash code should not occur in testcase because of it always changes. If you want to check server_certificate_status and other config, you can consider to modify https_config type to TypeList.

Copy link
Contributor Author

@chanind chanind Jan 3, 2019

Choose a reason for hiding this comment

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

I saw this pattern in the AWS provider, ex https://github.com/terraform-providers/terraform-provider-aws/blob/5a062fcdc5b24d82017aa15bc561fac1f152a2c6/aws/resource_aws_elb_test.go#L132. I agree it's not ideal to include the hash code in the test, but it seems like we shouldn't need to change the provider structure just to avoid dealing with hash codes in the state. The other params of alicloud_cdn_domain all use schema.TypeSet, ex auth_config, refer_config, page_404_config, and parameter_filter_config so I wanted to be consistent. Is there another helper I can use to write assertions that work on schema.TypeSet values, or is it not possible to test schema.TypeSet types?

Copy link
Member

Choose a reason for hiding this comment

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

If you can ensure same config has same hash code, the testcase can be kept. Can you run the testcase and upload the result when next submitting?

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 hash shouldn't change unless we change the values contained in the config. Here is the output of the test:

=== RUN   TestAccAlicloudCdnDomain_https
2019/01/04 11:32:07 [WARN] Test: Executing step 0
2019/01/04 11:32:07 [INFO] terraform: building graph: GraphTypeValidate
2019/01/04 11:32:07 [WARN] terraform: shadow graph disabled
2019/01/04 11:32:07 [INFO] terraform: building graph: GraphTypeRefresh
2019/01/04 11:32:07 [WARN] terraform: shadow graph disabled
2019/01/04 11:32:07 [INFO] terraform: building graph: GraphTypePlan
2019/01/04 11:32:07 [WARN] terraform: shadow graph disabled
2019/01/04 11:32:07 [WARN] Test: Step plan: DIFF:

CREATE: alicloud_cdn_domain.domain
  cdn_type:                                                "" => "web"
  certificate_config.#:                                    "0" => "1"
  certificate_config.3358202545.private_key:               "<sensitive>" => "<sensitive>" (attribute changed)
  certificate_config.3358202545.server_certificate:        "<sensitive>" => "<sensitive>" (attribute changed)
  certificate_config.3358202545.server_certificate_status: "" => "on"
  domain_name:                                             "" => "tf-testacc6068554464636384429.xiaozhu.com"
  scope:                                                   "" => "overseas"
  source_port:                                             "" => "80"
  source_type:                                             "" => "oss"
  sources.#:                                               "0" => "1"
  sources.21942838:                                        "" => "terraformtest.aliyuncs.com"

STATE:

<no state>
2019/01/04 11:32:07 [INFO] terraform: building graph: GraphTypeApply
2019/01/04 11:32:07 [WARN] terraform: shadow graph disabled
2019/01/04 11:38:48 [WARN] Domain id "tf-testacc6068554464636384429.xiaozhu.com"
2019/01/04 11:38:48 [INFO] terraform: building graph: GraphTypePlan
2019/01/04 11:38:48 [WARN] terraform: shadow graph disabled
2019/01/04 11:38:48 [INFO] terraform: building graph: GraphTypeRefresh
2019/01/04 11:38:48 [WARN] terraform: shadow graph disabled
2019/01/04 11:38:51 [INFO] terraform: building graph: GraphTypePlan
2019/01/04 11:38:51 [WARN] terraform: shadow graph disabled
2019/01/04 11:38:51 [WARN] Test: Running ID-only refresh check on tf-testacc6068554464636384429.xiaozhu.com
2019/01/04 11:38:51 [WARN] Test: Executing destroy step
2019/01/04 11:38:51 [INFO] terraform: building graph: GraphTypeValidate
2019/01/04 11:38:51 [WARN] terraform: shadow graph disabled
2019/01/04 11:38:51 [INFO] terraform: building graph: GraphTypeRefresh
2019/01/04 11:38:51 [WARN] terraform: shadow graph disabled
2019/01/04 11:38:55 [INFO] terraform: building graph: GraphTypePlanDestroy
2019/01/04 11:38:55 [WARN] terraform: shadow graph disabled
2019/01/04 11:38:55 [WARN] Test: Step plan: DIFF:

DESTROY: alicloud_cdn_domain.domain

STATE:

alicloud_cdn_domain.domain:
  ID = tf-testacc6068554464636384429.xiaozhu.com
  block_ips.# = 0
  cache_config.# = 0
  cdn_type = web
  certificate_config.# = 1
  certificate_config.3358202545.private_key = -----BEGIN PRIVATE KEY-----
MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQDOdY9ITNHamP4B
3neS4bEm00oV5sNkqoNfGrwaR7qfwvGM76VXXb0VHnROeInXAn3QlYaFhLXDRVyJ
CqVg6SJhbaL6LqXTXQtl6ARxAuNqK/WQPsFbGgoofkkbgd6/sjc1x4fq5lGtBS3o
o/8dIFKL5s51LJO1DDM8CS2cJrsovCwrokyJUM0PUU3WmKNreDrhlZHUIic7GIkU
TTzqgirWL2HBAS2pSxTnFZ9GhvyPRZ9D963PHyvQRB2qGEbp5rrFAnQnCqYrBxym
HbZnd2YM/mfjwZIwEbbnzupDl0qL+ru2sy0MWYGSZnmoDZKkOP0fvW+BkOnK49D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neHY2syNb3EqPNyZEVYQKBgGeC4KiyTpW+SqmkDRU/
/FxIAlZE2vWmtJptAUkmLEVoBi0/GvJoYYJR4Jhj4gS9tJcrI860X0j05NZHvIX8
UJ/vZZeiFRiatXYUtKbD/ngoOXTF92ew2J3eCwNHH5OKwEO3aejaYwD9m0QM4kTl
VLWIf79+G3NrxIeqPnqv+l3J
-----END PRIVATE KEY-----
  certificate_config.3358202545.server_certificate = -----BEGIN CERTIFICATE-----
MIICrDCCAZQCCQDApyXUTYDE+DANBgkqhkiG9w0BAQsFADAYMRYwFAYDVQQDDA0q
LnhpYW96aHUuY29tMB4XDTE4MTIzMTEwMDY1OVoXDTE5MTIzMTEwMDY1OVowGDEW
MBQGA1UEAwwNKi54aWFvemh1LmNvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCC
AQoCggEBAM51j0hM0dqY/gHed5LhsSbTShXmw2Sqg18avBpHup/C8YzvpVddvRUe
dE54idcCfdCVhoWEtcNFXIkKpWDpImFtovoupdNdC2XoBHEC42or9ZA+wVsaCih+
SRuB3r+yNzXHh+rmUa0FLeij/x0gUovmznUsk7UMMzwJLZwmuyi8LCuiTIlQzQ9R
TdaYo2t4OuGVkdQiJzsYiRRNPOqCKtYvYcEBLalLFOcVn0aG/I9Fn0P3rc8fK9BE
HaoYRunmusUCdCcKpisHHKYdtmd3Zgz+Z+PBkjARtufO6kOXSov6u7azLQxZgZJm
eagNkqQ4/R+9b4GQ6crj0Pi655QWZVECAwEAATANBgkqhkiG9w0BAQsFAAOCAQEA
JAWcQb7942jWDWjFqW5C4eyJBuJxK8dsTsYpOa0ccpp/A2cVCTNMzV/sMCGROy2B
uhrTMG4q3QawFwV+K4nQX8yJUJp57zyUfdit+yOD4hDzPyF5MOlOwzdqeg9Y9ODL
Sc2O6J3tFsx2332Hb7RXFlYodEk1uFezrj4YLVrAgk1QojaBHpuFiA/O3eCmErjW
c88bcil60qMvlhBhCWaZzivji6oc3y/6qWRZ3apxp9/6sjOvlm5Q+wwoLHXaU+L6
w7TZptw6upuSrAS+N4Rwqgn5TfPvbGkdRG0X0TDzE1+F+w377kE71nV8lmi8F786
bqloD1gWJER071WRz1coHQ==
-----END CERTIFICATE-----

  certificate_config.3358202545.server_certificate_status = on
  domain_name = tf-testacc6068554464636384429.xiaozhu.com
  http_header_config.# = 0
  optimize_enable = 
  page_compress_enable = 
  range_enable = 
  scope = overseas
  source_port = 80
  source_type = oss
  sources.# = 1
  sources.21942838 = terraformtest.aliyuncs.com
  video_seek_enable =
2019/01/04 11:38:55 [INFO] terraform: building graph: GraphTypeApply
2019/01/04 11:38:55 [WARN] terraform: shadow graph disabled
2019/01/04 11:38:59 [INFO] terraform: building graph: GraphTypePlanDestroy
2019/01/04 11:38:59 [WARN] terraform: shadow graph disabled
2019/01/04 11:38:59 [INFO] terraform: building graph: GraphTypeRefresh
2019/01/04 11:38:59 [WARN] terraform: shadow graph disabled
2019/01/04 11:38:59 [INFO] terraform: building graph: GraphTypePlanDestroy
2019/01/04 11:38:59 [WARN] terraform: shadow graph disabled
--- PASS: TestAccAlicloudCdnDomain_https (412.07s)
PASS
ok  	github.com/terraform-providers/terraform-provider-alicloud/alicloud	412.119s

Copy link
Member

Choose a reason for hiding this comment

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

OK. Please check other comments.

* `cache_config` - (Optional, Type: set) Cache config of the accelerated domain. It's a set and each item's `cache_content` can not be repeated.
* `cache_type` - (Required) Cache type of the cache config. Valid values are `suffix` and `path`.
* `cache_content` - (Required) Cache content of the cache config. It's value is a path string when the `cache_type` is `path`. When the `cache_type` is `suffix`, it's value is a string which contains multiple file suffixes separated by commas.
* `cache_content` - (Required) Cache content of the cache config. It's value is a path string when the `cache_type` is `path`. When the `cache_type` is `suffix`, it's value is a string which contains multiple file suffixes separated by commas.
* `ttl` - (Required, Type: int) Cache time of the cache config.
* `weight` - (Optional, Type: int) Weight of the cache config. This parameter's value is between 1 and 99. Default value is `1`. The higher the value, the higher the priority.

Copy link
Member

Choose a reason for hiding this comment

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

Can you improve this docs by using block to arrange several configs?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm sorry I don't understand, what does it mean to use block to arrange configs? Is there an example in another part of the docs I can use as a reference? Sorry, I'm new to this

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok, I added the block labels in c14ad1c

"server_certificate": domain.ServerCertificate,
"server_certificate_status": domain.ServerCertificateStatus,
}
if oldConfig != nil && oldConfig.Len() > 0 {
Copy link
Member

Choose a reason for hiding this comment

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

OK


val := newConfig.List()[0].(map[string]interface{})
d.SetPartial("certificate_config")
args.ServerCertificateStatus = val["server_certificate_status"].(string)
Copy link
Member

Choose a reason for hiding this comment

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

Line 793 should be removed to line 823 that SetDomainServerCertificate success.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done in e038fe4

Copy link
Member

Choose a reason for hiding this comment

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

I think line 797 should be removed.

resource.TestCheckResourceAttr("alicloud_cdn_domain.domain", "certificate_config.#", "1"),
resource.TestCheckResourceAttr("alicloud_cdn_domain.domain", "certificate_config.3358202545.server_certificate_status", "on"),
resource.TestCheckResourceAttr("alicloud_cdn_domain.domain", "certificate_config.3358202545.server_certificate", strings.Replace(testServerCertificate, `\n`, "\n", -1)),
resource.TestCheckResourceAttr("alicloud_cdn_domain.domain", "certificate_config.3358202545.private_key", strings.Replace(testPrivateKey, `\n`, "\n", -1)),
Copy link
Member

Choose a reason for hiding this comment

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

Can this test case pass? Can you submit the results? I don't think hard cord hash code in the testcase is a good solution.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@xiaozhu36 I put this test output in a previous comment, but pasting here too:

=== RUN   TestAccAlicloudCdnDomain_https
2019/01/04 11:32:07 [WARN] Test: Executing step 0
2019/01/04 11:32:07 [INFO] terraform: building graph: GraphTypeValidate
2019/01/04 11:32:07 [WARN] terraform: shadow graph disabled
2019/01/04 11:32:07 [INFO] terraform: building graph: GraphTypeRefresh
2019/01/04 11:32:07 [WARN] terraform: shadow graph disabled
2019/01/04 11:32:07 [INFO] terraform: building graph: GraphTypePlan
2019/01/04 11:32:07 [WARN] terraform: shadow graph disabled
2019/01/04 11:32:07 [WARN] Test: Step plan: DIFF:

CREATE: alicloud_cdn_domain.domain
  cdn_type:                                                "" => "web"
  certificate_config.#:                                    "0" => "1"
  certificate_config.3358202545.private_key:               "<sensitive>" => "<sensitive>" (attribute changed)
  certificate_config.3358202545.server_certificate:        "<sensitive>" => "<sensitive>" (attribute changed)
  certificate_config.3358202545.server_certificate_status: "" => "on"
  domain_name:                                             "" => "tf-testacc6068554464636384429.xiaozhu.com"
  scope:                                                   "" => "overseas"
  source_port:                                             "" => "80"
  source_type:                                             "" => "oss"
  sources.#:                                               "0" => "1"
  sources.21942838:                                        "" => "terraformtest.aliyuncs.com"

STATE:

<no state>
2019/01/04 11:32:07 [INFO] terraform: building graph: GraphTypeApply
2019/01/04 11:32:07 [WARN] terraform: shadow graph disabled
2019/01/04 11:38:48 [WARN] Domain id "tf-testacc6068554464636384429.xiaozhu.com"
2019/01/04 11:38:48 [INFO] terraform: building graph: GraphTypePlan
2019/01/04 11:38:48 [WARN] terraform: shadow graph disabled
2019/01/04 11:38:48 [INFO] terraform: building graph: GraphTypeRefresh
2019/01/04 11:38:48 [WARN] terraform: shadow graph disabled
2019/01/04 11:38:51 [INFO] terraform: building graph: GraphTypePlan
2019/01/04 11:38:51 [WARN] terraform: shadow graph disabled
2019/01/04 11:38:51 [WARN] Test: Running ID-only refresh check on tf-testacc6068554464636384429.xiaozhu.com
2019/01/04 11:38:51 [WARN] Test: Executing destroy step
2019/01/04 11:38:51 [INFO] terraform: building graph: GraphTypeValidate
2019/01/04 11:38:51 [WARN] terraform: shadow graph disabled
2019/01/04 11:38:51 [INFO] terraform: building graph: GraphTypeRefresh
2019/01/04 11:38:51 [WARN] terraform: shadow graph disabled
2019/01/04 11:38:55 [INFO] terraform: building graph: GraphTypePlanDestroy
2019/01/04 11:38:55 [WARN] terraform: shadow graph disabled
2019/01/04 11:38:55 [WARN] Test: Step plan: DIFF:

DESTROY: alicloud_cdn_domain.domain

STATE:

alicloud_cdn_domain.domain:
  ID = tf-testacc6068554464636384429.xiaozhu.com
  block_ips.# = 0
  cache_config.# = 0
  cdn_type = web
  certificate_config.# = 1
  certificate_config.3358202545.private_key = -----BEGIN PRIVATE KEY-----
MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQDOdY9ITNHamP4B
3neS4bEm00oV5sNkqoNfGrwaR7qfwvGM76VXXb0VHnROeInXAn3QlYaFhLXDRVyJ
CqVg6SJhbaL6LqXTXQtl6ARxAuNqK/WQPsFbGgoofkkbgd6/sjc1x4fq5lGtBS3o
o/8dIFKL5s51LJO1DDM8CS2cJrsovCwrokyJUM0PUU3WmKNreDrhlZHUIic7GIkU
TTzqgirWL2HBAS2pSxTnFZ9GhvyPRZ9D963PHyvQRB2qGEbp5rrFAnQnCqYrBxym
HbZnd2YM/mfjwZIwEbbnzupDl0qL+ru2sy0MWYGSZnmoDZKkOP0fvW+BkOnK49D4
uueUFmVRAgMBAAECggEAGFrP2zSMsN/JXwkSS/Zpwm28WJcPR6nBs49gzyzU/BGw
EvMWKxc4vewIxlT71axKkTeCVe/QzUc6YkQqPCNkVd/sEN093JAmTxAurfIsR5MF
9c0hXBDXT+2NzDvmvfBVCPgPtYsT6Xgp8T6fUp1Ef5JrmnD2v62/wX5Hrhr3ixdp
FoEJ92/FJN+Dt/Duri481+RYqUUbNqiZAuEMsny/hM+aijtpQgZK8FqnVfjIOo0l
p4TwfDoxtTwkj0QeJxelX/sNS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9w0BAQsFADAYMRYwFAYDVQQDDA0q
LnhpYW96aHUuY29tMB4XDTE4MTIzMTEwMDY1OVoXDTE5MTIzMTEwMDY1OVowGDEW
MBQGA1UEAwwNKi54aWFvemh1LmNvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCC
AQoCggEBAM51j0hM0dqY/gHed5LhsSbTShXmw2Sqg18avBpHup/C8YzvpVddvRUe
dE54idcCfdCVhoWEtcNFXIkKpWDpImFtovoupdNdC2XoBHEC42or9ZA+wVsaCih+
SRuB3r+yNzXHh+rmUa0FLeij/x0gUovmznUsk7UMMzwJLZwmuyi8LCuiTIlQzQ9R
TdaYo2t4OuGVkdQiJzsYiRRNPOqCKtYvYcEBLalLFOcVn0aG/I9Fn0P3rc8fK9BE
HaoYRunmusUCdCcKpisHHKYdtmd3Zgz+Z+PBkjARtufO6kOXSov6u7azLQxZgZJm
eagNkqQ4/R+9b4GQ6crj0Pi655QWZVECAwEAATANBgkqhkiG9w0BAQsFAAOCAQEA
JAWcQb7942jWDWjFqW5C4eyJBuJxK8dsTsYpOa0ccpp/A2cVCTNMzV/sMCGROy2B
uhrTMG4q3QawFwV+K4nQX8yJUJp57zyUfdit+yOD4hDzPyF5MOlOwzdqeg9Y9ODL
Sc2O6J3tFsx2332Hb7RXFlYodEk1uFezrj4YLVrAgk1QojaBHpuFiA/O3eCmErjW
c88bcil60qMvlhBhCWaZzivji6oc3y/6qWRZ3apxp9/6sjOvlm5Q+wwoLHXaU+L6
w7TZptw6upuSrAS+N4Rwqgn5TfPvbGkdRG0X0TDzE1+F+w377kE71nV8lmi8F786
bqloD1gWJER071WRz1coHQ==
-----END CERTIFICATE-----

  certificate_config.3358202545.server_certificate_status = on
  domain_name = tf-testacc6068554464636384429.xiaozhu.com
  http_header_config.# = 0
  optimize_enable = 
  page_compress_enable = 
  range_enable = 
  scope = overseas
  source_port = 80
  source_type = oss
  sources.# = 1
  sources.21942838 = terraformtest.aliyuncs.com
  video_seek_enable =
2019/01/04 11:38:55 [INFO] terraform: building graph: GraphTypeApply
2019/01/04 11:38:55 [WARN] terraform: shadow graph disabled
2019/01/04 11:38:59 [INFO] terraform: building graph: GraphTypePlanDestroy
2019/01/04 11:38:59 [WARN] terraform: shadow graph disabled
2019/01/04 11:38:59 [INFO] terraform: building graph: GraphTypeRefresh
2019/01/04 11:38:59 [WARN] terraform: shadow graph disabled
2019/01/04 11:38:59 [INFO] terraform: building graph: GraphTypePlanDestroy
2019/01/04 11:38:59 [WARN] terraform: shadow graph disabled
--- PASS: TestAccAlicloudCdnDomain_https (412.07s)
PASS
ok  	github.com/terraform-providers/terraform-provider-alicloud/alicloud	412.119s

@chanind
Copy link
Contributor Author

chanind commented Jan 8, 2019

@xiaozhu36 I updated the PR and changed to use TypeList instead of TypeSet like you suggested, so the test doesn't have a hash anymore. Here's the updated test results:

=== RUN   TestAccAlicloudCdnDomain_https
2019/01/08 14:14:20 [WARN] Test: Executing step 0
2019/01/08 14:14:20 [INFO] terraform: building graph: GraphTypeValidate
2019/01/08 14:14:20 [WARN] terraform: shadow graph disabled
2019/01/08 14:14:20 [INFO] terraform: building graph: GraphTypeRefresh
2019/01/08 14:14:20 [WARN] terraform: shadow graph disabled
2019/01/08 14:14:20 [INFO] terraform: building graph: GraphTypePlan
2019/01/08 14:14:20 [WARN] terraform: shadow graph disabled
2019/01/08 14:14:20 [WARN] Test: Step plan: DIFF:

CREATE: alicloud_cdn_domain.domain
  cdn_type:                                       "" => "web"
  certificate_config.#:                           "0" => "1"
  certificate_config.0.private_key:               "<sensitive>" => "<sensitive>" (attribute changed)
  certificate_config.0.server_certificate:        "<sensitive>" => "<sensitive>" (attribute changed)
  certificate_config.0.server_certificate_status: "" => "on"
  domain_name:                                    "" => "tf-testacc5760878342779004972.xiaozhu.com"
  scope:                                          "" => "overseas"
  source_port:                                    "" => "80"
  source_type:                                    "" => "oss"
  sources.#:                                      "0" => "1"
  sources.21942838:                               "" => "terraformtest.aliyuncs.com"

STATE:

<no state>
2019/01/08 14:14:20 [INFO] terraform: building graph: GraphTypeApply
2019/01/08 14:14:20 [WARN] terraform: shadow graph disabled
2019/01/08 14:21:05 [WARN] Domain id "tf-testacc5760878342779004972.xiaozhu.com"
2019/01/08 14:21:05 [INFO] terraform: building graph: GraphTypePlan
2019/01/08 14:21:05 [WARN] terraform: shadow graph disabled
2019/01/08 14:21:05 [INFO] terraform: building graph: GraphTypeRefresh
2019/01/08 14:21:05 [WARN] terraform: shadow graph disabled
2019/01/08 14:21:13 [INFO] terraform: building graph: GraphTypePlan
2019/01/08 14:21:13 [WARN] terraform: shadow graph disabled
2019/01/08 14:21:13 [WARN] Test: Running ID-only refresh check on tf-testacc5760878342779004972.xiaozhu.com
2019/01/08 14:21:13 [WARN] Test: Executing destroy step
2019/01/08 14:21:13 [INFO] terraform: building graph: GraphTypeValidate
2019/01/08 14:21:13 [WARN] terraform: shadow graph disabled
2019/01/08 14:21:13 [INFO] terraform: building graph: GraphTypeRefresh
2019/01/08 14:21:13 [WARN] terraform: shadow graph disabled
2019/01/08 14:21:19 [INFO] terraform: building graph: GraphTypePlanDestroy
2019/01/08 14:21:19 [WARN] terraform: shadow graph disabled
2019/01/08 14:21:19 [WARN] Test: Step plan: DIFF:

DESTROY: alicloud_cdn_domain.domain

STATE:

alicloud_cdn_domain.domain:
  ID = tf-testacc5760878342779004972.xiaozhu.com
  block_ips.# = 0
  cache_config.# = 0
  cdn_type = web
  certificate_config.# = 1
  certificate_config.0.private_key = -----BEGIN PRIVATE KEY-----
MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQDOdY9ITNHamP4B
3neS4bEm00oV5sNkqoNfGrwaR7qfwvGM76VXXb0VHnROeInXAn3QlYaFhLXDRVyJ
CqVg6SJhbaL6LqXTXQtl6ARxAuNqK/WQPsFbGgoofkkbgd6/sjc1x4fq5lGtBS3o
o/8dIFKL5s51LJO1DDM8CS2cJrsovCwrokyJUM0PUU3WmKNreDrhlZHUIic7GIkU
TTzqgirWL2H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VqEVXCO+2QL7wetPm+A7NdXzPoBJwpZ
JhdO93ho89Hcg2eSDgf/HazH8eLaGH32U9cW2rhpShDZOcGDfaiI5y+yM8s1Erki
z2h+hLOH4g8D8ry6ItE+RvneHY2syNb3EqPNyZEVYQKBgGeC4KiyTpW+SqmkDRU/
/FxIAlZE2vWmtJptAUkmLEVoBi0/GvJoYYJR4Jhj4gS9tJcrI860X0j05NZHvIX8
UJ/vZZeiFRiatXYUtKbD/ngoOXTF92ew2J3eCwNHH5OKwEO3aejaYwD9m0QM4kTl
VLWIf79+G3NrxIeqPnqv+l3J
-----END PRIVATE KEY-----
  certificate_config.0.server_certificate = -----BEGIN CERTIFICATE-----
MIICrDCCAZQCCQDApyXUTYDE+DANBgkqhkiG9w0BAQsFADAYMRYwFAYDVQQDDA0q
LnhpYW96aHUuY29tMB4XDTE4MTIzMTEwMDY1OVoXDTE5MTIzMTEwMDY1OVowGDEW
MBQGA1UEAwwNKi54aWFvemh1LmNvbTCCASIwDQYJKoZIhvcNAQEBBQADggEPADCC
AQoCggEBAM51j0hM0dqY/gHed5LhsSbTShXmw2Sqg18avBpHup/C8YzvpVddvRUe
dE54idcCfdCVhoWEtcNFXIkKpWDpImFtovoupdNdC2XoBHEC42or9ZA+wVsaCih+
SRuB3r+yNzXHh+rmUa0FLeij/x0gUovmznUsk7UMMzwJLZwmuyi8LCuiTIlQzQ9R
TdaYo2t4OuGVkdQiJzsYiRRNPOqCKtYvYcEBLalLFOcVn0aG/I9Fn0P3rc8fK9BE
HaoYRunmusUCdCcKpisHHKYdtmd3Zgz+Z+PBkjARtufO6kOXSov6u7azLQxZgZJm
eagNkqQ4/R+9b4GQ6crj0Pi655QWZVECAwEAATANBgkqhkiG9w0BAQsFAAOCAQEA
JAWcQb7942jWDWjFqW5C4eyJBuJxK8dsTsYpOa0ccpp/A2cVCTNMzV/sMCGROy2B
uhrTMG4q3QawFwV+K4nQX8yJUJp57zyUfdit+yOD4hDzPyF5MOlOwzdqeg9Y9ODL
Sc2O6J3tFsx2332Hb7RXFlYodEk1uFezrj4YLVrAgk1QojaBHpuFiA/O3eCmErjW
c88bcil60qMvlhBhCWaZzivji6oc3y/6qWRZ3apxp9/6sjOvlm5Q+wwoLHXaU+L6
w7TZptw6upuSrAS+N4Rwqgn5TfPvbGkdRG0X0TDzE1+F+w377kE71nV8lmi8F786
bqloD1gWJER071WRz1coHQ==
-----END CERTIFICATE-----

  certificate_config.0.server_certificate_status = on
  domain_name = tf-testacc5760878342779004972.xiaozhu.com
  http_header_config.# = 0
  optimize_enable = 
  page_compress_enable = 
  range_enable = 
  scope = overseas
  source_port = 80
  source_type = oss
  sources.# = 1
  sources.21942838 = terraformtest.aliyuncs.com
  video_seek_enable =
2019/01/08 14:21:19 [INFO] terraform: building graph: GraphTypeApply
2019/01/08 14:21:19 [WARN] terraform: shadow graph disabled
2019/01/08 14:21:24 [INFO] terraform: building graph: GraphTypePlanDestroy
2019/01/08 14:21:24 [WARN] terraform: shadow graph disabled
2019/01/08 14:21:24 [INFO] terraform: building graph: GraphTypeRefresh
2019/01/08 14:21:24 [WARN] terraform: shadow graph disabled
2019/01/08 14:21:24 [INFO] terraform: building graph: GraphTypePlanDestroy
2019/01/08 14:21:24 [WARN] terraform: shadow graph disabled
--- PASS: TestAccAlicloudCdnDomain_https (424.22s)
PASS
ok  	github.com/terraform-providers/terraform-provider-alicloud/alicloud	424.274s


val := newConfig.List()[0].(map[string]interface{})
d.SetPartial("certificate_config")
args.ServerCertificateStatus = val["server_certificate_status"].(string)
Copy link
Member

Choose a reason for hiding this comment

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

I think line 797 should be removed.

@xiaozhu36
Copy link
Member

Hi @chanind Can you rebase this PR before the next submitting?

@chanind
Copy link
Contributor Author

chanind commented Jan 9, 2019

@xiaozhu36 I deleted line 797 and rebased / squashed

* `ttl` - (Required, Type: int) Cache time of the cache config.
* `weight` - (Optional, Type: int) Weight of the cache config. This parameter's value is between 1 and 99. Default value is `1`. The higher the value, the higher the priority.
### Block parameter_filter_config
`parameter_filter_config` - (Optional, Type: set) Parameter filter config of the accelerated domain. It's a set and consists of at most one item.
Copy link
Member

Choose a reason for hiding this comment

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

Please add a blank line between line 98 and 99

* `hash_key_args` - (Optional, Type: list) Reserved parameters of `parameter_filter_config`. It's a list of string and consists of at most 10 items.

### Block page_404_config
`page_404_config` - (Optional, Type: set) Error Page config of the accelerated domain. It's a set and consists of at most one item.
Copy link
Member

Choose a reason for hiding this comment

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

Please add a blank line between line 103 and 104

* `custom_page_url` - (Optional) Custom page url of the error page. It must be the full path under the accelerated domain name. It's value must be `http://promotion.alicdn.com/help/oss/error.html` when `page_type` value is `charity` and It can not be set when `page_type` value is `default`.

### Block refer_config
`refer_config` - (Optional, Type: set) Refer anti-theft chain config of the accelerated domain. It's a set and consists of at most 1 item.
Copy link
Member

Choose a reason for hiding this comment

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

Please add a blank line between line 108 and 109


### Block auth_config
`auth_config` - (Optional, Type: set) Auth config of the accelerated domain. It's a set and consist of at most 1 item.
* `auth_type` - (Optional) Auth type of the auth config. Valid values are `no_auth`, `type_a`, `type_b` and `type_c`. Default value is `no_auth`.
Copy link
Member

Choose a reason for hiding this comment

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

Please add a blank line between line 114 and 115

* `timeout` - (Optional, Type: int) Authentication cache time of the auth config. Default value is `1800`. It's value is valid only when the `auth_type` is `type_b` or `type_c`.

### Block certificate_config
`certificate_config` - (Optional, Type: set) Certificate config of the accelerated domain. It's a set and consist of at most 1 item.
Copy link
Member

Choose a reason for hiding this comment

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

Please add a blank line between line 121 and 122

* `private_key` - (Optional) The SSL private key. This is required if `server_certificate_status` is `on`

### Block http_header_config
`http_header_config` - (Optional, Type: set) Http header config of the accelerated domain. It's a set and consist of at most 8 items. The `header_key` for each item can not be repeated.
Copy link
Member

Choose a reason for hiding this comment

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

Please add a blank line between line 127 and128

* `header_value` - (Required) Header value of the http header.

### Block cache_config
`cache_config` - (Optional, Type: set) Cache config of the accelerated domain. It's a set and each item's `cache_content` can not be repeated.
Copy link
Member

Choose a reason for hiding this comment

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

Please add a blank line between line 132 and 133

@chanind
Copy link
Contributor Author

chanind commented Jan 9, 2019

@xiaozhu36 blank lines have been added in bbe7514

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants