diff --git a/docs/resources/kvstore.md b/docs/resources/kvstore.md new file mode 100644 index 000000000..5769823ef --- /dev/null +++ b/docs/resources/kvstore.md @@ -0,0 +1,73 @@ +--- +layout: "fastly" +page_title: "Fastly: kvstore" +sidebar_current: "docs-fastly-resource-kvstore" +description: |- + Provides a persistent, globally consistent key-value store accessible to Compute@Edge services during request processing. +--- + +# fastly_kvstore + +Provides a persistent, globally consistent key-value store accessible to Compute@Edge services during request processing. + +-> **Note** The `kv_store` feature does not support seeding the store with data. This is because the size of objects that can be stored is very large and Terraform is designed for containing [configuration, not data](https://developer.fastly.com/learning/integrations/orchestration/terraform/#configuration-not-data). You should use either the [Fastly CLI](https://developer.fastly.com/learning/tools/cli/), [Fastly API](https://developer.fastly.com/reference/api/) or one of the available [Fastly API Clients](https://developer.fastly.com/reference/api/#clients) to populate your KV Store. + +## Example Usage + +Basic usage: + +```terraform +# IMPORTANT: Deleting a KV Store requires first deleting its resource_link. +# This requires a two-step `terraform apply` as we can't guarantee deletion order. +# e.g. resource_link deletion within fastly_service_compute might not finish first. +resource "fastly_kvstore" "example" { + name = "my_kv_store" +} + +resource "fastly_service_compute" "example" { + name = "my_compute_service" + + domain { + name = "demo.example.com" + } + + package { + filename = "package.tar.gz" + source_code_hash = data.fastly_package_hash.example.hash + } + + resource_link { + name = "my_resource_link" + resource_id = fastly_kvstore.example.id + } + + force_destroy = true +} + +data "fastly_package_hash" "example" { + filename = "package.tar.gz" +} +``` + +## Import + +Fastly KV Stores can be imported using their Store ID, e.g. + +```sh +$ terraform import fastly_kvstore.example xxxxxxxxxxxxxxxxxxxx +``` + + +## Schema + +### Required + +- `name` (String) A unique name to identify the KV Store. It is important to note that changing this attribute will delete and recreate the KV Store, and discard the current entries. + +### Optional + +- `force_destroy` (Boolean) Allow the KV store to be deleted, even if it contains entries. Defaults to false. + +### Read-Only + +- `id` (String) The ID of this resource. diff --git a/docs/resources/service_compute.md b/docs/resources/service_compute.md index 1f98287ab..5561810f0 100644 --- a/docs/resources/service_compute.md +++ b/docs/resources/service_compute.md @@ -102,6 +102,7 @@ $ terraform import fastly_service_compute.demo xxxxxxxxxxxxxxxxxxxx@2 - `logging_sumologic` (Block Set) (see [below for nested schema](#nestedblock--logging_sumologic)) - `logging_syslog` (Block Set) (see [below for nested schema](#nestedblock--logging_syslog)) - `product_enablement` (Block Set, Max: 1) (see [below for nested schema](#nestedblock--product_enablement)) +- `resource_link` (Block Set) A resource link represents a link between a shared resource (such as an KV Store or Config Store) and a service version. (see [below for nested schema](#nestedblock--resource_link)) - `reuse` (Boolean) Services that are active cannot be destroyed. If set to `true` a service Terraform intends to destroy will instead be deactivated (allowing it to be reused by importing it into another Terraform project). If `false`, attempting to destroy an active service will cause an error. Default `false` - `version_comment` (String) Description field for the version @@ -653,3 +654,16 @@ Optional: Read-Only: - `name` (String) Used internally by the provider to identify modified settings + + + +### Nested Schema for `resource_link` + +Required: + +- `name` (String) The name of the resource link. +- `resource_id` (String) The ID of the underlying linked resource. + +Read-Only: + +- `link_id` (String) An alphanumeric string identifying the resource link. diff --git a/examples/resources/components/kvstore_import_cmd.txt b/examples/resources/components/kvstore_import_cmd.txt new file mode 100644 index 000000000..9307cbf16 --- /dev/null +++ b/examples/resources/components/kvstore_import_cmd.txt @@ -0,0 +1 @@ +$ terraform import fastly_kvstore.example xxxxxxxxxxxxxxxxxxxx diff --git a/examples/resources/kvstore_basic_usage.tf b/examples/resources/kvstore_basic_usage.tf new file mode 100644 index 000000000..93fa988de --- /dev/null +++ b/examples/resources/kvstore_basic_usage.tf @@ -0,0 +1,30 @@ +# IMPORTANT: Deleting a KV Store requires first deleting its resource_link. +# This requires a two-step `terraform apply` as we can't guarantee deletion order. +# e.g. resource_link deletion within fastly_service_compute might not finish first. +resource "fastly_kvstore" "example" { + name = "my_kv_store" +} + +resource "fastly_service_compute" "example" { + name = "my_compute_service" + + domain { + name = "demo.example.com" + } + + package { + filename = "package.tar.gz" + source_code_hash = data.fastly_package_hash.example.hash + } + + resource_link { + name = "my_resource_link" + resource_id = fastly_kvstore.example.id + } + + force_destroy = true +} + +data "fastly_package_hash" "example" { + filename = "package.tar.gz" +} diff --git a/fastly/block_fastly_service_acl_test.go b/fastly/block_fastly_service_acl_test.go index eb9e51531..878382950 100644 --- a/fastly/block_fastly_service_acl_test.go +++ b/fastly/block_fastly_service_acl_test.go @@ -67,7 +67,7 @@ func TestAccFastlyServiceVCL_acl(t *testing.T) { { Config: testAccServiceVCLConfigACL(name, aclName, domain), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_vcl.foo", &service), + testAccCheckServiceExists("fastly_service_vcl.foo", &service), testAccCheckFastlyServiceVCLAttributesACL(&service, name, "a_"+aclName, &aclA), testAccCheckFastlyServiceVCLAttributesACL(&service, name, "b_"+aclName, &aclB), ), @@ -75,7 +75,7 @@ func TestAccFastlyServiceVCL_acl(t *testing.T) { { Config: testAccServiceVCLConfigACL(name, aclNameUpdated, domain), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_vcl.foo", &service), + testAccCheckServiceExists("fastly_service_vcl.foo", &service), testAccCheckFastlyServiceVCLAttributesACL(&service, name, "a_"+aclNameUpdated, &aclA), testAccCheckFastlyServiceVCLAttributesACL(&service, name, "b_"+aclNameUpdated, &aclB), ), @@ -95,7 +95,7 @@ func TestAccFastlyServiceVCL_acl(t *testing.T) { { Config: testAccServiceVCLConfigACLForceDestroy(name, aclNameUpdated, domain), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_vcl.foo", &service), + testAccCheckServiceExists("fastly_service_vcl.foo", &service), testAccCheckFastlyServiceVCLAttributesACL(&service, name, "a_"+aclNameUpdated, &aclA), testAccCheckFastlyServiceVCLAttributesACL(&service, name, "b_"+aclNameUpdated, &aclB), ), @@ -103,7 +103,7 @@ func TestAccFastlyServiceVCL_acl(t *testing.T) { { Config: testAccServiceVCLConfigACLForceDestroy(name, aclName, domain), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_vcl.foo", &service), + testAccCheckServiceExists("fastly_service_vcl.foo", &service), testAccCheckFastlyServiceVCLAttributesACL(&service, name, "a_"+aclName, &aclA), testAccCheckFastlyServiceVCLAttributesACL(&service, name, "b_"+aclName, &aclB), ), diff --git a/fastly/block_fastly_service_backend_test.go b/fastly/block_fastly_service_backend_test.go index 990a9a659..57413eb9c 100644 --- a/fastly/block_fastly_service_backend_test.go +++ b/fastly/block_fastly_service_backend_test.go @@ -237,7 +237,7 @@ func TestAccFastlyServiceVCLBackend_basic(t *testing.T) { { Config: testAccServiceVCLBackend(serviceName, domainName, backendAddress, backendName), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_vcl.foo", &service), + testAccCheckServiceExists("fastly_service_vcl.foo", &service), resource.TestCheckResourceAttr("fastly_service_vcl.foo", "name", serviceName), resource.TestCheckResourceAttr("fastly_service_vcl.foo", "backend.#", "1"), testAccCheckFastlyServiceVCLBackendAttributes(&service, []*gofastly.Backend{&b1}), @@ -247,7 +247,7 @@ func TestAccFastlyServiceVCLBackend_basic(t *testing.T) { { Config: testAccServiceVCLBackendUpdate(serviceName, domainName, backendAddress, backendName), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_vcl.foo", &service), + testAccCheckServiceExists("fastly_service_vcl.foo", &service), resource.TestCheckResourceAttr("fastly_service_vcl.foo", "backend.#", "3"), testAccCheckFastlyServiceVCLBackendAttributes(&service, []*gofastly.Backend{&b1, &b2, &b3}), ), diff --git a/fastly/block_fastly_service_cachesetting_test.go b/fastly/block_fastly_service_cachesetting_test.go index 921fe972b..61c7df7c4 100644 --- a/fastly/block_fastly_service_cachesetting_test.go +++ b/fastly/block_fastly_service_cachesetting_test.go @@ -76,7 +76,7 @@ func TestAccFastlyServiceVCLCacheSetting_basic(t *testing.T) { { Config: testAccServiceVCLCacheSetting(name, domainName1), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_vcl.foo", &service), + testAccCheckServiceExists("fastly_service_vcl.foo", &service), testAccCheckFastlyServiceVCLCacheSettingsAttributes(&service, []*gofastly.CacheSetting{&cq1}), resource.TestCheckResourceAttr( "fastly_service_vcl.foo", "name", name), @@ -90,7 +90,7 @@ func TestAccFastlyServiceVCLCacheSetting_basic(t *testing.T) { { Config: testAccServiceVCLCacheSettingUpdate(name, domainName1), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_vcl.foo", &service), + testAccCheckServiceExists("fastly_service_vcl.foo", &service), testAccCheckFastlyServiceVCLCacheSettingsAttributes(&service, []*gofastly.CacheSetting{&cq1, &cq2}), resource.TestCheckResourceAttr( "fastly_service_vcl.foo", "cache_setting.#", "2"), diff --git a/fastly/block_fastly_service_condition_test.go b/fastly/block_fastly_service_condition_test.go index bbf60132b..a1ad7e304 100644 --- a/fastly/block_fastly_service_condition_test.go +++ b/fastly/block_fastly_service_condition_test.go @@ -73,7 +73,7 @@ func TestAccFastlyServiceVCL_conditional_basic(t *testing.T) { { Config: testAccServiceVCLConditionConfig(name, domainName1), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_vcl.foo", &service), + testAccCheckServiceExists("fastly_service_vcl.foo", &service), testAccCheckFastlyServiceVCLConditionalAttributes(&service, name, []*gofastly.Condition{&con1}), resource.TestCheckResourceAttr( "fastly_service_vcl.foo", "name", name), @@ -84,7 +84,7 @@ func TestAccFastlyServiceVCL_conditional_basic(t *testing.T) { { Config: testAccServiceVCLConditionConfigUpdate(name, domainName1, "CACHE"), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_vcl.foo", &service), + testAccCheckServiceExists("fastly_service_vcl.foo", &service), testAccCheckFastlyServiceVCLConditionalAttributes(&service, name, []*gofastly.Condition{&con2}), ), }, diff --git a/fastly/block_fastly_service_dictionary_test.go b/fastly/block_fastly_service_dictionary_test.go index c43eae4bf..4a096f554 100644 --- a/fastly/block_fastly_service_dictionary_test.go +++ b/fastly/block_fastly_service_dictionary_test.go @@ -69,14 +69,14 @@ func TestAccFastlyServiceVCL_dictionary(t *testing.T) { { Config: testAccServiceVCLConfigDictionary(name, dictName, backendName, domainName), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_vcl.foo", &service), + testAccCheckServiceExists("fastly_service_vcl.foo", &service), testAccCheckFastlyServiceVCLAttributesDictionary(&service, &dictionary, name, dictName, false), ), }, { Config: testAccServiceVCLConfigDictionary(name, updatedDictName, backendName, domainName), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_vcl.foo", &service), + testAccCheckServiceExists("fastly_service_vcl.foo", &service), testAccCheckFastlyServiceVCLAttributesDictionary(&service, &dictionary, name, updatedDictName, false), ), }, @@ -91,14 +91,14 @@ func TestAccFastlyServiceVCL_dictionary(t *testing.T) { { Config: testAccServiceVCLConfigDictionaryForceDestroy(name, updatedDictName, backendName, domainName), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_vcl.foo", &service), + testAccCheckServiceExists("fastly_service_vcl.foo", &service), testAccCheckFastlyServiceVCLAttributesDictionary(&service, &dictionary, name, updatedDictName, false), ), }, { Config: testAccServiceVCLConfigDictionaryForceDestroy(name, dictName, backendName, domainName), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_vcl.foo", &service), + testAccCheckServiceExists("fastly_service_vcl.foo", &service), testAccCheckFastlyServiceVCLAttributesDictionary(&service, &dictionary, name, dictName, false), ), }, @@ -124,7 +124,7 @@ func TestAccFastlyServiceVCL_dictionary_write_only(t *testing.T) { { Config: testAccServiceVCLConfigDictionaryWriteOnly(name, dictName, backendName, domainName), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_vcl.foo", &service), + testAccCheckServiceExists("fastly_service_vcl.foo", &service), testAccCheckFastlyServiceVCLAttributesDictionary(&service, &dictionary, name, dictName, true), ), }, diff --git a/fastly/block_fastly_service_director_test.go b/fastly/block_fastly_service_director_test.go index d4dfee330..a51284e41 100644 --- a/fastly/block_fastly_service_director_test.go +++ b/fastly/block_fastly_service_director_test.go @@ -195,7 +195,7 @@ func TestAccFastlyServiceVCL_directors_basic(t *testing.T) { { Config: testAccServiceVCLDirectorsConfig(name, domainName1), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_vcl.foo", &service), + testAccCheckServiceExists("fastly_service_vcl.foo", &service), testAccCheckFastlyServiceVCLDirectorsAttributes(&service, []*gofastly.Director{&directorDeveloper, &directorApps}), testAccCheckFastlyServiceVCLDirectorBackends(&service, []*gofastly.DirectorBackend{&dbDeveloper, &dbApps}), resource.TestCheckResourceAttr("fastly_service_vcl.foo", "name", name), @@ -206,7 +206,7 @@ func TestAccFastlyServiceVCL_directors_basic(t *testing.T) { { Config: testAccServiceVCLDirectorsConfigUpdate1(name, domainName1), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_vcl.foo", &service), + testAccCheckServiceExists("fastly_service_vcl.foo", &service), testAccCheckFastlyServiceVCLDirectorsAttributes(&service, []*gofastly.Director{&directorDeveloperUpdated, &directorApps, &directorWWWDemo}), testAccCheckFastlyServiceVCLDirectorBackends(&service, []*gofastly.DirectorBackend{&dbDeveloperUpdated, &dbApps, &dbWWW, &dbDemo}), resource.TestCheckResourceAttr("fastly_service_vcl.foo", "name", name), @@ -217,7 +217,7 @@ func TestAccFastlyServiceVCL_directors_basic(t *testing.T) { { Config: testAccServiceVCLDirectorsConfigUpdate2(name, domainName1), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_vcl.foo", &service), + testAccCheckServiceExists("fastly_service_vcl.foo", &service), testAccCheckFastlyServiceVCLDirectorsAttributes(&service, []*gofastly.Director{&directorApps, &directorWWWDemo2}), testAccCheckFastlyServiceVCLDirectorBackends(&service, []*gofastly.DirectorBackend{&dbApps, &dbWWW}), resource.TestCheckResourceAttr("fastly_service_vcl.foo", "name", name), diff --git a/fastly/block_fastly_service_dynamicsnippet_test.go b/fastly/block_fastly_service_dynamicsnippet_test.go index 38cc8ca2e..f99eed35b 100644 --- a/fastly/block_fastly_service_dynamicsnippet_test.go +++ b/fastly/block_fastly_service_dynamicsnippet_test.go @@ -91,7 +91,7 @@ func TestAccFastlyServiceVCLDynamicSnippet_basic(t *testing.T) { { Config: testAccServiceVCLDynamicSnippet(name, domainName1), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_vcl.foo", &service), + testAccCheckServiceExists("fastly_service_vcl.foo", &service), testAccCheckFastlyServiceVCLDynamicSnippetAttributes(&service, []*gofastly.Snippet{&s1}), resource.TestCheckResourceAttr("fastly_service_vcl.foo", "name", name), resource.TestCheckResourceAttr("fastly_service_vcl.foo", "dynamicsnippet.#", "1"), @@ -106,7 +106,7 @@ func TestAccFastlyServiceVCLDynamicSnippet_basic(t *testing.T) { { Config: testAccServiceVCLDynamicSnippetUpdate(name, domainName1), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_vcl.foo", &service), + testAccCheckServiceExists("fastly_service_vcl.foo", &service), testAccCheckFastlyServiceVCLDynamicSnippetAttributes(&service, []*gofastly.Snippet{&updatedS1, &updatedS2}), resource.TestCheckResourceAttr("fastly_service_vcl.foo", "dynamicsnippet.#", "2"), resource.TestCheckTypeSetElemNestedAttrs("fastly_service_vcl.foo", "dynamicsnippet.*", map[string]string{ diff --git a/fastly/block_fastly_service_gzip_test.go b/fastly/block_fastly_service_gzip_test.go index 7a26502b3..b8a4b3aa1 100644 --- a/fastly/block_fastly_service_gzip_test.go +++ b/fastly/block_fastly_service_gzip_test.go @@ -108,7 +108,7 @@ func TestAccFastlyServiceVCL_gzips_basic(t *testing.T) { { Config: testAccServiceVCLGzipsConfig(name, domainName1), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_vcl.foo", &service), + testAccCheckServiceExists("fastly_service_vcl.foo", &service), testAccCheckFastlyServiceVCLGzipsAttributes(&service, []*gofastly.Gzip{&log1, &log2}), resource.TestCheckResourceAttr( "fastly_service_vcl.foo", "name", name), @@ -120,7 +120,7 @@ func TestAccFastlyServiceVCL_gzips_basic(t *testing.T) { { Config: testAccServiceVCLGzipsConfigDeleteCreate(name, domainName1), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_vcl.foo", &service), + testAccCheckServiceExists("fastly_service_vcl.foo", &service), testAccCheckFastlyServiceVCLGzipsAttributes(&service, []*gofastly.Gzip{&log3}), resource.TestCheckResourceAttr( "fastly_service_vcl.foo", "name", name), @@ -132,7 +132,7 @@ func TestAccFastlyServiceVCL_gzips_basic(t *testing.T) { { Config: testAccServiceVCLGzipsConfigUpdate(name, domainName1), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_vcl.foo", &service), + testAccCheckServiceExists("fastly_service_vcl.foo", &service), testAccCheckFastlyServiceVCLGzipsAttributes(&service, []*gofastly.Gzip{&log4}), resource.TestCheckResourceAttr( "fastly_service_vcl.foo", "name", name), diff --git a/fastly/block_fastly_service_header_test.go b/fastly/block_fastly_service_header_test.go index 785bad0fa..cc266d615 100644 --- a/fastly/block_fastly_service_header_test.go +++ b/fastly/block_fastly_service_header_test.go @@ -185,7 +185,7 @@ func TestAccFastlyServiceVCL_headers_basic(t *testing.T) { { Config: testAccServiceVCLHeadersConfig(name, domainName1), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_vcl.foo", &service), + testAccCheckServiceExists("fastly_service_vcl.foo", &service), testAccCheckFastlyServiceVCLHeaderAttributes(&service, []*gofastly.Header{&log1, &log2}), resource.TestCheckResourceAttr( "fastly_service_vcl.foo", "name", name), @@ -197,7 +197,7 @@ func TestAccFastlyServiceVCL_headers_basic(t *testing.T) { { Config: testAccServiceVCLHeadersConfigUpdate(name, domainName1), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_vcl.foo", &service), + testAccCheckServiceExists("fastly_service_vcl.foo", &service), testAccCheckFastlyServiceVCLHeaderAttributes(&service, []*gofastly.Header{&log1, &log3, &log4}), resource.TestCheckResourceAttr( "fastly_service_vcl.foo", "name", name), diff --git a/fastly/block_fastly_service_healthcheck_test.go b/fastly/block_fastly_service_healthcheck_test.go index bec8e7407..53e22b788 100644 --- a/fastly/block_fastly_service_healthcheck_test.go +++ b/fastly/block_fastly_service_healthcheck_test.go @@ -109,7 +109,7 @@ func TestAccFastlyServiceVCL_healthcheck_basic(t *testing.T) { { Config: testAccServiceVCLHealthCheckConfig(name, domainName), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_vcl.foo", &service), + testAccCheckServiceExists("fastly_service_vcl.foo", &service), testAccCheckFastlyServiceVCLHealthCheckAttributes(&service, []*gofastly.HealthCheck{&log1}), resource.TestCheckResourceAttr("fastly_service_vcl.foo", "name", name), resource.TestCheckResourceAttr("fastly_service_vcl.foo", "healthcheck.#", "1"), @@ -119,7 +119,7 @@ func TestAccFastlyServiceVCL_healthcheck_basic(t *testing.T) { { Config: testAccServiceVCLHealthCheckConfigUpdate(name, domainName), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_vcl.foo", &service), + testAccCheckServiceExists("fastly_service_vcl.foo", &service), testAccCheckFastlyServiceVCLHealthCheckAttributes(&service, []*gofastly.HealthCheck{&log1, &log2}), resource.TestCheckResourceAttr("fastly_service_vcl.foo", "name", name), resource.TestCheckResourceAttr("fastly_service_vcl.foo", "healthcheck.#", "2"), diff --git a/fastly/block_fastly_service_logging_bigquery_test.go b/fastly/block_fastly_service_logging_bigquery_test.go index e05df90b5..a1b5c218d 100644 --- a/fastly/block_fastly_service_logging_bigquery_test.go +++ b/fastly/block_fastly_service_logging_bigquery_test.go @@ -36,14 +36,14 @@ func TestAccFastlyServiceVCL_bigquerylogging(t *testing.T) { { Config: testAccServiceVCLConfigBigQuery(name, bqName, secretKey, email), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_vcl.foo", &service), + testAccCheckServiceExists("fastly_service_vcl.foo", &service), testAccCheckFastlyServiceVCLAttributesBQ(&service, name, bqName, email), ), }, { Config: testAccServiceVCLConfigBigQuery(name, bqName, secretKey, emailUpdate), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_vcl.foo", &service), + testAccCheckServiceExists("fastly_service_vcl.foo", &service), testAccCheckFastlyServiceVCLAttributesBQ(&service, name, bqName, emailUpdate), ), }, @@ -74,14 +74,14 @@ func TestAccFastlyServiceVCL_bigquerylogging_compute(t *testing.T) { { Config: testAccServiceVCLConfigBigQueryCompute(name, bqName, secretKey, email), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_compute.foo", &service), + testAccCheckServiceExists("fastly_service_compute.foo", &service), testAccCheckFastlyServiceVCLAttributesBQ(&service, name, bqName, email), ), }, { Config: testAccServiceVCLConfigBigQueryCompute(name, bqName, secretKey, emailUpdate), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_compute.foo", &service), + testAccCheckServiceExists("fastly_service_compute.foo", &service), testAccCheckFastlyServiceVCLAttributesBQ(&service, name, bqName, emailUpdate), ), }, diff --git a/fastly/block_fastly_service_logging_blobstorage_test.go b/fastly/block_fastly_service_logging_blobstorage_test.go index 3fadf4be4..3eb363d57 100644 --- a/fastly/block_fastly_service_logging_blobstorage_test.go +++ b/fastly/block_fastly_service_logging_blobstorage_test.go @@ -138,7 +138,7 @@ func TestAccFastlyServiceVCL_blobstoragelogging_basic(t *testing.T) { { Config: testAccServiceVCLBlobStorageLoggingConfigComplete(serviceName), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_vcl.foo", &service), + testAccCheckServiceExists("fastly_service_vcl.foo", &service), testAccCheckFastlyServiceVCLBlobStorageLoggingAttributes(&service, []*gofastly.BlobStorage{&blobStorageLogOne}, ServiceTypeVCL), resource.TestCheckResourceAttr( "fastly_service_vcl.foo", "name", serviceName), @@ -150,7 +150,7 @@ func TestAccFastlyServiceVCL_blobstoragelogging_basic(t *testing.T) { { Config: testAccServiceVCLBlobStorageLoggingConfigUpdate(serviceName), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_vcl.foo", &service), + testAccCheckServiceExists("fastly_service_vcl.foo", &service), testAccCheckFastlyServiceVCLBlobStorageLoggingAttributes(&service, []*gofastly.BlobStorage{&blobStorageLogOneUpdated, &blobStorageLogTwo}, ServiceTypeVCL), resource.TestCheckResourceAttr( "fastly_service_vcl.foo", "name", serviceName), @@ -190,7 +190,7 @@ func TestAccFastlyServiceVCL_blobstoragelogging_basic_compute(t *testing.T) { { Config: testAccServiceVCLBlobStorageLoggingConfigCompleteCompute(serviceName), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_compute.foo", &service), + testAccCheckServiceExists("fastly_service_compute.foo", &service), testAccCheckFastlyServiceVCLBlobStorageLoggingAttributes(&service, []*gofastly.BlobStorage{&blobStorageLogOne}, ServiceTypeCompute), resource.TestCheckResourceAttr("fastly_service_compute.foo", "name", serviceName), resource.TestCheckResourceAttr("fastly_service_compute.foo", "logging_blobstorage.#", "1"), @@ -226,7 +226,7 @@ func TestAccFastlyServiceVCL_blobstoragelogging_default(t *testing.T) { { Config: testAccServiceVCLBlobStorageLoggingConfigDefault(serviceName), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_vcl.foo", &service), + testAccCheckServiceExists("fastly_service_vcl.foo", &service), testAccCheckFastlyServiceVCLBlobStorageLoggingAttributes(&service, []*gofastly.BlobStorage{&blobStorageLog}, ServiceTypeVCL), resource.TestCheckResourceAttr( "fastly_service_vcl.foo", "name", serviceName), diff --git a/fastly/block_fastly_service_logging_cloudfiles_test.go b/fastly/block_fastly_service_logging_cloudfiles_test.go index 0785b7f83..adc53f5ac 100644 --- a/fastly/block_fastly_service_logging_cloudfiles_test.go +++ b/fastly/block_fastly_service_logging_cloudfiles_test.go @@ -145,7 +145,7 @@ func TestAccFastlyServiceVCL_logging_cloudfiles_basic(t *testing.T) { { Config: testAccServiceVCLCloudfilesConfig(name, domain), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_vcl.none", &service), + testAccCheckServiceExists("fastly_service_vcl.none", &service), testAccCheckFastlyServiceVCLCloudfilesAttributes(&service, []*gofastly.Cloudfiles{&log1}, ServiceTypeVCL), resource.TestCheckResourceAttr( "fastly_service_vcl.none", "name", name), @@ -157,7 +157,7 @@ func TestAccFastlyServiceVCL_logging_cloudfiles_basic(t *testing.T) { { Config: testAccServiceVCLCloudfilesConfigUpdate(name, domain), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_vcl.none", &service), + testAccCheckServiceExists("fastly_service_vcl.none", &service), testAccCheckFastlyServiceVCLCloudfilesAttributes(&service, []*gofastly.Cloudfiles{&log1AfterUpdate, &log2}, ServiceTypeVCL), resource.TestCheckResourceAttr( "fastly_service_vcl.none", "name", name), @@ -200,7 +200,7 @@ func TestAccFastlyServiceVCL_logging_cloudfiles_basic_compute(t *testing.T) { { Config: testAccServiceVCLComputeCloudfilesConfig(name, domain), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_compute.none", &service), + testAccCheckServiceExists("fastly_service_compute.none", &service), testAccCheckFastlyServiceVCLCloudfilesAttributes(&service, []*gofastly.Cloudfiles{&log1Compute}, ServiceTypeCompute), resource.TestCheckResourceAttr( "fastly_service_compute.none", "name", name), diff --git a/fastly/block_fastly_service_logging_datadog_test.go b/fastly/block_fastly_service_logging_datadog_test.go index 2309ab146..1e78aa8c0 100644 --- a/fastly/block_fastly_service_logging_datadog_test.go +++ b/fastly/block_fastly_service_logging_datadog_test.go @@ -170,7 +170,7 @@ func TestAccFastlyServiceVCL_logging_datadog_basic(t *testing.T) { { Config: testAccServiceVCLDatadogConfig(name, domain), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_vcl.foo", &service), + testAccCheckServiceExists("fastly_service_vcl.foo", &service), testAccCheckFastlyServiceVCLDatadogAttributes(&service, []*gofastly.Datadog{&log1}, ServiceTypeVCL), resource.TestCheckResourceAttr("fastly_service_vcl.foo", "name", name), resource.TestCheckResourceAttr("fastly_service_vcl.foo", "logging_datadog.#", "1"), @@ -180,7 +180,7 @@ func TestAccFastlyServiceVCL_logging_datadog_basic(t *testing.T) { { Config: testAccServiceVCLDatadogConfigUpdate(name, domain), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_vcl.foo", &service), + testAccCheckServiceExists("fastly_service_vcl.foo", &service), testAccCheckFastlyServiceVCLDatadogAttributes(&service, []*gofastly.Datadog{&log1AfterUpdate, &log2}, ServiceTypeVCL), resource.TestCheckResourceAttr("fastly_service_vcl.foo", "name", name), resource.TestCheckResourceAttr("fastly_service_vcl.foo", "logging_datadog.#", "2"), @@ -212,7 +212,7 @@ func TestAccFastlyServiceVCL_logging_datadog_basic_compute(t *testing.T) { { Config: testAccServiceVCLDatadogComputeConfig(name, domain), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_compute.foo", &service), + testAccCheckServiceExists("fastly_service_compute.foo", &service), testAccCheckFastlyServiceVCLDatadogAttributes(&service, []*gofastly.Datadog{&log1}, ServiceTypeCompute), resource.TestCheckResourceAttr( "fastly_service_compute.foo", "name", name), diff --git a/fastly/block_fastly_service_logging_digitalocean_test.go b/fastly/block_fastly_service_logging_digitalocean_test.go index 142aa6fcf..d3b927641 100644 --- a/fastly/block_fastly_service_logging_digitalocean_test.go +++ b/fastly/block_fastly_service_logging_digitalocean_test.go @@ -143,7 +143,7 @@ func TestAccFastlyServiceVCL_logging_digitalocean_basic(t *testing.T) { { Config: testAccServiceVCLDigitalOceanConfig(name, domain), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_vcl.foo", &service), + testAccCheckServiceExists("fastly_service_vcl.foo", &service), testAccCheckFastlyServiceVCLDigitalOceanAttributes(&service, []*gofastly.DigitalOcean{&log1}, ServiceTypeVCL), resource.TestCheckResourceAttr( "fastly_service_vcl.foo", "name", name), @@ -155,7 +155,7 @@ func TestAccFastlyServiceVCL_logging_digitalocean_basic(t *testing.T) { { Config: testAccServiceVCLDigitalOceanConfigUpdate(name, domain), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_vcl.foo", &service), + testAccCheckServiceExists("fastly_service_vcl.foo", &service), testAccCheckFastlyServiceVCLDigitalOceanAttributes(&service, []*gofastly.DigitalOcean{&log1AfterUpdate, &log2}, ServiceTypeVCL), resource.TestCheckResourceAttr( "fastly_service_vcl.foo", "name", name), @@ -197,7 +197,7 @@ func TestAccFastlyServiceVCL_logging_digitalocean_basic_compute(t *testing.T) { { Config: testAccServiceVCLDigitalOceanComputeConfig(name, domain), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_compute.foo", &service), + testAccCheckServiceExists("fastly_service_compute.foo", &service), testAccCheckFastlyServiceVCLDigitalOceanAttributes(&service, []*gofastly.DigitalOcean{&log1}, ServiceTypeCompute), resource.TestCheckResourceAttr( "fastly_service_compute.foo", "name", name), diff --git a/fastly/block_fastly_service_logging_elasticsearch_test.go b/fastly/block_fastly_service_logging_elasticsearch_test.go index aac747959..c31046b2c 100644 --- a/fastly/block_fastly_service_logging_elasticsearch_test.go +++ b/fastly/block_fastly_service_logging_elasticsearch_test.go @@ -145,7 +145,7 @@ func TestAccFastlyServiceVCL_logging_elasticsearch_basic(t *testing.T) { { Config: testAccServiceVCLElasticsearchConfig(name, domain), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_vcl.foo", &service), + testAccCheckServiceExists("fastly_service_vcl.foo", &service), testAccCheckFastlyServiceVCLElasticsearchAttributes(&service, []*fst.Elasticsearch{&log1}, ServiceTypeVCL), resource.TestCheckResourceAttr( "fastly_service_vcl.foo", "name", name), @@ -157,7 +157,7 @@ func TestAccFastlyServiceVCL_logging_elasticsearch_basic(t *testing.T) { { Config: testAccServiceVCLElasticsearchConfigUpdate(name, domain), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_vcl.foo", &service), + testAccCheckServiceExists("fastly_service_vcl.foo", &service), testAccCheckFastlyServiceVCLElasticsearchAttributes(&service, []*fst.Elasticsearch{&log1AfterUpdate, &log2}, ServiceTypeVCL), resource.TestCheckResourceAttr( "fastly_service_vcl.foo", "name", name), @@ -200,7 +200,7 @@ func TestAccFastlyServiceVCL_logging_elasticsearch_basic_compute(t *testing.T) { { Config: testAccServiceVCLElasticsearchComputeConfig(name, domain), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_compute.foo", &service), + testAccCheckServiceExists("fastly_service_compute.foo", &service), testAccCheckFastlyServiceVCLElasticsearchAttributes(&service, []*fst.Elasticsearch{&log1}, ServiceTypeCompute), resource.TestCheckResourceAttr( "fastly_service_compute.foo", "name", name), diff --git a/fastly/block_fastly_service_logging_ftp_test.go b/fastly/block_fastly_service_logging_ftp_test.go index fcf96b681..425655b2e 100644 --- a/fastly/block_fastly_service_logging_ftp_test.go +++ b/fastly/block_fastly_service_logging_ftp_test.go @@ -137,7 +137,7 @@ func TestAccFastlyServiceVCL_logging_ftp_basic(t *testing.T) { { Config: testAccServiceVCLFTPConfig(name, domain), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_vcl.foo", &service), + testAccCheckServiceExists("fastly_service_vcl.foo", &service), testAccCheckFastlyServiceVCLFTPAttributes(&service, []*gofastly.FTP{&log1}, ServiceTypeVCL), resource.TestCheckResourceAttr( "fastly_service_vcl.foo", "name", name), @@ -149,7 +149,7 @@ func TestAccFastlyServiceVCL_logging_ftp_basic(t *testing.T) { { Config: testAccServiceVCLFTPConfigUpdate(name, domain), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_vcl.foo", &service), + testAccCheckServiceExists("fastly_service_vcl.foo", &service), testAccCheckFastlyServiceVCLFTPAttributes(&service, []*gofastly.FTP{&log1AfterUpdate, &log2}, ServiceTypeVCL), resource.TestCheckResourceAttr( "fastly_service_vcl.foo", "name", name), @@ -190,7 +190,7 @@ func TestAccFastlyServiceVCL_logging_ftp_basic_compute(t *testing.T) { { Config: testAccServiceVCLFTPComputeConfig(name, domain), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_compute.foo", &service), + testAccCheckServiceExists("fastly_service_compute.foo", &service), testAccCheckFastlyServiceVCLFTPAttributes(&service, []*gofastly.FTP{&log1}, ServiceTypeCompute), resource.TestCheckResourceAttr( "fastly_service_compute.foo", "name", name), diff --git a/fastly/block_fastly_service_logging_gcs_test.go b/fastly/block_fastly_service_logging_gcs_test.go index 34f26e993..937c5bf8b 100644 --- a/fastly/block_fastly_service_logging_gcs_test.go +++ b/fastly/block_fastly_service_logging_gcs_test.go @@ -84,7 +84,7 @@ func TestAccFastlyServiceVCL_gcslogging(t *testing.T) { { Config: testAccServiceVCLConfigGCS(name, gcsName, secretKey), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_vcl.foo", &service), + testAccCheckServiceExists("fastly_service_vcl.foo", &service), testAccCheckFastlyServiceVCLAttributesGCS(&service, name, gcsName), ), }, @@ -111,7 +111,7 @@ func TestAccFastlyServiceVCL_gcslogging_compute(t *testing.T) { { Config: testAccServiceVCLConfigComputeGCS(name, gcsName, secretKey), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_compute.foo", &service), + testAccCheckServiceExists("fastly_service_compute.foo", &service), testAccCheckFastlyServiceVCLAttributesGCS(&service, name, gcsName), ), }, diff --git a/fastly/block_fastly_service_logging_googlepubsub_test.go b/fastly/block_fastly_service_logging_googlepubsub_test.go index 52f59a7bd..32268e00c 100644 --- a/fastly/block_fastly_service_logging_googlepubsub_test.go +++ b/fastly/block_fastly_service_logging_googlepubsub_test.go @@ -210,7 +210,7 @@ func TestAccFastlyServiceVCL_googlepubsublogging_basic(t *testing.T) { { Config: testAccServiceVCLGooglePubSubConfig(name, domain), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_vcl.foo", &service), + testAccCheckServiceExists("fastly_service_vcl.foo", &service), testAccCheckFastlyServiceVCLGooglePubSubAttributes(&service, []*gofastly.Pubsub{&log1}, ServiceTypeVCL), resource.TestCheckResourceAttr( "fastly_service_vcl.foo", "name", name), @@ -222,7 +222,7 @@ func TestAccFastlyServiceVCL_googlepubsublogging_basic(t *testing.T) { { Config: testAccServiceVCLGooglePubSubConfigUpdate(name, domain), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_vcl.foo", &service), + testAccCheckServiceExists("fastly_service_vcl.foo", &service), testAccCheckFastlyServiceVCLGooglePubSubAttributes(&service, []*gofastly.Pubsub{&log1AfterUpdate, &log2}, ServiceTypeVCL), resource.TestCheckResourceAttr( "fastly_service_vcl.foo", "name", name), @@ -258,7 +258,7 @@ func TestAccFastlyServiceVCL_googlepubsublogging_basic_compute(t *testing.T) { { Config: testAccServiceVCLGooglePubSubComputeConfig(name, domain), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_compute.foo", &service), + testAccCheckServiceExists("fastly_service_compute.foo", &service), testAccCheckFastlyServiceVCLGooglePubSubAttributes(&service, []*gofastly.Pubsub{&log1}, ServiceTypeCompute), resource.TestCheckResourceAttr( "fastly_service_compute.foo", "name", name), diff --git a/fastly/block_fastly_service_logging_heroku_test.go b/fastly/block_fastly_service_logging_heroku_test.go index 365e4ec63..39c6d3c26 100644 --- a/fastly/block_fastly_service_logging_heroku_test.go +++ b/fastly/block_fastly_service_logging_heroku_test.go @@ -96,7 +96,7 @@ func TestAccFastlyServiceVCL_logging_heroku_basic(t *testing.T) { { Config: testAccServiceVCLHerokuConfig(name, domain), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_vcl.foo", &service), + testAccCheckServiceExists("fastly_service_vcl.foo", &service), testAccCheckFastlyServiceVCLHerokuAttributes(&service, []*gofastly.Heroku{&log1}, ServiceTypeVCL), resource.TestCheckResourceAttr( "fastly_service_vcl.foo", "name", name), @@ -108,7 +108,7 @@ func TestAccFastlyServiceVCL_logging_heroku_basic(t *testing.T) { { Config: testAccServiceVCLHerokuConfigUpdate(name, domain), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_vcl.foo", &service), + testAccCheckServiceExists("fastly_service_vcl.foo", &service), testAccCheckFastlyServiceVCLHerokuAttributes(&service, []*gofastly.Heroku{&log1AfterUpdate, &log2}, ServiceTypeVCL), resource.TestCheckResourceAttr( "fastly_service_vcl.foo", "name", name), @@ -142,7 +142,7 @@ func TestAccFastlyServiceVCL_logging_heroku_basic_compute(t *testing.T) { { Config: testAccServiceVCLHerokuComputeConfig(name, domain), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_compute.foo", &service), + testAccCheckServiceExists("fastly_service_compute.foo", &service), testAccCheckFastlyServiceVCLHerokuAttributes(&service, []*gofastly.Heroku{&log1}, ServiceTypeCompute), resource.TestCheckResourceAttr( "fastly_service_compute.foo", "name", name), diff --git a/fastly/block_fastly_service_logging_honeycomb_test.go b/fastly/block_fastly_service_logging_honeycomb_test.go index dff742ad6..4d5d6644a 100644 --- a/fastly/block_fastly_service_logging_honeycomb_test.go +++ b/fastly/block_fastly_service_logging_honeycomb_test.go @@ -129,7 +129,7 @@ func TestAccFastlyServiceVCL_logging_honeycomb_basic(t *testing.T) { { Config: testAccServiceVCLHoneycombConfig(name, domain), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_vcl.foo", &service), + testAccCheckServiceExists("fastly_service_vcl.foo", &service), testAccCheckFastlyServiceVCLHoneycombAttributes(&service, []*gofastly.Honeycomb{&log1}, ServiceTypeVCL), resource.TestCheckResourceAttr( "fastly_service_vcl.foo", "name", name), @@ -141,7 +141,7 @@ func TestAccFastlyServiceVCL_logging_honeycomb_basic(t *testing.T) { { Config: testAccServiceVCLHoneycombConfigUpdate(name, domain), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_vcl.foo", &service), + testAccCheckServiceExists("fastly_service_vcl.foo", &service), testAccCheckFastlyServiceVCLHoneycombAttributes(&service, []*gofastly.Honeycomb{&log1AfterUpdate, &log2}, ServiceTypeVCL), resource.TestCheckResourceAttr( "fastly_service_vcl.foo", "name", name), @@ -175,7 +175,7 @@ func TestAccFastlyServiceVCL_logging_honeycomb_basic_compute(t *testing.T) { { Config: testAccServiceVCLHoneycombComputeConfig(name, domain), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_compute.foo", &service), + testAccCheckServiceExists("fastly_service_compute.foo", &service), testAccCheckFastlyServiceVCLHoneycombAttributes(&service, []*gofastly.Honeycomb{&log1}, ServiceTypeCompute), resource.TestCheckResourceAttr( "fastly_service_compute.foo", "name", name), diff --git a/fastly/block_fastly_service_logging_https_test.go b/fastly/block_fastly_service_logging_https_test.go index c559630fb..ab1eafdf7 100644 --- a/fastly/block_fastly_service_logging_https_test.go +++ b/fastly/block_fastly_service_logging_https_test.go @@ -109,7 +109,7 @@ func TestAccFastlyServiceVCL_httpslogging_basic(t *testing.T) { { Config: testAccServiceVCLHTTPSConfig(name, domain), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_vcl.foo", &service), + testAccCheckServiceExists("fastly_service_vcl.foo", &service), testAccCheckFastlyServiceVCLHTTPSAttributes(&service, []*gofastly.HTTPS{&log1}, ServiceTypeVCL), resource.TestCheckResourceAttr( "fastly_service_vcl.foo", "name", name), @@ -121,7 +121,7 @@ func TestAccFastlyServiceVCL_httpslogging_basic(t *testing.T) { { Config: testAccServiceVCLHTTPSConfigUpdate(name, domain), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_vcl.foo", &service), + testAccCheckServiceExists("fastly_service_vcl.foo", &service), testAccCheckFastlyServiceVCLHTTPSAttributes(&service, []*gofastly.HTTPS{&log1AfterUpdate, &log2}, ServiceTypeVCL), resource.TestCheckResourceAttr( "fastly_service_vcl.foo", "name", name), @@ -159,7 +159,7 @@ func TestAccFastlyServiceVCL_httpslogging_basic_compute(t *testing.T) { { Config: testAccServiceVCLHTTPSComputeConfig(name, domain), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_compute.foo", &service), + testAccCheckServiceExists("fastly_service_compute.foo", &service), testAccCheckFastlyServiceVCLHTTPSAttributes(&service, []*gofastly.HTTPS{&https}, ServiceTypeCompute), resource.TestCheckResourceAttr( "fastly_service_compute.foo", "name", name), diff --git a/fastly/block_fastly_service_logging_kafka_test.go b/fastly/block_fastly_service_logging_kafka_test.go index a00d7c0aa..15049a1eb 100644 --- a/fastly/block_fastly_service_logging_kafka_test.go +++ b/fastly/block_fastly_service_logging_kafka_test.go @@ -160,7 +160,7 @@ func TestAccFastlyServiceVCL_kafkalogging_basic(t *testing.T) { { Config: testAccServiceVCLKafkaConfig(name, domain), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_vcl.foo", &service), + testAccCheckServiceExists("fastly_service_vcl.foo", &service), testAccCheckFastlyServiceVCLKafkaAttributes(&service, []*gofastly.Kafka{&log1}, ServiceTypeVCL), resource.TestCheckResourceAttr( "fastly_service_vcl.foo", "name", name), @@ -172,7 +172,7 @@ func TestAccFastlyServiceVCL_kafkalogging_basic(t *testing.T) { { Config: testAccServiceVCLKafkaConfigUpdate(name, domain), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_vcl.foo", &service), + testAccCheckServiceExists("fastly_service_vcl.foo", &service), testAccCheckFastlyServiceVCLKafkaAttributes(&service, []*gofastly.Kafka{&log1AfterUpdate, &log2}, ServiceTypeVCL), resource.TestCheckResourceAttr( "fastly_service_vcl.foo", "name", name), @@ -213,7 +213,7 @@ func TestAccFastlyServiceVCL_kafkalogging_basic_compute(t *testing.T) { { Config: testAccServiceVCLKafkaComputeConfig(name, domain), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_compute.foo", &service), + testAccCheckServiceExists("fastly_service_compute.foo", &service), testAccCheckFastlyServiceVCLKafkaAttributes(&service, []*gofastly.Kafka{&log1}, ServiceTypeCompute), resource.TestCheckResourceAttr( "fastly_service_compute.foo", "name", name), diff --git a/fastly/block_fastly_service_logging_kinesis_test.go b/fastly/block_fastly_service_logging_kinesis_test.go index b62c21d50..95d8c7f97 100644 --- a/fastly/block_fastly_service_logging_kinesis_test.go +++ b/fastly/block_fastly_service_logging_kinesis_test.go @@ -131,7 +131,7 @@ func TestAccFastlyServiceVCL_logging_kinesis_basic(t *testing.T) { { Config: testAccServiceVCLKinesisConfig(name, domain), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_vcl.foo", &service), + testAccCheckServiceExists("fastly_service_vcl.foo", &service), testAccCheckFastlyServiceVCLKinesisAttributes(&service, []*gofastly.Kinesis{&log1}, ServiceTypeVCL), resource.TestCheckResourceAttr( "fastly_service_vcl.foo", "name", name), @@ -143,7 +143,7 @@ func TestAccFastlyServiceVCL_logging_kinesis_basic(t *testing.T) { { Config: testAccServiceVCLKinesisConfigUpdate(name, domain), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_vcl.foo", &service), + testAccCheckServiceExists("fastly_service_vcl.foo", &service), testAccCheckFastlyServiceVCLKinesisAttributes(&service, []*gofastly.Kinesis{&log1AfterUpdate, &log2}, ServiceTypeVCL), resource.TestCheckResourceAttr( "fastly_service_vcl.foo", "name", name), @@ -179,7 +179,7 @@ func TestAccFastlyServiceVCL_logging_kinesis_basic_compute(t *testing.T) { { Config: testAccServiceVCLKinesisComputeConfig(name, domain), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_compute.foo", &service), + testAccCheckServiceExists("fastly_service_compute.foo", &service), testAccCheckFastlyServiceVCLKinesisAttributes(&service, []*gofastly.Kinesis{&log1}, ServiceTypeCompute), resource.TestCheckResourceAttr( "fastly_service_compute.foo", "name", name), diff --git a/fastly/block_fastly_service_logging_logentries_test.go b/fastly/block_fastly_service_logging_logentries_test.go index 38b222dd4..b030f8324 100644 --- a/fastly/block_fastly_service_logging_logentries_test.go +++ b/fastly/block_fastly_service_logging_logentries_test.go @@ -88,7 +88,7 @@ func TestAccFastlyServiceVCL_logentries_basic(t *testing.T) { { Config: testAccServiceVCLLogentriesConfig(name, domainName1), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_vcl.foo", &service), + testAccCheckServiceExists("fastly_service_vcl.foo", &service), testAccCheckFastlyServiceVCLLogentriesAttributes(&service, []*gofastly.Logentries{&log1}, ServiceTypeVCL), resource.TestCheckResourceAttr( "fastly_service_vcl.foo", "name", name), @@ -99,7 +99,7 @@ func TestAccFastlyServiceVCL_logentries_basic(t *testing.T) { { Config: testAccServiceVCLLogentriesConfigUpdate(name, domainName1), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_vcl.foo", &service), + testAccCheckServiceExists("fastly_service_vcl.foo", &service), testAccCheckFastlyServiceVCLLogentriesAttributes(&service, []*gofastly.Logentries{&log1, &log2}, ServiceTypeVCL), resource.TestCheckResourceAttr( "fastly_service_vcl.foo", "name", name), @@ -137,7 +137,7 @@ func TestAccFastlyServiceVCL_logentries_basic_compute(t *testing.T) { { Config: testAccServiceVCLLogentriesComputeConfig(name, domainName1), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_compute.foo", &service), + testAccCheckServiceExists("fastly_service_compute.foo", &service), testAccCheckFastlyServiceVCLLogentriesAttributes(&service, []*gofastly.Logentries{&log1}, ServiceTypeCompute), resource.TestCheckResourceAttr( "fastly_service_compute.foo", "name", name), @@ -228,7 +228,7 @@ func TestAccFastlyServiceVCL_logentries_formatVersion(t *testing.T) { { Config: testAccServiceVCLLogentriesConfigFormatVersion(name, domainName1), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_vcl.foo", &service), + testAccCheckServiceExists("fastly_service_vcl.foo", &service), testAccCheckFastlyServiceVCLLogentriesAttributes(&service, []*gofastly.Logentries{&log1}, ServiceTypeVCL), resource.TestCheckResourceAttr( "fastly_service_vcl.foo", "name", name), diff --git a/fastly/block_fastly_service_logging_loggly_test.go b/fastly/block_fastly_service_logging_loggly_test.go index 2ce45f9ed..9136f4cb8 100644 --- a/fastly/block_fastly_service_logging_loggly_test.go +++ b/fastly/block_fastly_service_logging_loggly_test.go @@ -83,7 +83,7 @@ func TestAccFastlyServiceVCL_logging_loggly_basic(t *testing.T) { { Config: testAccServiceVCLLogglyConfig(name, domain), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_vcl.foo", &service), + testAccCheckServiceExists("fastly_service_vcl.foo", &service), testAccCheckFastlyServiceVCLLogglyAttributes(&service, []*gofastly.Loggly{&log1}, ServiceTypeVCL), resource.TestCheckResourceAttr( "fastly_service_vcl.foo", "name", name), @@ -95,7 +95,7 @@ func TestAccFastlyServiceVCL_logging_loggly_basic(t *testing.T) { { Config: testAccServiceVCLLogglyConfigUpdate(name, domain), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_vcl.foo", &service), + testAccCheckServiceExists("fastly_service_vcl.foo", &service), testAccCheckFastlyServiceVCLLogglyAttributes(&service, []*gofastly.Loggly{&log1AfterUpdate, &log2}, ServiceTypeVCL), resource.TestCheckResourceAttr( "fastly_service_vcl.foo", "name", name), @@ -128,7 +128,7 @@ func TestAccFastlyServiceVCL_logging_loggly_basic_compute(t *testing.T) { { Config: testAccServiceVCLLogglyComputeConfig(name, domain), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_compute.foo", &service), + testAccCheckServiceExists("fastly_service_compute.foo", &service), testAccCheckFastlyServiceVCLLogglyAttributes(&service, []*gofastly.Loggly{&log1}, ServiceTypeCompute), resource.TestCheckResourceAttr( "fastly_service_compute.foo", "name", name), diff --git a/fastly/block_fastly_service_logging_logshuttle_test.go b/fastly/block_fastly_service_logging_logshuttle_test.go index 3e1552b8e..b44d1d685 100644 --- a/fastly/block_fastly_service_logging_logshuttle_test.go +++ b/fastly/block_fastly_service_logging_logshuttle_test.go @@ -96,7 +96,7 @@ func TestAccFastlyServiceVCL_logging_logshuttle_basic(t *testing.T) { { Config: testAccServiceVCLLogshuttleConfig(name, domain), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_vcl.foo", &service), + testAccCheckServiceExists("fastly_service_vcl.foo", &service), testAccCheckFastlyServiceVCLLogshuttleAttributes(&service, []*gofastly.Logshuttle{&log1}, ServiceTypeVCL), resource.TestCheckResourceAttr("fastly_service_vcl.foo", "name", name), resource.TestCheckResourceAttr("fastly_service_vcl.foo", "logging_logshuttle.#", "1"), @@ -106,7 +106,7 @@ func TestAccFastlyServiceVCL_logging_logshuttle_basic(t *testing.T) { { Config: testAccServiceVCLLogshuttleConfigUpdate(name, domain), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_vcl.foo", &service), + testAccCheckServiceExists("fastly_service_vcl.foo", &service), testAccCheckFastlyServiceVCLLogshuttleAttributes(&service, []*gofastly.Logshuttle{&log1AfterUpdate, &log2}, ServiceTypeVCL), resource.TestCheckResourceAttr("fastly_service_vcl.foo", "name", name), resource.TestCheckResourceAttr("fastly_service_vcl.foo", "logging_logshuttle.#", "2"), @@ -138,7 +138,7 @@ func TestAccFastlyServiceVCL_logging_logshuttle_basic_compute(t *testing.T) { { Config: testAccServiceVCLLogshuttleComputeConfig(name, domain), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_compute.foo", &service), + testAccCheckServiceExists("fastly_service_compute.foo", &service), testAccCheckFastlyServiceVCLLogshuttleAttributes(&service, []*gofastly.Logshuttle{&log1}, ServiceTypeCompute), resource.TestCheckResourceAttr( "fastly_service_compute.foo", "name", name), diff --git a/fastly/block_fastly_service_logging_newrelic_test.go b/fastly/block_fastly_service_logging_newrelic_test.go index 1be624a18..70861a6e7 100644 --- a/fastly/block_fastly_service_logging_newrelic_test.go +++ b/fastly/block_fastly_service_logging_newrelic_test.go @@ -104,7 +104,7 @@ func TestAccFastlyServiceVCL_logging_newrelic_basic(t *testing.T) { { Config: testAccServiceVCLNewRelicConfig(name, domain), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_vcl.foo", &service), + testAccCheckServiceExists("fastly_service_vcl.foo", &service), testAccCheckFastlyServiceVCLNewRelicAttributes(&service, []*gofastly.NewRelic{&log1}, ServiceTypeVCL), resource.TestCheckResourceAttr( "fastly_service_vcl.foo", "name", name), @@ -116,7 +116,7 @@ func TestAccFastlyServiceVCL_logging_newrelic_basic(t *testing.T) { { Config: testAccServiceVCLNewRelicConfigUpdate(name, domain), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_vcl.foo", &service), + testAccCheckServiceExists("fastly_service_vcl.foo", &service), testAccCheckFastlyServiceVCLNewRelicAttributes(&service, []*gofastly.NewRelic{&log1AfterUpdate, &log2}, ServiceTypeVCL), resource.TestCheckResourceAttr( "fastly_service_vcl.foo", "name", name), @@ -153,7 +153,7 @@ func TestAccFastlyServiceVCL_logging_newrelic_basic_compute(t *testing.T) { { Config: testAccServiceVCLNewRelicComputeConfig(name, domain), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_compute.foo", &service), + testAccCheckServiceExists("fastly_service_compute.foo", &service), testAccCheckFastlyServiceVCLNewRelicAttributes(&service, []*gofastly.NewRelic{&log1}, ServiceTypeCompute), resource.TestCheckResourceAttr( "fastly_service_compute.foo", "name", name), diff --git a/fastly/block_fastly_service_logging_openstack_test.go b/fastly/block_fastly_service_logging_openstack_test.go index e62390154..ee144b659 100644 --- a/fastly/block_fastly_service_logging_openstack_test.go +++ b/fastly/block_fastly_service_logging_openstack_test.go @@ -141,7 +141,7 @@ func TestAccFastlyServiceVCL_logging_openstack_basic(t *testing.T) { { Config: testAccServiceVCLOpenstackConfig(name, domain), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_vcl.foo", &service), + testAccCheckServiceExists("fastly_service_vcl.foo", &service), testAccCheckFastlyServiceVCLOpenstackAttributes(&service, []*gofastly.Openstack{&log1}, ServiceTypeVCL), resource.TestCheckResourceAttr( "fastly_service_vcl.foo", "name", name), @@ -153,7 +153,7 @@ func TestAccFastlyServiceVCL_logging_openstack_basic(t *testing.T) { { Config: testAccServiceVCLOpenstackConfigUpdate(name, domain), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_vcl.foo", &service), + testAccCheckServiceExists("fastly_service_vcl.foo", &service), testAccCheckFastlyServiceVCLOpenstackAttributes(&service, []*gofastly.Openstack{&log1AfterUpdate, &log2}, ServiceTypeVCL), resource.TestCheckResourceAttr( "fastly_service_vcl.foo", "name", name), @@ -195,7 +195,7 @@ func TestAccFastlyServiceVCL_logging_openstack_basic_compute(t *testing.T) { { Config: testAccServiceVCLOpenstackComputeConfig(name, domain), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_compute.foo", &service), + testAccCheckServiceExists("fastly_service_compute.foo", &service), testAccCheckFastlyServiceVCLOpenstackAttributes(&service, []*gofastly.Openstack{&log1}, ServiceTypeCompute), resource.TestCheckResourceAttr( "fastly_service_compute.foo", "name", name), diff --git a/fastly/block_fastly_service_logging_papertrail_test.go b/fastly/block_fastly_service_logging_papertrail_test.go index 3e6e97cfe..e08a63e76 100644 --- a/fastly/block_fastly_service_logging_papertrail_test.go +++ b/fastly/block_fastly_service_logging_papertrail_test.go @@ -83,7 +83,7 @@ func TestAccFastlyServiceVCL_papertrail_basic(t *testing.T) { { Config: testAccServiceVCLPapertrailConfig(name, domainName1), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_vcl.foo", &service), + testAccCheckServiceExists("fastly_service_vcl.foo", &service), testAccCheckFastlyServiceVCLPapertrailAttributes(&service, []*gofastly.Papertrail{&log1}, ServiceTypeVCL), resource.TestCheckResourceAttr( "fastly_service_vcl.foo", "name", name), @@ -95,7 +95,7 @@ func TestAccFastlyServiceVCL_papertrail_basic(t *testing.T) { { Config: testAccServiceVCLPapertrailConfigUpdate(name, domainName1), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_vcl.foo", &service), + testAccCheckServiceExists("fastly_service_vcl.foo", &service), testAccCheckFastlyServiceVCLPapertrailAttributes(&service, []*gofastly.Papertrail{&log1, &log2}, ServiceTypeVCL), resource.TestCheckResourceAttr( "fastly_service_vcl.foo", "name", name), @@ -129,7 +129,7 @@ func TestAccFastlyServiceVCL_papertrail_basic_compute(t *testing.T) { { Config: testAccServiceVCLPapertrailComputeConfig(name, domainName1), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_compute.foo", &service), + testAccCheckServiceExists("fastly_service_compute.foo", &service), testAccCheckFastlyServiceVCLPapertrailAttributes(&service, []*gofastly.Papertrail{&log1}, ServiceTypeCompute), resource.TestCheckResourceAttr( "fastly_service_compute.foo", "name", name), diff --git a/fastly/block_fastly_service_logging_s3_test.go b/fastly/block_fastly_service_logging_s3_test.go index fa471dd10..5cfdc35a0 100644 --- a/fastly/block_fastly_service_logging_s3_test.go +++ b/fastly/block_fastly_service_logging_s3_test.go @@ -218,7 +218,7 @@ func TestAccFastlyServiceVCL_s3logging_basic(t *testing.T) { { Config: testAccServiceVCLS3LoggingConfig(name, domainName1, testAwsPrimaryAccessKey, testAwsPrimarySecretKey), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_vcl.foo", &service), + testAccCheckServiceExists("fastly_service_vcl.foo", &service), testAccCheckFastlyServiceVCLS3LoggingAttributes(&service, []*gofastly.S3{&log1}, ServiceTypeVCL), resource.TestCheckResourceAttr( "fastly_service_vcl.foo", "name", name), @@ -230,7 +230,7 @@ func TestAccFastlyServiceVCL_s3logging_basic(t *testing.T) { { Config: testAccServiceVCLS3LoggingConfigUpdate(name, domainName1), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_vcl.foo", &service), + testAccCheckServiceExists("fastly_service_vcl.foo", &service), testAccCheckFastlyServiceVCLS3LoggingAttributes(&service, []*gofastly.S3{&log1AfterUpdate, &log2}, ServiceTypeVCL), resource.TestCheckResourceAttr( "fastly_service_vcl.foo", "name", name), @@ -272,7 +272,7 @@ func TestAccFastlyServiceVCL_s3logging_basic_compute(t *testing.T) { { Config: testAccServiceVCLS3LoggingComputeConfig(name, domainName1, testAwsPrimaryAccessKey, testAwsPrimarySecretKey), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_compute.foo", &service), + testAccCheckServiceExists("fastly_service_compute.foo", &service), testAccCheckFastlyServiceVCLS3LoggingAttributes(&service, []*gofastly.S3{&log1}, ServiceTypeCompute), resource.TestCheckResourceAttr( "fastly_service_compute.foo", "name", name), @@ -315,7 +315,7 @@ func TestAccFastlyServiceVCL_s3logging_domain_default(t *testing.T) { { Config: testAccServiceVCLS3LoggingConfigDomainDefault(name, domainName1), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_vcl.foo", &service), + testAccCheckServiceExists("fastly_service_vcl.foo", &service), testAccCheckFastlyServiceVCLS3LoggingAttributes(&service, []*gofastly.S3{&log1}, ServiceTypeVCL), resource.TestCheckResourceAttr( "fastly_service_vcl.foo", "name", name), @@ -357,7 +357,7 @@ func TestAccFastlyServiceVCL_s3logging_formatVersion(t *testing.T) { { Config: testAccServiceVCLS3LoggingConfigFormatVersion(name, domainName1, testAwsPrimaryAccessKey, testAwsPrimarySecretKey), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_vcl.foo", &service), + testAccCheckServiceExists("fastly_service_vcl.foo", &service), testAccCheckFastlyServiceVCLS3LoggingAttributes(&service, []*gofastly.S3{&log1}, ServiceTypeVCL), resource.TestCheckResourceAttr( "fastly_service_vcl.foo", "name", name), diff --git a/fastly/block_fastly_service_logging_scalyr_test.go b/fastly/block_fastly_service_logging_scalyr_test.go index 3edc3b131..5627aee47 100644 --- a/fastly/block_fastly_service_logging_scalyr_test.go +++ b/fastly/block_fastly_service_logging_scalyr_test.go @@ -102,7 +102,7 @@ func TestAccFastlyServiceVCL_scalyrlogging_basic(t *testing.T) { { Config: testAccServiceVCLScalyrConfig(name, domain), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_vcl.foo", &service), + testAccCheckServiceExists("fastly_service_vcl.foo", &service), testAccCheckFastlyServiceVCLScalyrAttributes(&service, []*gofastly.Scalyr{&log1}, ServiceTypeVCL), resource.TestCheckResourceAttr( "fastly_service_vcl.foo", "name", name), @@ -114,7 +114,7 @@ func TestAccFastlyServiceVCL_scalyrlogging_basic(t *testing.T) { { Config: testAccServiceVCLScalyrConfigUpdate(name, domain), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_vcl.foo", &service), + testAccCheckServiceExists("fastly_service_vcl.foo", &service), testAccCheckFastlyServiceVCLScalyrAttributes(&service, []*gofastly.Scalyr{&log1AfterUpdate, &log2}, ServiceTypeVCL), resource.TestCheckResourceAttr( "fastly_service_vcl.foo", "name", name), @@ -148,7 +148,7 @@ func TestAccFastlyServiceVCL_scalyrlogging_basic_compute(t *testing.T) { { Config: testAccServiceVCLScalyrComputeConfig(name, domain), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_compute.foo", &service), + testAccCheckServiceExists("fastly_service_compute.foo", &service), testAccCheckFastlyServiceVCLScalyrAttributes(&service, []*gofastly.Scalyr{&log1}, ServiceTypeCompute), resource.TestCheckResourceAttr( "fastly_service_compute.foo", "name", name), diff --git a/fastly/block_fastly_service_logging_sftp_test.go b/fastly/block_fastly_service_logging_sftp_test.go index 83fc32813..72454cb59 100644 --- a/fastly/block_fastly_service_logging_sftp_test.go +++ b/fastly/block_fastly_service_logging_sftp_test.go @@ -160,7 +160,7 @@ func TestAccFastlyServiceVCL_logging_sftp_basic(t *testing.T) { { Config: testAccServiceVCLSFTPConfig(name, domain), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_vcl.foo", &service), + testAccCheckServiceExists("fastly_service_vcl.foo", &service), testAccCheckFastlyServiceVCLSFTPAttributes(&service, []*gofastly.SFTP{&log1}, ServiceTypeVCL), resource.TestCheckResourceAttr( "fastly_service_vcl.foo", "name", name), @@ -172,7 +172,7 @@ func TestAccFastlyServiceVCL_logging_sftp_basic(t *testing.T) { { Config: testAccServiceVCLSFTPConfigUpdate(name, domain), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_vcl.foo", &service), + testAccCheckServiceExists("fastly_service_vcl.foo", &service), testAccCheckFastlyServiceVCLSFTPAttributes(&service, []*gofastly.SFTP{&log1AfterUpdate, &log2}, ServiceTypeVCL), resource.TestCheckResourceAttr( "fastly_service_vcl.foo", "name", name), @@ -220,7 +220,7 @@ func TestAccFastlyServiceVCL_logging_sftp_basic_compute(t *testing.T) { { Config: testAccServiceVCLSFTPComputeConfig(name, domain), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_compute.foo", &service), + testAccCheckServiceExists("fastly_service_compute.foo", &service), testAccCheckFastlyServiceVCLSFTPAttributes(&service, []*gofastly.SFTP{&log1}, ServiceTypeCompute), resource.TestCheckResourceAttr("fastly_service_compute.foo", "name", name), resource.TestCheckResourceAttr("fastly_service_compute.foo", "logging_sftp.#", "1"), diff --git a/fastly/block_fastly_service_logging_splunk_test.go b/fastly/block_fastly_service_logging_splunk_test.go index 645b985a7..5bb375b0e 100644 --- a/fastly/block_fastly_service_logging_splunk_test.go +++ b/fastly/block_fastly_service_logging_splunk_test.go @@ -123,7 +123,7 @@ func TestAccFastlyServiceVCL_splunk_basic(t *testing.T) { { Config: testAccServiceVCLSplunkConfigBasic(serviceName), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_vcl.foo", &service), + testAccCheckServiceExists("fastly_service_vcl.foo", &service), testAccCheckFastlyServiceVCLSplunkAttributes(&service, []*gofastly.Splunk{&splunkLogOne}, ServiceTypeVCL), resource.TestCheckResourceAttr("fastly_service_vcl.foo", "name", serviceName), resource.TestCheckResourceAttr("fastly_service_vcl.foo", "logging_splunk.#", "1"), @@ -133,7 +133,7 @@ func TestAccFastlyServiceVCL_splunk_basic(t *testing.T) { { Config: testAccServiceVCLSplunkConfigUpdate(serviceName), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_vcl.foo", &service), + testAccCheckServiceExists("fastly_service_vcl.foo", &service), testAccCheckFastlyServiceVCLSplunkAttributes(&service, []*gofastly.Splunk{&splunkLogOneUpdated, &splunkLogTwo}, ServiceTypeVCL), resource.TestCheckResourceAttr("fastly_service_vcl.foo", "name", serviceName), resource.TestCheckResourceAttr("fastly_service_vcl.foo", "logging_splunk.#", "2"), @@ -163,7 +163,7 @@ func TestAccFastlyServiceVCL_splunk_basic_compute(t *testing.T) { { Config: testAccServiceVCLSplunkConfigComputeBasic(serviceName), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_compute.foo", &service), + testAccCheckServiceExists("fastly_service_compute.foo", &service), testAccCheckFastlyServiceVCLSplunkAttributes(&service, []*gofastly.Splunk{&splunkLogOne}, ServiceTypeCompute), resource.TestCheckResourceAttr( "fastly_service_compute.foo", "name", serviceName), @@ -197,7 +197,7 @@ func TestAccFastlyServiceVCL_splunk_default(t *testing.T) { { Config: testAccServiceVCLSplunkConfigDefault(serviceName), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_vcl.foo", &service), + testAccCheckServiceExists("fastly_service_vcl.foo", &service), testAccCheckFastlyServiceVCLSplunkAttributes(&service, []*gofastly.Splunk{&splunkLog}, ServiceTypeVCL), resource.TestCheckResourceAttr("fastly_service_vcl.foo", "name", serviceName), resource.TestCheckResourceAttr("fastly_service_vcl.foo", "logging_splunk.#", "1"), @@ -283,7 +283,7 @@ func TestAccFastlyServiceVCL_splunk_complete(t *testing.T) { { Config: testAccServiceVCLSplunkConfigUseTLS(serviceName, cert, key), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_vcl.foo", &service), + testAccCheckServiceExists("fastly_service_vcl.foo", &service), testAccCheckFastlyServiceVCLSplunkAttributes(&service, []*gofastly.Splunk{&splunkLogOne}, ServiceTypeVCL), resource.TestCheckResourceAttr( "fastly_service_vcl.foo", "name", serviceName), @@ -295,7 +295,7 @@ func TestAccFastlyServiceVCL_splunk_complete(t *testing.T) { { Config: testAccServiceVCLSplunkConfigUpdateUseTLS(serviceName, cert, key), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_vcl.foo", &service), + testAccCheckServiceExists("fastly_service_vcl.foo", &service), testAccCheckFastlyServiceVCLSplunkAttributes(&service, []*gofastly.Splunk{&splunkLogOneUpdated, &splunkLogTwo}, ServiceTypeVCL), resource.TestCheckResourceAttr( "fastly_service_vcl.foo", "name", serviceName), diff --git a/fastly/block_fastly_service_logging_sumologic_test.go b/fastly/block_fastly_service_logging_sumologic_test.go index d728ece4d..70885dafc 100644 --- a/fastly/block_fastly_service_logging_sumologic_test.go +++ b/fastly/block_fastly_service_logging_sumologic_test.go @@ -78,7 +78,7 @@ func TestAccFastlyServiceVCL_sumologic(t *testing.T) { { Config: testAccServiceVCLConfigSumologic(name, domainName, backendName, s), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_vcl.foo", &service), + testAccCheckServiceExists("fastly_service_vcl.foo", &service), testAccCheckFastlyServiceVCLAttributesSumologic(&service, name, s, ServiceTypeVCL), resource.TestCheckResourceAttr( "fastly_service_vcl.foo", "name", name), @@ -89,7 +89,7 @@ func TestAccFastlyServiceVCL_sumologic(t *testing.T) { { Config: testAccServiceVCLConfigSumologic(name, domainName, backendName, sn), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_vcl.foo", &service), + testAccCheckServiceExists("fastly_service_vcl.foo", &service), testAccCheckFastlyServiceVCLAttributesSumologic(&service, name, sn, ServiceTypeVCL), resource.TestCheckResourceAttr( "fastly_service_vcl.foo", "name", name), @@ -122,7 +122,7 @@ func TestAccFastlyServiceVCL_sumologic_compute(t *testing.T) { { Config: testAccServiceVCLConfigSumologicCompute(name, domainName, backendName, s), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_compute.foo", &service), + testAccCheckServiceExists("fastly_service_compute.foo", &service), testAccCheckFastlyServiceVCLAttributesSumologic(&service, name, s, ServiceTypeCompute), resource.TestCheckResourceAttr( "fastly_service_compute.foo", "name", name), diff --git a/fastly/block_fastly_service_logging_syslog_test.go b/fastly/block_fastly_service_logging_syslog_test.go index 82b545c3f..8503f24b7 100644 --- a/fastly/block_fastly_service_logging_syslog_test.go +++ b/fastly/block_fastly_service_logging_syslog_test.go @@ -121,7 +121,7 @@ func TestAccFastlyServiceVCL_syslog_basic(t *testing.T) { { Config: testAccServiceVCLSyslogConfig(name, domainName1), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_vcl.foo", &service), + testAccCheckServiceExists("fastly_service_vcl.foo", &service), testAccCheckFastlyServiceVCLSyslogAttributes(&service, []*gofastly.Syslog{&log1}, ServiceTypeVCL), resource.TestCheckResourceAttr( "fastly_service_vcl.foo", "name", name), @@ -133,7 +133,7 @@ func TestAccFastlyServiceVCL_syslog_basic(t *testing.T) { { Config: testAccServiceVCLSyslogConfigUpdate(name, domainName1), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_vcl.foo", &service), + testAccCheckServiceExists("fastly_service_vcl.foo", &service), testAccCheckFastlyServiceVCLSyslogAttributes(&service, []*gofastly.Syslog{&log1AfterUpdate, &log2}, ServiceTypeVCL), resource.TestCheckResourceAttr( "fastly_service_vcl.foo", "name", name), @@ -169,7 +169,7 @@ func TestAccFastlyServiceVCL_syslog_basic_compute(t *testing.T) { { Config: testAccServiceVCLSyslogComputeConfig(name, domainName1), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_compute.foo", &service), + testAccCheckServiceExists("fastly_service_compute.foo", &service), testAccCheckFastlyServiceVCLSyslogAttributes(&service, []*gofastly.Syslog{&log1}, ServiceTypeCompute), resource.TestCheckResourceAttr( "fastly_service_compute.foo", "name", name), @@ -207,7 +207,7 @@ func TestAccFastlyServiceVCL_syslog_formatVersion(t *testing.T) { { Config: testAccServiceVCLSyslogConfigFormatVersion(name, domainName1), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_vcl.foo", &service), + testAccCheckServiceExists("fastly_service_vcl.foo", &service), testAccCheckFastlyServiceVCLSyslogAttributes(&service, []*gofastly.Syslog{&log1}, ServiceTypeVCL), resource.TestCheckResourceAttr( "fastly_service_vcl.foo", "name", name), @@ -260,7 +260,7 @@ func TestAccFastlyServiceVCL_syslog_useTLS(t *testing.T) { { Config: testAccServiceVCLSyslogConfigUseTLS(name, domainName1), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_vcl.foo", &service), + testAccCheckServiceExists("fastly_service_vcl.foo", &service), testAccCheckFastlyServiceVCLSyslogAttributes(&service, []*gofastly.Syslog{&log1}, ServiceTypeVCL), resource.TestCheckResourceAttr("fastly_service_vcl.foo", "name", name), resource.TestCheckResourceAttr("fastly_service_vcl.foo", "logging_syslog.#", "1"), diff --git a/fastly/block_fastly_service_package_test.go b/fastly/block_fastly_service_package_test.go index 92f72ccf2..407a16f31 100644 --- a/fastly/block_fastly_service_package_test.go +++ b/fastly/block_fastly_service_package_test.go @@ -51,7 +51,7 @@ func TestAccFastlyServiceVCL_package_basic(t *testing.T) { { Config: testAccServiceVCLPackageConfig(name01, domain01), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_compute.foo", &service), + testAccCheckServiceExists("fastly_service_compute.foo", &service), testAccCheckFastlyServiceVCLPackageAttributes(&service, &want), resource.TestCheckResourceAttr("fastly_service_compute.foo", "name", name01), resource.TestCheckResourceAttr("fastly_service_compute.foo", "package.#", "1"), @@ -60,7 +60,7 @@ func TestAccFastlyServiceVCL_package_basic(t *testing.T) { { Config: testAccServiceVCLPackageConfig(name02, domain02), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_compute.foo", &service), + testAccCheckServiceExists("fastly_service_compute.foo", &service), testAccCheckFastlyServiceVCLPackageAttributes(&service, &want), resource.TestCheckResourceAttr("fastly_service_compute.foo", "name", name02), resource.TestCheckResourceAttr("fastly_service_compute.foo", "package.#", "1"), @@ -70,7 +70,7 @@ func TestAccFastlyServiceVCL_package_basic(t *testing.T) { { Config: testAccServiceVCLPackageConfigNew(name02, domain02), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_compute.foo", &service), + testAccCheckServiceExists("fastly_service_compute.foo", &service), testAccCheckFastlyServiceVCLPackageAttributes(&service, &want2), resource.TestCheckResourceAttr("fastly_service_compute.foo", "name", name02), resource.TestCheckResourceAttr("fastly_service_compute.foo", "package.#", "1"), @@ -126,7 +126,7 @@ func TestAccFastlyServiceVCL_package_content(t *testing.T) { { Config: testAccServiceVCLPackageConfigContent(name01, domain01, b64Content), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_compute.foo", &service), + testAccCheckServiceExists("fastly_service_compute.foo", &service), testAccCheckFastlyServiceVCLPackageAttributes(&service, &want), resource.TestCheckResourceAttr("fastly_service_compute.foo", "name", name01), resource.TestCheckResourceAttr("fastly_service_compute.foo", "package.#", "1"), @@ -135,7 +135,7 @@ func TestAccFastlyServiceVCL_package_content(t *testing.T) { { Config: testAccServiceVCLPackageConfigContent(name02, domain02, b64Content), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_compute.foo", &service), + testAccCheckServiceExists("fastly_service_compute.foo", &service), testAccCheckFastlyServiceVCLPackageAttributes(&service, &want), resource.TestCheckResourceAttr("fastly_service_compute.foo", "name", name02), resource.TestCheckResourceAttr("fastly_service_compute.foo", "package.#", "1"), @@ -145,7 +145,7 @@ func TestAccFastlyServiceVCL_package_content(t *testing.T) { { Config: testAccServiceVCLPackageConfigContent(name02, domain02, b64Content2), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_compute.foo", &service), + testAccCheckServiceExists("fastly_service_compute.foo", &service), testAccCheckFastlyServiceVCLPackageAttributes(&service, &want2), resource.TestCheckResourceAttr("fastly_service_compute.foo", "name", name02), resource.TestCheckResourceAttr("fastly_service_compute.foo", "package.#", "1"), diff --git a/fastly/block_fastly_service_product_enablement_test.go b/fastly/block_fastly_service_product_enablement_test.go index 2f712a54d..b62e4533f 100644 --- a/fastly/block_fastly_service_product_enablement_test.go +++ b/fastly/block_fastly_service_product_enablement_test.go @@ -74,7 +74,7 @@ func TestAccFastlyServiceVCLProductEnablement_basic(t *testing.T) { { Config: config, Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_vcl.foo", &service), + testAccCheckServiceExists("fastly_service_vcl.foo", &service), resource.TestCheckResourceAttr("fastly_service_vcl.foo", "name", serviceName), resource.TestCheckResourceAttr("fastly_service_vcl.foo", "backend.#", "1"), testAccCheckFastlyServiceVCLBackendAttributes(&service, []*gofastly.Backend{&b1}), diff --git a/fastly/block_fastly_service_ratelimiter_test.go b/fastly/block_fastly_service_ratelimiter_test.go index 527ac7869..0a1c9dce5 100644 --- a/fastly/block_fastly_service_ratelimiter_test.go +++ b/fastly/block_fastly_service_ratelimiter_test.go @@ -151,7 +151,7 @@ func TestAccFastlyServiceVCLRateLimiter_basic(t *testing.T) { { Config: testAccServiceVCLRateLimiter(serviceName, domainName, rateLimiterName), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_vcl.foo", &service), + testAccCheckServiceExists("fastly_service_vcl.foo", &service), resource.TestCheckResourceAttr("fastly_service_vcl.foo", "name", serviceName), resource.TestCheckResourceAttr("fastly_service_vcl.foo", "rate_limiter.#", "1"), testAccCheckFastlyServiceVCLRateLimiterAttributes(&service, []*gofastly.ERL{&erl1}), @@ -161,7 +161,7 @@ func TestAccFastlyServiceVCLRateLimiter_basic(t *testing.T) { { Config: testAccServiceVCLRateLimiterUpdate(serviceName, domainName, rateLimiterName), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_vcl.foo", &service), + testAccCheckServiceExists("fastly_service_vcl.foo", &service), resource.TestCheckResourceAttr("fastly_service_vcl.foo", "rate_limiter.#", "2"), testAccCheckFastlyServiceVCLRateLimiterAttributes(&service, []*gofastly.ERL{&erl1, &erl2}), ), diff --git a/fastly/block_fastly_service_requestsetting_test.go b/fastly/block_fastly_service_requestsetting_test.go index b41759f8b..c05c87e3d 100644 --- a/fastly/block_fastly_service_requestsetting_test.go +++ b/fastly/block_fastly_service_requestsetting_test.go @@ -83,7 +83,7 @@ func TestAccFastlyServiceVCLRequestSetting_basic(t *testing.T) { { Config: testAccServiceVCLRequestSetting(name, domainName1, "90"), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_vcl.foo", &service), + testAccCheckServiceExists("fastly_service_vcl.foo", &service), testAccCheckFastlyServiceVCLRequestSettingsAttributes(&service, []*gofastly.RequestSetting{&rq1}), resource.TestCheckResourceAttr( "fastly_service_vcl.foo", "name", name), @@ -96,7 +96,7 @@ func TestAccFastlyServiceVCLRequestSetting_basic(t *testing.T) { { Config: testAccServiceVCLRequestSetting(name, domainName1, "900"), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_vcl.foo", &service), + testAccCheckServiceExists("fastly_service_vcl.foo", &service), testAccCheckFastlyServiceVCLRequestSettingsAttributes(&service, []*gofastly.RequestSetting{&rq2}), resource.TestCheckResourceAttr( "fastly_service_vcl.foo", "name", name), diff --git a/fastly/block_fastly_service_resource_link.go b/fastly/block_fastly_service_resource_link.go new file mode 100644 index 000000000..e1ccf1b9f --- /dev/null +++ b/fastly/block_fastly_service_resource_link.go @@ -0,0 +1,162 @@ +package fastly + +import ( + "context" + "log" + + gofastly "github.com/fastly/go-fastly/v8/fastly" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" +) + +// ResourceLinkServiceAttributeHandler provides a base implementation for ServiceAttributeDefinition. +type ResourceLinkServiceAttributeHandler struct { + *DefaultServiceAttributeHandler +} + +// NewServiceResourceLink returns a new resource. +func NewServiceResourceLink(sa ServiceMetadata) ServiceAttributeDefinition { + return ToServiceAttributeDefinition(&ResourceLinkServiceAttributeHandler{ + &DefaultServiceAttributeHandler{ + key: "resource_link", + serviceMetadata: sa, + }, + }) +} + +// Key returns the resource key. +func (h *ResourceLinkServiceAttributeHandler) Key() string { + return h.key +} + +// GetSchema returns the resource schema. +func (h *ResourceLinkServiceAttributeHandler) GetSchema() *schema.Schema { + return &schema.Schema{ + Type: schema.TypeSet, + Optional: true, + Description: "A resource link represents a link between a shared resource (such as an KV Store or Config Store) and a service version.", + Elem: &schema.Resource{ + Schema: map[string]*schema.Schema{ + "link_id": { + Type: schema.TypeString, + Computed: true, + Description: "An alphanumeric string identifying the resource link.", + }, + "name": { + Type: schema.TypeString, + Required: true, + Description: "The name of the resource link.", + }, + "resource_id": { + Type: schema.TypeString, + Required: true, + Description: "The ID of the underlying linked resource.", + }, + }, + }, + } +} + +// Create creates the resource. +func (h *ResourceLinkServiceAttributeHandler) Create(_ context.Context, d *schema.ResourceData, resource map[string]any, serviceVersion int, conn *gofastly.Client) error { + input := &gofastly.CreateResourceInput{ + ServiceID: d.Id(), + ServiceVersion: serviceVersion, + Name: gofastly.String(resource["name"].(string)), + ResourceID: gofastly.String(resource["resource_id"].(string)), + } + + log.Printf("[DEBUG] CREATE: Resource Links input: %#v", input) + + _, err := conn.CreateResource(input) + if err != nil { + return err + } + + return nil +} + +// Read refreshes the resource. +func (h *ResourceLinkServiceAttributeHandler) Read(_ context.Context, d *schema.ResourceData, _ map[string]any, serviceVersion int, conn *gofastly.Client) error { + localState := d.Get(h.GetKey()).(*schema.Set).List() + + if len(localState) > 0 || d.Get("imported").(bool) || d.Get("force_refresh").(bool) { + input := &gofastly.ListResourcesInput{ + ServiceID: d.Id(), + ServiceVersion: serviceVersion, + } + + log.Printf("[DEBUG] REFRESH: Resource Links input: %#v", input) + + remoteState, err := conn.ListResources(input) + if err != nil { + return err + } + + data := flattenResourceLinks(remoteState) + if err := d.Set(h.GetKey(), data); err != nil { + log.Printf("[WARN] REFRESH: Error setting Resource Links for Service ID '%s': %s", d.Id(), err) + } + } + + return nil +} + +// Update updates the resource. +func (h *ResourceLinkServiceAttributeHandler) Update(_ context.Context, d *schema.ResourceData, resource, modified map[string]any, serviceVersion int, conn *gofastly.Client) error { + input := &gofastly.UpdateResourceInput{ + ID: resource["link_id"].(string), + Name: gofastly.String(resource["name"].(string)), + ServiceID: d.Id(), + ServiceVersion: serviceVersion, + } + + log.Printf("[DEBUG] UPDATE: Resource Links input: %#v", input) + + _, err := conn.UpdateResource(input) + if err != nil { + return err + } + + return nil +} + +// Delete deletes the resource. +func (h *ResourceLinkServiceAttributeHandler) Delete(_ context.Context, d *schema.ResourceData, resource map[string]any, serviceVersion int, conn *gofastly.Client) error { + input := &gofastly.DeleteResourceInput{ + ID: resource["link_id"].(string), + ServiceID: d.Id(), + ServiceVersion: serviceVersion, + } + + log.Printf("[DEBUG] DELETE: Resource Links input: %#v", input) + + err := conn.DeleteResource(input) + if err != nil { + if errRes, ok := err.(*gofastly.HTTPError); ok { + // If error is because the resource looks to already be deleted (i.e. 404), + // then skip returning the error and allow it to fail silently. + if errRes.StatusCode != 404 { + return err + } + } + } + + return err +} + +// flattenResourceLinks models data into format suitable for saving to Terraform state. +func flattenResourceLinks(remoteState []*gofastly.Resource) []map[string]any { + result := make([]map[string]any, 0, len(remoteState)) + + for _, resource := range remoteState { + data := map[string]any{ + "link_id": resource.ID, + "name": resource.Name, + "resource_id": resource.ResourceID, + } + + result = append(result, data) + } + + return result +} diff --git a/fastly/block_fastly_service_responseobject_test.go b/fastly/block_fastly_service_responseobject_test.go index 0826de8ca..f4725d6ee 100644 --- a/fastly/block_fastly_service_responseobject_test.go +++ b/fastly/block_fastly_service_responseobject_test.go @@ -88,7 +88,7 @@ func TestAccFastlyServiceVCL_response_object_basic(t *testing.T) { { Config: testAccServiceVCLResponseObjectConfig(name, domainName1), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_vcl.foo", &service), + testAccCheckServiceExists("fastly_service_vcl.foo", &service), testAccCheckFastlyServiceVCLResponseObjectAttributes(&service, []*gofastly.ResponseObject{&log1}), resource.TestCheckResourceAttr( "fastly_service_vcl.foo", "name", name), @@ -100,7 +100,7 @@ func TestAccFastlyServiceVCL_response_object_basic(t *testing.T) { { Config: testAccServiceVCLResponseObjectConfigUpdate(name, domainName1), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_vcl.foo", &service), + testAccCheckServiceExists("fastly_service_vcl.foo", &service), testAccCheckFastlyServiceVCLResponseObjectAttributes(&service, []*gofastly.ResponseObject{&log1, &log2}), resource.TestCheckResourceAttr( "fastly_service_vcl.foo", "name", name), diff --git a/fastly/block_fastly_service_snippet_test.go b/fastly/block_fastly_service_snippet_test.go index 9fd5991da..ed63355b9 100644 --- a/fastly/block_fastly_service_snippet_test.go +++ b/fastly/block_fastly_service_snippet_test.go @@ -92,7 +92,7 @@ func TestAccFastlyServiceVCLSnippet_basic(t *testing.T) { { Config: testAccServiceVCLSnippet(name, domainName1), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_vcl.foo", &service), + testAccCheckServiceExists("fastly_service_vcl.foo", &service), testAccCheckFastlyServiceVCLSnippetAttributes(&service, []*gofastly.Snippet{&s1}), resource.TestCheckResourceAttr("fastly_service_vcl.foo", "name", name), resource.TestCheckResourceAttr("fastly_service_vcl.foo", "snippet.#", "1"), @@ -107,7 +107,7 @@ func TestAccFastlyServiceVCLSnippet_basic(t *testing.T) { { Config: testAccServiceVCLSnippetUpdate(name, domainName1), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_vcl.foo", &service), + testAccCheckServiceExists("fastly_service_vcl.foo", &service), testAccCheckFastlyServiceVCLSnippetAttributes(&service, []*gofastly.Snippet{&updatedS1, &updatedS2}), resource.TestCheckResourceAttr("fastly_service_vcl.foo", "snippet.#", "2"), resource.TestCheckTypeSetElemNestedAttrs("fastly_service_vcl.foo", "snippet.*", map[string]string{ diff --git a/fastly/block_fastly_service_vcl_test.go b/fastly/block_fastly_service_vcl_test.go index a7da9bd38..423c5f0f4 100644 --- a/fastly/block_fastly_service_vcl_test.go +++ b/fastly/block_fastly_service_vcl_test.go @@ -58,7 +58,7 @@ func TestAccFastlyServiceVCL_VCL_basic(t *testing.T) { { Config: testAccServiceVCLVCLConfig(name, domainName1, backendName), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_vcl.foo", &service), + testAccCheckServiceExists("fastly_service_vcl.foo", &service), testAccCheckFastlyServiceVCLVCLAttributes(&service, name, 1), resource.TestCheckResourceAttr( "fastly_service_vcl.foo", "name", name), @@ -70,7 +70,7 @@ func TestAccFastlyServiceVCL_VCL_basic(t *testing.T) { { Config: testAccServiceVCLVCLConfigUpdate(name, domainName1, backendName), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_vcl.foo", &service), + testAccCheckServiceExists("fastly_service_vcl.foo", &service), testAccCheckFastlyServiceVCLVCLAttributes(&service, name, 2), resource.TestCheckResourceAttr( "fastly_service_vcl.foo", "name", name), diff --git a/fastly/block_fastly_service_waf_test.go b/fastly/block_fastly_service_waf_test.go index 06301a7fd..262f69e06 100644 --- a/fastly/block_fastly_service_waf_test.go +++ b/fastly/block_fastly_service_waf_test.go @@ -77,7 +77,7 @@ func TestAccFastlyServiceVCLWAF_Add(t *testing.T) { { Config: testAccServiceVCLWAF(name, "", waf, ""), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists(serviceRef, &service), + testAccCheckServiceExists(serviceRef, &service), testAccCheckFastlyServiceVCLAttributesWAF(&service, response, condition), ), }, @@ -100,20 +100,20 @@ func TestAccFastlyServiceVCLWAF_AddAndRemove(t *testing.T) { { Config: testAccServiceVCLWAF(name, "", "", ""), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists(serviceRef, &service), + testAccCheckServiceExists(serviceRef, &service), ), }, { Config: testAccServiceVCLWAF(name, "", waf, ""), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists(serviceRef, &service), + testAccCheckServiceExists(serviceRef, &service), testAccCheckFastlyServiceVCLAttributesWAF(&service, response, condition), ), }, { Config: testAccServiceVCLWAF(name, "", "", ""), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists(serviceRef, &service), + testAccCheckServiceExists(serviceRef, &service), testAccCheckFastlyServiceVCLDeletedWAF(&service), ), }, @@ -138,14 +138,14 @@ func TestAccFastlyServiceVCLWAF_UpdateResponse(t *testing.T) { { Config: testAccServiceVCLWAF(name, "", waf, ""), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists(serviceRef, &service), + testAccCheckServiceExists(serviceRef, &service), testAccCheckFastlyServiceVCLAttributesWAF(&service, response, condition), ), }, { Config: testAccServiceVCLWAF(name, extraResponse, updatedWaf, ""), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists(serviceRef, &service), + testAccCheckServiceExists(serviceRef, &service), testAccCheckFastlyServiceVCLAttributesWAF(&service, updateResponse, condition), ), }, @@ -170,14 +170,14 @@ func TestAccFastlyServiceVCLWAF_UpdateCondition(t *testing.T) { { Config: testAccServiceVCLWAF(name, "", waf, ""), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists(serviceRef, &service), + testAccCheckServiceExists(serviceRef, &service), testAccCheckFastlyServiceVCLAttributesWAF(&service, response, condition), ), }, { Config: testAccServiceVCLWAF(name, extraCondition, updatedWaf, ""), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists(serviceRef, &service), + testAccCheckServiceExists(serviceRef, &service), testAccCheckFastlyServiceVCLAttributesWAF(&service, response, updatedCondition), ), }, diff --git a/fastly/block_fastly_waf_configuration_active_rule_test.go b/fastly/block_fastly_waf_configuration_active_rule_test.go index b74ecaac2..b8a0c8769 100644 --- a/fastly/block_fastly_waf_configuration_active_rule_test.go +++ b/fastly/block_fastly_waf_configuration_active_rule_test.go @@ -109,14 +109,14 @@ func TestAccFastlyServiceWAFVersionV1_AddUpdateDeleteRules(t *testing.T) { { Config: testAccFastlyServiceWAFVersionV1(name, wafVer1), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists(serviceRef, &service), + testAccCheckServiceExists(serviceRef, &service), testAccCheckFastlyServiceWAFVersionV1CheckRules(&service, rules1, 1), ), }, { Config: testAccFastlyServiceWAFVersionV1(name, wafVer2), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists(serviceRef, &service), + testAccCheckServiceExists(serviceRef, &service), testAccCheckFastlyServiceWAFVersionV1CheckRules(&service, rules2, 2), ), }, diff --git a/fastly/block_fastly_waf_configuration_exclusion_test.go b/fastly/block_fastly_waf_configuration_exclusion_test.go index d6f26bda6..ce6142bce 100644 --- a/fastly/block_fastly_waf_configuration_exclusion_test.go +++ b/fastly/block_fastly_waf_configuration_exclusion_test.go @@ -256,14 +256,14 @@ func TestAccFastlyServiceWAFVersionV1_AddUpdateDeleteExclusions(t *testing.T) { { Config: testAccFastlyServiceWAFVersionV1(name, wafVer1), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists(serviceRef, &service), + testAccCheckServiceExists(serviceRef, &service), testAccCheckFastlyServiceWAFVersionV1CheckExclusions(&service, exclusions1, 1), ), }, { Config: testAccFastlyServiceWAFVersionV1(name, wafVer2), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists(serviceRef, &service), + testAccCheckServiceExists(serviceRef, &service), testAccCheckFastlyServiceWAFVersionV1CheckExclusions(&service, exclusions2, 2), ), }, diff --git a/fastly/provider.go b/fastly/provider.go index a9aeff0f3..7680139c2 100644 --- a/fastly/provider.go +++ b/fastly/provider.go @@ -65,6 +65,7 @@ func Provider() *schema.Provider { "fastly_waf_rules": dataSourceFastlyWAFRules(), }, ResourcesMap: map[string]*schema.Resource{ + "fastly_kvstore": resourceFastlyKVStore(), "fastly_service_acl_entries": resourceServiceACLEntries(), "fastly_service_authorization": resourceServiceAuthorization(), "fastly_service_compute": resourceServiceCompute(), diff --git a/fastly/resource_fastly_kvstore.go b/fastly/resource_fastly_kvstore.go new file mode 100644 index 000000000..3ca541a60 --- /dev/null +++ b/fastly/resource_fastly_kvstore.go @@ -0,0 +1,152 @@ +package fastly + +import ( + "context" + "fmt" + "log" + "sort" + + gofastly "github.com/fastly/go-fastly/v8/fastly" + "github.com/hashicorp/terraform-plugin-sdk/v2/diag" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema" +) + +func resourceFastlyKVStore() *schema.Resource { + return &schema.Resource{ + CreateContext: resourceFastlyKVStoreCreate, + ReadContext: resourceFastlyKVStoreRead, + UpdateContext: resourceFastlyKVStoreUpdate, + DeleteContext: resourceFastlyKVStoreDelete, + Importer: &schema.ResourceImporter{ + StateContext: schema.ImportStatePassthroughContext, + }, + Schema: map[string]*schema.Schema{ + "force_destroy": { + Type: schema.TypeBool, + Default: false, + Optional: true, + Description: "Allow the KV store to be deleted, even if it contains entries. Defaults to false.", + }, + "name": { + Type: schema.TypeString, + Required: true, + Description: "A unique name to identify the KV Store. It is important to note that changing this attribute will delete and recreate the KV Store, and discard the current entries.", + ForceNew: true, + }, + }, + } +} + +func resourceFastlyKVStoreCreate(_ context.Context, d *schema.ResourceData, meta any) diag.Diagnostics { + conn := meta.(*APIClient).conn + + input := &gofastly.CreateKVStoreInput{ + Name: d.Get("name").(string), + } + + log.Printf("[DEBUG] CREATE: KV Store input: %#v", input) + + store, err := conn.CreateKVStore(input) + if err != nil { + return diag.FromErr(err) + } + + // NOTE: `id` is exposed as a read-only attribute. + d.SetId(store.ID) + + return nil +} + +func resourceFastlyKVStoreRead(_ context.Context, d *schema.ResourceData, meta any) diag.Diagnostics { + conn := meta.(*APIClient).conn + + input := &gofastly.GetKVStoreInput{ + ID: d.Id(), + } + + log.Printf("[DEBUG] REFRESH: KV Store input: %#v", input) + + store, err := conn.GetKVStore(input) + if err != nil { + log.Printf("[WARN] No KV Store found '%s'", d.Id()) + d.SetId("") + return diag.FromErr(err) + } + + err = d.Set("name", store.Name) + if err != nil { + return diag.FromErr(err) + } + + return nil +} + +// NOTE: There is no UPDATE endpoint for KV Stores. +func resourceFastlyKVStoreUpdate(_ context.Context, _ *schema.ResourceData, _ any) diag.Diagnostics { + return nil +} + +func resourceFastlyKVStoreDelete(_ context.Context, d *schema.ResourceData, meta any) diag.Diagnostics { + conn := meta.(*APIClient).conn + + if !d.Get("force_destroy").(bool) { + mayDelete, err := isKVStoreEmpty(d.Id(), conn) + if err != nil { + return diag.FromErr(err) + } + + if !mayDelete { + return diag.FromErr(fmt.Errorf("cannot delete KV Store (%s), it is not empty. Either delete the entries first, or set force_destroy to true and apply it before making this change", d.Id())) + } + } + + // IMPORTANT: We must delete all keys first before we can delete the store. + p := conn.NewListKVStoreKeysPaginator(&gofastly.ListKVStoreKeysInput{ + ID: d.Id(), + }) + for p.Next() { + keys := p.Keys() + sort.Strings(keys) + for _, key := range keys { + err := conn.DeleteKVStoreKey(&gofastly.DeleteKVStoreKeyInput{ + ID: d.Id(), + Key: key, + }) + if err != nil { + return diag.FromErr(fmt.Errorf("error during KV Store key cleanup: %w", err)) + } + } + } + if err := p.Err(); err != nil { + return diag.FromErr(fmt.Errorf("error during KV Store cleanup pagination: %w", err)) + } + + input := gofastly.DeleteKVStoreInput{ + ID: d.Id(), + } + + log.Printf("[DEBUG] DELETE: KV Store input: %#v", input) + + err := conn.DeleteKVStore(&input) + if err != nil { + if errRes, ok := err.(*gofastly.HTTPError); ok { + // If error is because the resource looks to already be deleted (i.e. 404), + // then skip returning the error and allow it to fail silently. + if errRes.StatusCode != 404 { + return diag.FromErr(err) + } + } + } + + return diag.FromErr(err) +} + +func isKVStoreEmpty(storeID string, conn *gofastly.Client) (bool, error) { + keys, err := conn.ListKVStoreKeys(&gofastly.ListKVStoreKeysInput{ + ID: storeID, + }) + if err != nil { + return false, err + } + return len(keys.Data) == 0, nil +} diff --git a/fastly/resource_fastly_kvstore_test.go b/fastly/resource_fastly_kvstore_test.go new file mode 100644 index 000000000..00807e637 --- /dev/null +++ b/fastly/resource_fastly_kvstore_test.go @@ -0,0 +1,212 @@ +package fastly + +import ( + "fmt" + "testing" + + gofastly "github.com/fastly/go-fastly/v8/fastly" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/acctest" + "github.com/hashicorp/terraform-plugin-sdk/v2/helper/resource" + "github.com/hashicorp/terraform-plugin-sdk/v2/terraform" +) + +func TestAccFastlyKVStore_validate(t *testing.T) { + var ( + kvStore gofastly.KVStore + service gofastly.ServiceDetail + ) + kvStoreName := fmt.Sprintf("KV Store %s", acctest.RandString(10)) + serviceName := fmt.Sprintf("tf-test-%s", acctest.RandString(10)) + domainName := fmt.Sprintf("fastly-test.tf-%s.com", acctest.RandString(10)) + linkName := fmt.Sprintf("resource_link_%s", acctest.RandString(10)) + + resource.ParallelTest(t, resource.TestCase{ + PreCheck: func() { + testAccPreCheck(t) + }, + ProviderFactories: testAccProviders, + CheckDestroy: testAccCheckServiceVCLDestroy, + Steps: []resource.TestStep{ + { + Config: testAccKVStoreConfig(kvStoreName, serviceName, domainName, linkName), + Check: resource.ComposeTestCheckFunc( + testAccCheckServiceExists("fastly_service_compute.example", &service), + testAccCheckFastlyKVStoreRemoteState(&service, &kvStore, serviceName, kvStoreName, linkName), + ), + }, + { + ResourceName: "fastly_kvstore.example", + ImportState: true, + ImportStateVerify: true, + // These attributes are not stored on the Fastly API and must be ignored. + ImportStateVerifyIgnore: []string{"activate", "force_destroy", "package.0.filename", "imported"}, + }, + // IMPORTANT: Add a key to the store so we can validate force delete. + { + Config: testAccKVStoreConfig(kvStoreName, serviceName, domainName, linkName), + Check: testAccAddKVStoreItems(&kvStore), // triggers side-effect of adding a KV Store key/value + }, + { + Config: testAccKVStoreConfigDeleteStep1(kvStoreName, serviceName, domainName), + }, + { + Config: testAccKVStoreConfigDeleteStep2(serviceName, domainName), + }, + }, + }) +} + +func testAccCheckFastlyKVStoreRemoteState(service *gofastly.ServiceDetail, kvStore *gofastly.KVStore, serviceName, kvStoreName, linkName string) resource.TestCheckFunc { + return func(_ *terraform.State) error { + if service.Name != serviceName { + return fmt.Errorf("bad name, expected (%s), got (%s)", serviceName, service.Name) + } + + conn := testAccProvider.Meta().(*APIClient).conn + + stores, err := conn.ListKVStores(&gofastly.ListKVStoresInput{}) + if err != nil { + return fmt.Errorf("error listing all KV Stores: %s", err) + } + + var found bool + for _, store := range stores.Data { + if store.Name == kvStoreName { + found = true + *kvStore = store + break + } + } + if !found { + return fmt.Errorf("error looking up the KV Store") + } + + links, err := conn.ListResources(&gofastly.ListResourcesInput{ + ServiceID: service.ID, + ServiceVersion: service.Version.Number, + }) + if err != nil { + return fmt.Errorf("error listing all resource links: %s", err) + } + + found = false + for _, link := range links { + if link.Name == linkName { + found = true + } + } + if !found { + return fmt.Errorf("error looking up the resource link") + } + + return nil + } +} + +func testAccKVStoreConfig(kvStoreName, serviceName, domainName, linkName string) string { + return fmt.Sprintf(` +resource "fastly_kvstore" "example" { + name = "%s" + force_destroy = true +} + +resource "fastly_service_compute" "example" { + name = "%s" + + domain { + name = "%s" + } + + package { + filename = "test_fixtures/package/valid.tar.gz" + source_code_hash = data.fastly_package_hash.example.hash + } + + resource_link { + name = "%s" + resource_id = fastly_kvstore.example.id + } + + force_destroy = true +} + +data "fastly_package_hash" "example" { + filename = "./test_fixtures/package/valid.tar.gz" +} + `, kvStoreName, serviceName, domainName, linkName) +} + +// IMPORTANT: Deleting a KV Store requires first deleting its resource_link. +// This requires a two-step `terraform apply` as we can't guarantee deletion order. +// e.g. resource_link deletion within fastly_service_compute might not finish first. +func testAccKVStoreConfigDeleteStep1(kvStoreName, serviceName, domainName string) string { + return fmt.Sprintf(` +resource "fastly_kvstore" "example" { + name = "%s" + force_destroy = true +} + +resource "fastly_service_compute" "example" { + name = "%s" + + domain { + name = "%s" + } + + package { + filename = "test_fixtures/package/valid.tar.gz" + source_code_hash = data.fastly_package_hash.example.hash + } + + force_destroy = true +} + +data "fastly_package_hash" "example" { + filename = "./test_fixtures/package/valid.tar.gz" +} + `, kvStoreName, serviceName, domainName) +} + +// Step 1 deleted the resource_link first. +// Step 2 will now delete the fastly_kvstore. +func testAccKVStoreConfigDeleteStep2(serviceName, domainName string) string { + return fmt.Sprintf(` +resource "fastly_service_compute" "example" { + name = "%s" + + domain { + name = "%s" + } + + package { + filename = "test_fixtures/package/valid.tar.gz" + source_code_hash = data.fastly_package_hash.example.hash + } + + force_destroy = true +} + +data "fastly_package_hash" "example" { + filename = "./test_fixtures/package/valid.tar.gz" +} + `, serviceName, domainName) +} + +// testAccAddKVStoreItems doesn't technically check for anything despite +// returning a TestCheckFunc. Instead it is used for its side effect of adding +// a single KV Store entry so we can later validate we're able to force delete +// the KV Store resource even though it contains data. +func testAccAddKVStoreItems(kvStore *gofastly.KVStore) resource.TestCheckFunc { + return func(_ *terraform.State) error { + conn := testAccProvider.Meta().(*APIClient).conn + err := conn.InsertKVStoreKey(&gofastly.InsertKVStoreKeyInput{ + ID: kvStore.ID, + Key: "test_key", + Value: "test_value", + }) + if err != nil { + return fmt.Errorf("error adding item to KV Store '%s': %w", kvStore.ID, err) + } + return nil + } +} diff --git a/fastly/resource_fastly_service_acl_entries_test.go b/fastly/resource_fastly_service_acl_entries_test.go index 92184927e..3c98df5ba 100644 --- a/fastly/resource_fastly_service_acl_entries_test.go +++ b/fastly/resource_fastly_service_acl_entries_test.go @@ -87,7 +87,7 @@ func TestAccFastlyServiceAclEntries_create(t *testing.T) { { Config: testAccServiceACLEntriesConfigOneACLWithEntries(serviceName, aclName, expectedRemoteEntries, true), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_vcl.foo", &service), + testAccCheckServiceExists("fastly_service_vcl.foo", &service), testAccCheckFastlyServiceACLEntriesRemoteState(&service, serviceName, aclName, expectedRemoteEntries), resource.TestCheckResourceAttr("fastly_service_acl_entries.entries", "entry.#", "1"), ), @@ -137,7 +137,7 @@ func TestAccFastlyServiceAclEntries_create_update(t *testing.T) { { Config: testAccServiceACLEntriesConfigOneACLWithEntries(serviceName, aclName, expectedRemoteEntries, true), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_vcl.foo", &service), + testAccCheckServiceExists("fastly_service_vcl.foo", &service), testAccCheckFastlyServiceACLEntriesRemoteState(&service, serviceName, aclName, expectedRemoteEntries), resource.TestCheckResourceAttr("fastly_service_acl_entries.entries", "entry.#", "1"), ), @@ -145,7 +145,7 @@ func TestAccFastlyServiceAclEntries_create_update(t *testing.T) { { Config: testAccServiceACLEntriesConfigOneACLWithEntries(serviceName, aclName, expectedRemoteEntriesAfterUpdate, true), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_vcl.foo", &service), + testAccCheckServiceExists("fastly_service_vcl.foo", &service), testAccCheckFastlyServiceACLEntriesRemoteState(&service, serviceName, aclName, expectedRemoteEntriesAfterUpdate), resource.TestCheckResourceAttr("fastly_service_acl_entries.entries", "entry.#", "1"), ), @@ -195,7 +195,7 @@ func TestAccFastlyServiceAclEntries_update_additional_fields(t *testing.T) { { Config: testAccServiceACLEntriesConfigOneACLWithEntries(serviceName, aclName, expectedRemoteEntries, true), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_vcl.foo", &service), + testAccCheckServiceExists("fastly_service_vcl.foo", &service), testAccCheckFastlyServiceACLEntriesRemoteState(&service, serviceName, aclName, expectedRemoteEntries), resource.TestCheckResourceAttr("fastly_service_acl_entries.entries", "entry.#", "1"), resource.TestCheckTypeSetElemNestedAttrs("fastly_service_acl_entries.entries", "entry.*", map[string]string{ @@ -209,7 +209,7 @@ func TestAccFastlyServiceAclEntries_update_additional_fields(t *testing.T) { { Config: testAccServiceACLEntriesConfigOneACLWithEntries(serviceName, aclName, expectedRemoteEntriesAfterUpdate, true), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_vcl.foo", &service), + testAccCheckServiceExists("fastly_service_vcl.foo", &service), testAccCheckFastlyServiceACLEntriesRemoteState(&service, serviceName, aclName, expectedRemoteEntriesAfterUpdate), resource.TestCheckResourceAttr("fastly_service_acl_entries.entries", "entry.#", "1"), resource.TestCheckTypeSetElemNestedAttrs("fastly_service_acl_entries.entries", "entry.*", map[string]string{ @@ -249,7 +249,7 @@ func TestAccFastlyServiceAclEntries_delete(t *testing.T) { { Config: testAccServiceACLEntriesConfigOneACLWithEntries(serviceName, aclName, expectedRemoteEntries, true), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_vcl.foo", &service), + testAccCheckServiceExists("fastly_service_vcl.foo", &service), testAccCheckFastlyServiceACLEntriesRemoteState(&service, serviceName, aclName, expectedRemoteEntries), resource.TestCheckResourceAttr("fastly_service_acl_entries.entries", "entry.#", "1"), ), @@ -257,7 +257,7 @@ func TestAccFastlyServiceAclEntries_delete(t *testing.T) { { Config: testAccServiceDictionaryItemsV1ConfigOneACLNoEntries(serviceName, aclName), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_vcl.foo", &service), + testAccCheckServiceExists("fastly_service_vcl.foo", &service), resource.TestCheckNoResourceAttr("fastly_service_vcl.foo", "entry"), ), }, @@ -304,7 +304,7 @@ func TestAccFastlyServiceAclEntries_process_1001_entries(t *testing.T) { { Config: testAccServiceACLEntriesConfigOneACLWithEntries(name, aclName, expectedRemoteEntries, true), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_vcl.foo", &service), + testAccCheckServiceExists("fastly_service_vcl.foo", &service), testAccCheckFastlyServiceACLEntriesRemoteState(&service, name, aclName, expectedRemoteEntries), resource.TestCheckResourceAttr("fastly_service_acl_entries.entries", "entry.#", strconv.Itoa(expectedBatchSize)), ), @@ -355,7 +355,7 @@ func TestAccFastlyServiceAclEntries_manage_entries_false(t *testing.T) { { Config: testAccServiceACLEntriesConfigOneACLWithEntries(serviceName, aclName, initialEntries, false), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_vcl.foo", &service), + testAccCheckServiceExists("fastly_service_vcl.foo", &service), testAccCheckFastlyServiceACLEntriesRemoteState(&service, serviceName, aclName, initialEntries), resource.TestCheckResourceAttr("fastly_service_acl_entries.entries", "entry.#", "1"), ), @@ -363,7 +363,7 @@ func TestAccFastlyServiceAclEntries_manage_entries_false(t *testing.T) { { Config: testAccServiceACLEntriesConfigOneACLWithEntries(serviceName, aclName, updatedEntries, false), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_vcl.foo", &service), + testAccCheckServiceExists("fastly_service_vcl.foo", &service), testAccCheckFastlyServiceACLEntriesRemoteState(&service, serviceName, aclName, initialEntries), resource.TestCheckResourceAttr("fastly_service_acl_entries.entries", "entry.#", "1"), ), diff --git a/fastly/resource_fastly_service_compute.go b/fastly/resource_fastly_service_compute.go index 6d8c75bca..309fc9b52 100644 --- a/fastly/resource_fastly_service_compute.go +++ b/fastly/resource_fastly_service_compute.go @@ -45,6 +45,7 @@ var computeService = &BaseServiceDefinition{ NewServiceLoggingKinesis(computeAttributes), NewServiceDictionary(computeAttributes), NewServicePackage(computeAttributes), + NewServiceResourceLink(computeAttributes), }, } diff --git a/fastly/resource_fastly_service_compute_test.go b/fastly/resource_fastly_service_compute_test.go index 30a8c1b81..bf32089f1 100644 --- a/fastly/resource_fastly_service_compute_test.go +++ b/fastly/resource_fastly_service_compute_test.go @@ -25,7 +25,7 @@ func TestAccFastlyServiceCompute_basic(t *testing.T) { { Config: testAccServiceComputeConfig(name, domainName1), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_compute.foo", &service), + testAccCheckServiceExists("fastly_service_compute.foo", &service), resource.TestCheckResourceAttr("fastly_service_compute.foo", "name", name), resource.TestCheckResourceAttr("fastly_service_compute.foo", "comment", "Managed by Terraform"), resource.TestCheckResourceAttr("fastly_service_compute.foo", "version_comment", ""), diff --git a/fastly/resource_fastly_service_dictionary_items_test.go b/fastly/resource_fastly_service_dictionary_items_test.go index dc627127f..cad19e6ce 100644 --- a/fastly/resource_fastly_service_dictionary_items_test.go +++ b/fastly/resource_fastly_service_dictionary_items_test.go @@ -67,7 +67,7 @@ func TestAccFastlyServiceDictionaryItem_create(t *testing.T) { { Config: testAccServiceDictionaryItemsConfigOneDictionaryWithItems(name, dictName, expectedRemoteItems, true, true), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_vcl.foo", &service), + testAccCheckServiceExists("fastly_service_vcl.foo", &service), testAccCheckFastlyServiceDictionaryItemsRemoteState(&service, name, dictName, expectedRemoteItems), resource.TestCheckResourceAttr("fastly_service_dictionary_items.items", "items.%", "2"), ), @@ -112,7 +112,7 @@ func TestAccFastlyServiceDictionaryItem_create_inactive_service(t *testing.T) { { Config: testAccServiceDictionaryItemsConfigOneDictionaryWithItems(name, dictName, expectedRemoteItems, false, true), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_vcl.foo", &service), + testAccCheckServiceExists("fastly_service_vcl.foo", &service), testAccCheckFastlyServiceDictionaryItemsRemoteState(&service, name, dictName, expectedRemoteItems), resource.TestCheckResourceAttr("fastly_service_dictionary_items.items", "items.%", "2"), ), @@ -143,7 +143,7 @@ func TestAccFastlyServiceDictionaryItem_create_dynamic(t *testing.T) { { Config: testAccServiceDictionaryItemsConfigCreateDynamic(name, dictName), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_vcl.myservice", &service), + testAccCheckServiceExists("fastly_service_vcl.myservice", &service), testAccCheckFastlyServiceDictionaryItemsRemoteState(&service, name, dictName, expectedRemoteItems), resource.TestCheckResourceAttr("fastly_service_dictionary_items.common", "items.%", "4"), ), @@ -178,7 +178,7 @@ func TestAccFastlyServiceDictionaryItem_update(t *testing.T) { { Config: testAccServiceDictionaryItemsConfigOneDictionaryWithItems(name, dictName, expectedRemoteItems, true, true), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_vcl.foo", &service), + testAccCheckServiceExists("fastly_service_vcl.foo", &service), testAccCheckFastlyServiceDictionaryItemsRemoteState(&service, name, dictName, expectedRemoteItems), resource.TestCheckResourceAttr("fastly_service_dictionary_items.items", "items.%", "2"), ), @@ -186,7 +186,7 @@ func TestAccFastlyServiceDictionaryItem_update(t *testing.T) { { Config: testAccServiceDictionaryItemsConfigOneDictionaryWithItems(name, dictName, expectedRemoteItemsAfterUpdate, true, true), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_vcl.foo", &service), + testAccCheckServiceExists("fastly_service_vcl.foo", &service), testAccCheckFastlyServiceDictionaryItemsRemoteState(&service, name, dictName, expectedRemoteItemsAfterUpdate), resource.TestCheckResourceAttr("fastly_service_dictionary_items.items", "items.%", "3"), ), @@ -218,7 +218,7 @@ func TestAccFastlyServiceDictionaryItem_external_item_is_removed(t *testing.T) { { Config: config, Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_vcl.foo", &service), + testAccCheckServiceExists("fastly_service_vcl.foo", &service), testAccCheckFastlyServiceDictionaryItemsRemoteState(&service, name, dictName, expectedRemoteItems), resource.TestCheckResourceAttr("fastly_service_dictionary_items.items", "items.%", "2"), ), @@ -229,7 +229,7 @@ func TestAccFastlyServiceDictionaryItem_external_item_is_removed(t *testing.T) { }, Config: config, Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_vcl.foo", &service), + testAccCheckServiceExists("fastly_service_vcl.foo", &service), testAccCheckFastlyServiceDictionaryItemsRemoteState(&service, name, dictName, expectedRemoteItems), resource.TestCheckResourceAttr("fastly_service_dictionary_items.items", "items.%", "2"), ), @@ -261,7 +261,7 @@ func TestAccFastlyServiceDictionaryItem_external_item_deleted(t *testing.T) { { Config: testAccServiceDictionaryItemsConfigOneDictionaryWithItems(name, dictName, expectedRemoteItems, true, true), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_vcl.foo", &service), + testAccCheckServiceExists("fastly_service_vcl.foo", &service), testAccCheckFastlyServiceDictionaryItemsRemoteState(&service, name, dictName, expectedRemoteItems), resource.TestCheckResourceAttr("fastly_service_dictionary_items.items", "items.%", "2"), ), @@ -272,7 +272,7 @@ func TestAccFastlyServiceDictionaryItem_external_item_deleted(t *testing.T) { }, Config: testAccServiceDictionaryItemsConfigOneDictionaryNoItems(name, dictName), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_vcl.foo", &service), + testAccCheckServiceExists("fastly_service_vcl.foo", &service), testAccCheckFastlyServiceDictionaryItemsRemoteState(&service, name, dictName, expectedRemoteItemsAfterUpdate), testAccCheckFastlyServiceDictionaryItemsDoesNotExists("fastly_service_dictionary_items.items"), ), @@ -304,7 +304,7 @@ func TestAccFastlyServiceDictionaryItem_batch_1001_items(t *testing.T) { { Config: testAccServiceDictionaryItemsConfigOneDictionaryWithItems(name, dictName, expectedRemoteItems, true, true), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_vcl.foo", &service), + testAccCheckServiceExists("fastly_service_vcl.foo", &service), testAccCheckFastlyServiceDictionaryItemsRemoteState(&service, name, dictName, expectedRemoteItems), resource.TestCheckResourceAttr("fastly_service_dictionary_items.items", "items.%", strconv.Itoa(expectedBatchSize)), ), @@ -339,7 +339,7 @@ func TestAccFastlyServiceDictionaryItem_manage_items_false(t *testing.T) { { Config: testAccServiceDictionaryItemsConfigOneDictionaryWithItems(name, dictName, initialItems, true, false), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_vcl.foo", &service), + testAccCheckServiceExists("fastly_service_vcl.foo", &service), testAccCheckFastlyServiceDictionaryItemsRemoteState(&service, name, dictName, initialItems), resource.TestCheckResourceAttr("fastly_service_dictionary_items.items", "items.%", "2"), ), @@ -347,7 +347,7 @@ func TestAccFastlyServiceDictionaryItem_manage_items_false(t *testing.T) { { Config: testAccServiceDictionaryItemsConfigOneDictionaryWithItems(name, dictName, updatedItems, true, false), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_vcl.foo", &service), + testAccCheckServiceExists("fastly_service_vcl.foo", &service), testAccCheckFastlyServiceDictionaryItemsRemoteState(&service, name, dictName, initialItems), resource.TestCheckResourceAttr("fastly_service_dictionary_items.items", "items.%", "2"), ), diff --git a/fastly/resource_fastly_service_dynamic_snippet_content_test.go b/fastly/resource_fastly_service_dynamic_snippet_content_test.go index 3e15aba86..b2c90302b 100644 --- a/fastly/resource_fastly_service_dynamic_snippet_content_test.go +++ b/fastly/resource_fastly_service_dynamic_snippet_content_test.go @@ -30,7 +30,7 @@ func TestAccFastlyServiceDynamicSnippetContent_create(t *testing.T) { { Config: testAccServiceDynamicSnippetContentConfigWithDynamicSnippet(serviceName, expectedSnippetName, expectedSnippetContent, true), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_vcl.foo", &service), + testAccCheckServiceExists("fastly_service_vcl.foo", &service), testAccCheckFastlyServiceDynamicSnippetContentRemoteState(&service, serviceName, expectedSnippetName, expectedSnippetContent), resource.TestCheckResourceAttr("fastly_service_vcl.foo", "dynamicsnippet.#", expectedNumberOfSnippets), resource.TestCheckTypeSetElemNestedAttrs("fastly_service_vcl.foo", "dynamicsnippet.*", map[string]string{ @@ -70,7 +70,7 @@ func TestAccFastlyServiceDynamicSnippetContent_update(t *testing.T) { { Config: testAccServiceDynamicSnippetContentConfigWithDynamicSnippet(name, dynamicSnippetName, expectedRemoteItems, true), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_vcl.foo", &service), + testAccCheckServiceExists("fastly_service_vcl.foo", &service), testAccCheckFastlyServiceDynamicSnippetContentRemoteState(&service, name, dynamicSnippetName, expectedRemoteItems), resource.TestCheckResourceAttr("fastly_service_vcl.foo", "dynamicsnippet.#", "1"), resource.TestCheckResourceAttr("fastly_service_dynamic_snippet_content.content", "content", expectedRemoteItems), @@ -79,7 +79,7 @@ func TestAccFastlyServiceDynamicSnippetContent_update(t *testing.T) { { Config: testAccServiceDynamicSnippetContentConfigWithDynamicSnippet(name, dynamicSnippetName, expectedRemoteItemsAfterUpdate, true), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_vcl.foo", &service), + testAccCheckServiceExists("fastly_service_vcl.foo", &service), testAccCheckFastlyServiceDynamicSnippetContentRemoteState(&service, name, dynamicSnippetName, expectedRemoteItemsAfterUpdate), resource.TestCheckResourceAttr("fastly_service_vcl.foo", "dynamicsnippet.#", "1"), resource.TestCheckResourceAttr("fastly_service_dynamic_snippet_content.content", "content", expectedRemoteItemsAfterUpdate), @@ -109,7 +109,7 @@ func TestAccFastlyServiceDynamicSnippetContent_external_snippet_is_removed(t *te { Config: testAccServiceDynamicSnippetContentConfigWithDynamicSnippet(name, managedDynamicSnippetName, managedContent, true), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_vcl.foo", &service), + testAccCheckServiceExists("fastly_service_vcl.foo", &service), resource.TestCheckResourceAttr("fastly_service_vcl.foo", "dynamicsnippet.#", "1"), ), }, @@ -119,7 +119,7 @@ func TestAccFastlyServiceDynamicSnippetContent_external_snippet_is_removed(t *te }, Config: testAccServiceDynamicSnippetContentConfigWithDynamicSnippet(name, managedDynamicSnippetName, managedContent, true), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_vcl.foo", &service), + testAccCheckServiceExists("fastly_service_vcl.foo", &service), testAccCheckFastlyServiceDynamicSnippetContentRemoteState(&service, name, managedDynamicSnippetName, managedContent), testAccCheckFastlyServiceDynamicSnippetContentRemoteStateDoesntExist(&service, name, externalDynamicSnippetName), resource.TestCheckResourceAttr("fastly_service_vcl.foo", "dynamicsnippet.#", "1"), @@ -150,7 +150,7 @@ func TestAccFastlyServiceDynamicSnippetContent_normal_snippet_is_not_removed(t * { Config: testAccServiceDynamicSnippetContentConfigWithSnippet(name, normalSnippetName, normalContent), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_vcl.foo", &service), + testAccCheckServiceExists("fastly_service_vcl.foo", &service), resource.TestCheckResourceAttr("fastly_service_vcl.foo", "snippet.#", "1"), resource.TestCheckResourceAttr("fastly_service_vcl.foo", "dynamicsnippet.#", "0"), ), @@ -158,7 +158,7 @@ func TestAccFastlyServiceDynamicSnippetContent_normal_snippet_is_not_removed(t * { Config: testAccServiceDynamicSnippetContentConfigWithSnippetAndDynamicSnippet(name, normalSnippetName, normalContent, dynamicSnippetName, dynamicContent), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_vcl.foo", &service), + testAccCheckServiceExists("fastly_service_vcl.foo", &service), testAccCheckFastlyServiceDynamicSnippetContentRemoteState(&service, name, dynamicSnippetName, dynamicContent), resource.TestCheckResourceAttr("fastly_service_vcl.foo", "snippet.#", "1"), resource.TestCheckResourceAttr("fastly_service_vcl.foo", "dynamicsnippet.#", "1"), diff --git a/fastly/resource_fastly_service_vcl_test.go b/fastly/resource_fastly_service_vcl_test.go index 2eca54ebc..e23522230 100644 --- a/fastly/resource_fastly_service_vcl_test.go +++ b/fastly/resource_fastly_service_vcl_test.go @@ -37,7 +37,7 @@ func TestAccFastlyServiceVCL_updateDomain(t *testing.T) { { Config: testAccServiceVCLConfig(name, domainName1), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_vcl.foo", &service), + testAccCheckServiceExists("fastly_service_vcl.foo", &service), testAccCheckFastlyServiceVCLAttributes(&service, name, []string{domainName1}), resource.TestCheckResourceAttr( "fastly_service_vcl.foo", "name", name), @@ -51,7 +51,7 @@ func TestAccFastlyServiceVCL_updateDomain(t *testing.T) { { Config: testAccServiceVCLConfigDomainAdd(nameUpdate, domainName1, domainName2), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_vcl.foo", &service), + testAccCheckServiceExists("fastly_service_vcl.foo", &service), testAccCheckFastlyServiceVCLAttributes(&service, nameUpdate, []string{domainName1, domainName2}), resource.TestCheckResourceAttr( "fastly_service_vcl.foo", "name", nameUpdate), @@ -65,7 +65,7 @@ func TestAccFastlyServiceVCL_updateDomain(t *testing.T) { { Config: testAccServiceVCLConfigDomainUpdateComment(nameUpdate, domainName1, domainName2), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_vcl.foo", &service), + testAccCheckServiceExists("fastly_service_vcl.foo", &service), testAccCheckFastlyServiceVCLAttributes(&service, nameUpdate, []string{domainName1, domainName2}), resource.TestCheckResourceAttr( "fastly_service_vcl.foo", "active_version", "3"), @@ -77,7 +77,7 @@ func TestAccFastlyServiceVCL_updateDomain(t *testing.T) { { Config: testAccServiceVCLConfigDomainUpdate(nameUpdate, domainName1, domainName3), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_vcl.foo", &service), + testAccCheckServiceExists("fastly_service_vcl.foo", &service), testAccCheckFastlyServiceVCLAttributes(&service, nameUpdate, []string{domainName1, domainName3}), resource.TestCheckResourceAttr( "fastly_service_vcl.foo", "active_version", "4"), @@ -106,7 +106,7 @@ func TestAccFastlyServiceVCL_updateBackend(t *testing.T) { { Config: testAccServiceVCLConfigBackend(name, domain, backendName), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_vcl.foo", &service), + testAccCheckServiceExists("fastly_service_vcl.foo", &service), testAccCheckFastlyServiceVCLAttributesBackends(&service, name, []string{backendName}), ), }, @@ -114,7 +114,7 @@ func TestAccFastlyServiceVCL_updateBackend(t *testing.T) { { Config: testAccServiceVCLConfigBackendUpdate(name, domain, backendName, backendName2, 3400), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_vcl.foo", &service), + testAccCheckServiceExists("fastly_service_vcl.foo", &service), testAccCheckFastlyServiceVCLAttributesBackends(&service, name, []string{backendName, backendName2}), resource.TestCheckResourceAttr( "fastly_service_vcl.foo", "active_version", "2"), @@ -174,7 +174,7 @@ func TestAccFastlyServiceVCL_activateNewVersionExternally(t *testing.T) { { Config: testAccServiceVCLConfigBackendUpdate(name, domain, backendName, backendName2, 3400), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_vcl.foo", &service), + testAccCheckServiceExists("fastly_service_vcl.foo", &service), testAccCheckFastlyServiceVCLAttributesBackends(&service, name, []string{backendName, backendName2}), activateNewVersion, ), @@ -184,7 +184,7 @@ func TestAccFastlyServiceVCL_activateNewVersionExternally(t *testing.T) { { Config: testAccServiceVCLConfigBackendUpdate(name, domain, backendName, backendName2, 3400), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_vcl.foo", &service), + testAccCheckServiceExists("fastly_service_vcl.foo", &service), testAccCheckFastlyServiceVCLAttributesBackends(&service, name, []string{backendName, backendName2}), resource.TestCheckResourceAttr( "fastly_service_vcl.foo", "active_version", "3"), @@ -215,7 +215,7 @@ func TestAccFastlyServiceVCL_updateInvalidBackend(t *testing.T) { Config: testAccServiceVCLConfigBackend(name, domain, badBackendName), ExpectError: regexp.MustCompile("Bad Request"), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_vcl.foo", &service), + testAccCheckServiceExists("fastly_service_vcl.foo", &service), testAccCheckFastlyServiceVCLAttributesBackends(&service, name, []string{}), ), }, @@ -223,7 +223,7 @@ func TestAccFastlyServiceVCL_updateInvalidBackend(t *testing.T) { { Config: testAccServiceVCLConfigBackendUpdate(name, domain, backendName, backendName2, 3400), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_vcl.foo", &service), + testAccCheckServiceExists("fastly_service_vcl.foo", &service), testAccCheckFastlyServiceVCLAttributesBackends(&service, name, []string{backendName, backendName2}), resource.TestCheckResourceAttr( "fastly_service_vcl.foo", "active_version", "1"), @@ -276,7 +276,7 @@ func TestAccFastlyServiceVCL_createServiceWithStaticBackend(t *testing.T) { { Config: testAccServiceVCLConfigStaticBackend(name, domain, snippet1), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_vcl.foo", &service), + testAccCheckServiceExists("fastly_service_vcl.foo", &service), testAccCheckFastlyServiceVCLAttributesBackends(&service, name, []string{}), resource.TestCheckResourceAttr( "fastly_service_vcl.foo", "active_version", "1"), @@ -307,7 +307,7 @@ func TestAccFastlyServiceVCL_basic(t *testing.T) { { Config: testAccServiceVCLConfigInitWithVersionComment(name, versionComment1, domainName1), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_vcl.foo", &service), + testAccCheckServiceExists("fastly_service_vcl.foo", &service), resource.TestCheckResourceAttr("fastly_service_vcl.foo", "name", name), resource.TestCheckResourceAttr("fastly_service_vcl.foo", "comment", "Managed by Terraform"), resource.TestCheckResourceAttr("fastly_service_vcl.foo", "version_comment", versionComment1), @@ -321,7 +321,7 @@ func TestAccFastlyServiceVCL_basic(t *testing.T) { // updating service comment with "activate = false" will be ignored Config: testAccServiceVCLConfigUpdateServiceComment(name, "new service comment", domainName1, false), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_vcl.foo", &service), + testAccCheckServiceExists("fastly_service_vcl.foo", &service), resource.TestCheckResourceAttr("fastly_service_vcl.foo", "active_version", "1"), resource.TestCheckResourceAttr("fastly_service_vcl.foo", "comment", "Managed by Terraform"), ), @@ -330,7 +330,7 @@ func TestAccFastlyServiceVCL_basic(t *testing.T) { { Config: testAccServiceVCLConfigBasicUpdate(name, comment, versionComment2, domainName2), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_vcl.foo", &service), + testAccCheckServiceExists("fastly_service_vcl.foo", &service), resource.TestCheckResourceAttr("fastly_service_vcl.foo", "name", name), resource.TestCheckResourceAttr("fastly_service_vcl.foo", "comment", comment), resource.TestCheckResourceAttr("fastly_service_vcl.foo", "version_comment", versionComment2), @@ -390,7 +390,7 @@ func TestAccFastlyServiceVCL_disappears(t *testing.T) { { Config: testAccServiceVCLConfig(name, domainName), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_vcl.foo", &service), + testAccCheckServiceExists("fastly_service_vcl.foo", &service), testDestroy, ), ExpectNonEmptyPlan: true, @@ -399,7 +399,7 @@ func TestAccFastlyServiceVCL_disappears(t *testing.T) { }) } -func testAccCheckServiceVCLExists(n string, service *gofastly.ServiceDetail) resource.TestCheckFunc { +func testAccCheckServiceExists(n string, service *gofastly.ServiceDetail) resource.TestCheckFunc { return func(s *terraform.State) error { rs, ok := s.RootModule().Resources[n] if !ok { @@ -505,7 +505,7 @@ func TestAccFastlyServiceVCL_defaultTTL(t *testing.T) { { Config: testAccServiceVCLConfigBackend(name, domain, backendName), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_vcl.foo", &service), + testAccCheckServiceExists("fastly_service_vcl.foo", &service), testAccCheckFastlyServiceVCLAttributesBackends(&service, name, []string{backendName}), resource.TestCheckResourceAttr( "fastly_service_vcl.foo", "default_ttl", "3600"), @@ -515,7 +515,7 @@ func TestAccFastlyServiceVCL_defaultTTL(t *testing.T) { { Config: testAccServiceVCLConfigBackendTTL(name, domain, backendName, 3400), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_vcl.foo", &service), + testAccCheckServiceExists("fastly_service_vcl.foo", &service), testAccCheckFastlyServiceVCLAttributesBackends(&service, name, []string{backendName}), resource.TestCheckResourceAttr( "fastly_service_vcl.foo", "default_ttl", "3400"), @@ -527,7 +527,7 @@ func TestAccFastlyServiceVCL_defaultTTL(t *testing.T) { { Config: testAccServiceVCLConfigBackendTTL(name, domain, backendName, 0), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_vcl.foo", &service), + testAccCheckServiceExists("fastly_service_vcl.foo", &service), testAccCheckFastlyServiceVCLAttributesBackends(&service, name, []string{backendName}), resource.TestCheckResourceAttr( "fastly_service_vcl.foo", "default_ttl", "0"), @@ -555,7 +555,7 @@ func TestAccFastlyServiceVCL_defaultHost(t *testing.T) { { Config: testAccServiceVCLConfigDefaultHost(name, domain, defaultHost), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_vcl.foo", &service), + testAccCheckServiceExists("fastly_service_vcl.foo", &service), resource.TestCheckResourceAttr( "fastly_service_vcl.foo", "default_ttl", "3600"), resource.TestCheckResourceAttr( @@ -568,7 +568,7 @@ func TestAccFastlyServiceVCL_defaultHost(t *testing.T) { { Config: testAccServiceVCLConfigDefaultHost(name, domain, ""), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_vcl.foo", &service), + testAccCheckServiceExists("fastly_service_vcl.foo", &service), resource.TestCheckResourceAttr( "fastly_service_vcl.foo", "default_host", ""), resource.TestCheckResourceAttr( @@ -601,7 +601,7 @@ func TestAccFastlyServiceVCL_brokenSnippet(t *testing.T) { set req.url = "/anything" req.url; }`), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_vcl.foo", &service), + testAccCheckServiceExists("fastly_service_vcl.foo", &service), ), }, { @@ -615,7 +615,7 @@ func TestAccFastlyServiceVCL_brokenSnippet(t *testing.T) { set req.url = "/anything" req.url; }`), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_vcl.foo", &service), + testAccCheckServiceExists("fastly_service_vcl.foo", &service), ), }, }, @@ -638,7 +638,7 @@ func TestAccFastlyServiceVCL_createZeroDefaultTTL(t *testing.T) { { Config: testAccServiceVCLConfigBackendZeroTTL(name, domain, backendName, 0), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_vcl.foo", &service), + testAccCheckServiceExists("fastly_service_vcl.foo", &service), testAccCheckFastlyServiceVCLAttributesBackends(&service, name, []string{backendName}), resource.TestCheckResourceAttr( "fastly_service_vcl.foo", "default_ttl", "0"), diff --git a/fastly/resource_fastly_service_versionless_test.go b/fastly/resource_fastly_service_versionless_test.go index d47d52b21..0b9ee75ba 100644 --- a/fastly/resource_fastly_service_versionless_test.go +++ b/fastly/resource_fastly_service_versionless_test.go @@ -29,7 +29,7 @@ func TestAccFastlyServiceVCL_creation_with_versionless_resources(t *testing.T) { { Config: testAccServiceVCLConfigCreateServiceWithOneACLDictionaryAndDynamicSnippet(serviceName, dictionaryName, aclName, dynamicSnippetName, domainName), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists("fastly_service_vcl.service", &service), + testAccCheckServiceExists("fastly_service_vcl.service", &service), resource.TestCheckResourceAttr("fastly_service_acl_entries.entries", "entry.#", "1"), resource.TestCheckResourceAttr("fastly_service_dictionary_items.items", "items.%", "3"), resource.TestCheckResourceAttrSet("fastly_service_dynamic_snippet_content.dyn_content", "content"), diff --git a/fastly/resource_fastly_service_waf_configuration_test.go b/fastly/resource_fastly_service_waf_configuration_test.go index 1a6b3f6de..9a593f845 100644 --- a/fastly/resource_fastly_service_waf_configuration_test.go +++ b/fastly/resource_fastly_service_waf_configuration_test.go @@ -79,7 +79,7 @@ func TestAccFastlyServiceWAFVersionV1_Add(t *testing.T) { { Config: testAccFastlyServiceWAFVersionV1(name, wafVer), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists(serviceRef, &service), + testAccCheckServiceExists(serviceRef, &service), testAccCheckFastlyServiceWAFVersionV1CheckAttributes(&service, wafVerInput, 1), ), }, @@ -103,13 +103,13 @@ func TestAccFastlyServiceWAFVersionV1_AddExistingService(t *testing.T) { { Config: testAccFastlyServiceWAFVersionV1(name, ""), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists(serviceRef, &service), + testAccCheckServiceExists(serviceRef, &service), ), }, { Config: testAccFastlyServiceWAFVersionV1(name, wafVer), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists(serviceRef, &service), + testAccCheckServiceExists(serviceRef, &service), testAccCheckFastlyServiceWAFVersionV1CheckAttributes(&service, wafVerInput, 1), ), }, @@ -141,14 +141,14 @@ func TestAccFastlyServiceWAFVersionV1_Update(t *testing.T) { { Config: testAccFastlyServiceWAFVersionV1(name, wafVer1), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists(serviceRef, &service), + testAccCheckServiceExists(serviceRef, &service), testAccCheckFastlyServiceWAFVersionV1CheckAttributes(&service, wafVerInput1, 1), ), }, { Config: testAccFastlyServiceWAFVersionV1(name, wafVer2), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists(serviceRef, &service), + testAccCheckServiceExists(serviceRef, &service), testAccCheckFastlyServiceWAFVersionV1CheckAttributes(&service, wafVerInput2, 2), resource.TestCheckResourceAttr(resourceName, "active", "false"), resource.TestCheckResourceAttr(resourceName, "number", "2"), @@ -157,7 +157,7 @@ func TestAccFastlyServiceWAFVersionV1_Update(t *testing.T) { { Config: testAccFastlyServiceWAFVersionV1(name, wafVer3), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists(serviceRef, &service), + testAccCheckServiceExists(serviceRef, &service), testAccCheckFastlyServiceWAFVersionV1CheckAttributes(&service, wafVerInput3, 2), resource.TestCheckResourceAttr(resourceName, "active", "true"), resource.TestCheckResourceAttr(resourceName, "number", "2"), @@ -183,14 +183,14 @@ func TestAccFastlyServiceWAFVersionV1_Delete(t *testing.T) { { Config: testAccFastlyServiceWAFVersionV1(name, wafVer), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists(serviceRef, &service), + testAccCheckServiceExists(serviceRef, &service), testAccCheckFastlyServiceWAFVersionV1CheckAttributes(&service, wafVerInput, 1), ), }, { Config: testAccFastlyServiceWAFVersionV1(name, ""), Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists(serviceRef, &service), + testAccCheckServiceExists(serviceRef, &service), testAccCheckFastlyServiceWAFVersionV1CheckEmpty(&service, 2), ), }, @@ -265,7 +265,7 @@ func TestAccFastlyServiceWAFVersionV1_Config(t *testing.T) { { Config: wafSvcCfg, Check: resource.ComposeTestCheckFunc( - testAccCheckServiceVCLExists(serviceRef, &service), + testAccCheckServiceExists(serviceRef, &service), ), }, { diff --git a/templates/resources/kvstore.md.tmpl b/templates/resources/kvstore.md.tmpl new file mode 100644 index 000000000..4fdbdd595 --- /dev/null +++ b/templates/resources/kvstore.md.tmpl @@ -0,0 +1,27 @@ +--- +layout: "fastly" +page_title: "Fastly: kvstore" +sidebar_current: "docs-fastly-resource-kvstore" +description: |- + Provides a persistent, globally consistent key-value store accessible to Compute@Edge services during request processing. +--- + +# fastly_kvstore + +Provides a persistent, globally consistent key-value store accessible to Compute@Edge services during request processing. + +-> **Note** The `kv_store` feature does not support seeding the store with data. This is because the size of objects that can be stored is very large and Terraform is designed for containing [configuration, not data](https://developer.fastly.com/learning/integrations/orchestration/terraform/#configuration-not-data). You should use either the [Fastly CLI](https://developer.fastly.com/learning/tools/cli/), [Fastly API](https://developer.fastly.com/reference/api/) or one of the available [Fastly API Clients](https://developer.fastly.com/reference/api/#clients) to populate your KV Store. + +## Example Usage + +Basic usage: + +{{ tffile "examples/resources/kvstore_basic_usage.tf" }} + +## Import + +Fastly KV Stores can be imported using their Store ID, e.g. + +{{ codefile "sh" "examples/resources/components/kvstore_import_cmd.txt" }} + +{{ .SchemaMarkdown | trimspace }}