* Use certificate name as primary identifier instead of ID
When the certificate type is lets_encrypt, the certificate ID will change when
it's renewed, so we have to rely on the certificate name as the primary
identifier instead.
* Support running LB and cert tests in parallel
* Add state migration for Certificate resource
* Add state migration for LoadBalancer resource
* Use resource.ParallelTest for tests.
* Use a v0.12-style StateUpgrader.
* loadbalancer: Fix panic in buildLoadBalancerRequest
* Add fallback to flattenForwardingRules to prevent error state when a hardcoded UUID is used.
* Fix typo in findCertificateByName.
* Deprecate forwarding_rule.certificate_id in favor of forwarding_rule.certificate_name
* Use a v0.12-style StateUpgrader for load balancer migration.
* Handle cert ID change in CDN resource.
* Clean up structure.
* Update documentation.
Co-authored-by: Steven Normore <snormore@digitalocean.com>
* Upgrade to terraform-plugin-sdk
After following the [guide](https://www.terraform.io/docs/extend/plugin-sdk.html#using-tf-sdk-migrator)
Check
```
▶ GO111MODULE=on tf-sdk-migrator check
Checking Go runtime version ...
Go version 1.12.10: OK.
Checking whether provider uses Go modules...
Go modules in use: OK.
Checking version of github.com/hashicorp/terraform-plugin-sdk to determine if provider was already migrated...
Checking version of github.com/hashicorp/terraform used in provider...
Terraform version 0.12.8: OK.
Checking whether provider uses deprecated SDK packages or identifiers...
No imports of deprecated SDK packages or identifiers: OK.
All constraints satisfied. Provider can be migrated to the new SDK.
```
Migrate
```
▶ GO111MODULE=on tf-sdk-migrator migrate
Checking Go runtime version ...
Go version 1.12.10: OK.
Checking whether provider uses Go modules...
Go modules in use: OK.
Checking version of github.com/hashicorp/terraform-plugin-sdk to determine if provider was already migrated...
Checking version of github.com/hashicorp/terraform used in provider...
Terraform version 0.12.8: OK.
Checking whether provider uses deprecated SDK packages or identifiers...
No imports of deprecated SDK packages or identifiers: OK.
All constraints satisfied. Provider can be migrated to the new SDK.
Rewriting provider go.mod file...
Rewriting SDK package imports...
Running `go mod tidy`...
Success! Provider is migrated to github.com/hashicorp/terraform-plugin-sdk v1.1.0.
It looks like this provider vendors dependencies. Don't forget to run `go mod vendor`.
Make sure to review all changes and run all tests.
```
* Fix build under go 1.13.x.
When CustomizeDiff is run for a new resource, it does not have access to the
current state. In the digitalocean_certificate resource, we are using a
CustomizeDiff function to validate that certain attributes are used together
depending on the certificate type. When the value for one of those attributes
is interpolated, as in the case of generating a cert using the acme provider,
the validation fails since it depends on reading the value from state. As state
is not present, the value is interpreted as empty.
From the CustomizeDiff doc string:
> // The phases Terraform runs this in, and the state available via functions
> // like Get and GetChange, are as follows:
> //
> // * New resource: One run with no state
https://godoc.org/github.com/hashicorp/terraform/helper/schema#Resource
This PR moves the validation from the CustomizeDiff function into the
Create function as well as adding acceptance tests:
```
$ make testacc TESTARGS='-run=TestAccDigitalOceanCertificate_ExpectedErrors'
==> Checking that code complies with gofmt requirements...
TF_ACC=1 go test $(go list ./... |grep -v 'vendor') -v -run=TestAccDigitalOceanCertificate_ExpectedE$
? github.com/terraform-providers/terraform-provider-digitalocean [no test files]
=== RUN TestAccDigitalOceanCertificate_ExpectedErrors
--- PASS: TestAccDigitalOceanCertificate_ExpectedErrors (0.10s)
PASS
ok github.com/terraform-providers/terraform-provider-digitalocean/digitalocean (cached)
```
* Added importability for load balancer
* Added importability, go fmt'ed
* Added importability for DNS records
* added importability for certificates
* Added import notes for DNS records and load balancers
* Added import tests
* Added random int for test configs
* Added certificates for the test to import
* Fixed docs, added certificate importability on docs
* Make TestAccDigitalOceanCertificate_importBasic pass by reusing certificate generation from resource_digitalocean_certificate_test.go
* Fix importablity of Load Balancer Droplet droplet_ids.
* Revert "Added importability for DNS records"
This reverts commit 94b1f69fe756c862125d0b899d49eca74f7bd591.
* Remove mention of record imports in docs.
* Remove digitalocean/import_digitalocean_record_test.go