Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

fix: force refresh when service version is reverted outside of Terraform #630

Merged
merged 2 commits into from
Jan 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/resources/service_compute.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ $ terraform import fastly_service_compute.demo xxxxxxxxxxxxxxxxxxxx@2

- `active_version` (Number) The currently active version of your Fastly Service
- `cloned_version` (Number) The latest cloned version by the provider
- `force_refresh` (Boolean) Used internally by the provider to temporarily indicate if all resources should call their associated API to update the local state. This is for scenarios where the service version has been reverted outside of Terraform (e.g. via the Fastly UI) and the provider needs to resync the state for a different active version (this is only if `activate` is `true`).
- `id` (String) The ID of this resource.
- `imported` (Boolean) Used internally by the provider to temporarily indicate if the service is being imported, and is reset to false once the import is finished

Expand Down
1 change: 1 addition & 0 deletions docs/resources/service_vcl.md
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,7 @@ $ terraform import fastly_service_vcl.demo xxxxxxxxxxxxxxxxxxxx@2

- `active_version` (Number) The currently active version of your Fastly Service
- `cloned_version` (Number) The latest cloned version by the provider
- `force_refresh` (Boolean) Used internally by the provider to temporarily indicate if all resources should call their associated API to update the local state. This is for scenarios where the service version has been reverted outside of Terraform (e.g. via the Fastly UI) and the provider needs to resync the state for a different active version (this is only if `activate` is `true`).
- `id` (String) The ID of this resource.
- `imported` (Boolean) Used internally by the provider to temporarily indicate if the service is being imported, and is reset to false once the import is finished

Expand Down
44 changes: 42 additions & 2 deletions fastly/base_fastly_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,11 @@ func resourceService(serviceDef ServiceDefinition) *schema.Resource {
Description: "Services that are active cannot be destroyed. In order to destroy the Service, set `force_destroy` to `true`. Default `false`",
ConflictsWith: []string{"reuse"},
},
"force_refresh": {
Type: schema.TypeBool,
Computed: true,
Description: "Used internally by the provider to temporarily indicate if all resources should call their associated API to update the local state. This is for scenarios where the service version has been reverted outside of Terraform (e.g. via the Fastly UI) and the provider needs to resync the state for a different active version (this is only if `activate` is `true`).",
},
"imported": {
Type: schema.TypeBool,
Computed: true,
Expand Down Expand Up @@ -452,6 +457,35 @@ func resourceServiceRead(ctx context.Context, d *schema.ResourceData, meta any,
if err != nil {
return diag.FromErr(err)
}

var activeVersionFromPriorState int
if i := d.Get("active_version"); i != nil {
activeVersionFromPriorState = i.(int)
}

var activate bool
if i := d.Get("activate"); i != nil {
activate = i.(bool)
}

// If the user has reverted a service version via the Fastly UI, then the
// active version of the service will no longer match the version being
// tracked in the state file. This means we can use this information to help
// force each nested service resource to call its API to update the state.
//
// REFERENCE:
// https://github.com/fastly/terraform-provider-fastly/issues/629
//
// NOTE: We only force a refresh if `activate = true` in config.
// This is because if the user has set it to false, then the expectation is
// for the version to drift and so there will be no active version to use.
if activeVersionFromPriorState != s.ActiveVersion.Number && activate {
err = d.Set("force_refresh", true)
if err != nil {
return diag.FromErr(err)
}
}

err = d.Set("active_version", s.ActiveVersion.Number)
if err != nil {
return diag.FromErr(err)
Expand Down Expand Up @@ -528,13 +562,19 @@ func resourceServiceRead(ctx context.Context, d *schema.ResourceData, meta any,
}

// To ensure nested resources (e.g. backends, domains etc) don't continue to
// call the API to refresh the internal Terraform state, once an import is
// complete, we reset the 'imported' computed attribute to false.
// call the API to refresh the internal Terraform state, once an import or a
// forced refresh is complete, we reset both the 'imported' and
// 'force_refresh' computed attributes back to false.
err = d.Set("imported", false)
if err != nil {
return diag.FromErr(err)
}

err = d.Set("force_refresh", false)
if err != nil {
return diag.FromErr(err)
}

return diags
}

Expand Down
2 changes: 1 addition & 1 deletion fastly/block_fastly_service_acl.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ func (h *ACLServiceAttributeHandler) Create(_ context.Context, d *schema.Resourc
func (h *ACLServiceAttributeHandler) Read(_ context.Context, d *schema.ResourceData, _ map[string]any, latestVersion int, conn *gofastly.Client) error {
localState := d.Get(h.Key()).(*schema.Set).List()

if len(localState) > 0 || d.Get("imported").(bool) {
if len(localState) > 0 || d.Get("imported").(bool) || d.Get("force_refresh").(bool) {
log.Printf("[DEBUG] Refreshing ACLs for (%s)", d.Id())
remoteState, err := conn.ListACLs(&gofastly.ListACLsInput{
ServiceID: d.Id(),
Expand Down
2 changes: 1 addition & 1 deletion fastly/block_fastly_service_backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,7 @@ func (h *BackendServiceAttributeHandler) Create(_ context.Context, d *schema.Res
func (h *BackendServiceAttributeHandler) 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) {
if len(localState) > 0 || d.Get("imported").(bool) || d.Get("force_refresh").(bool) {
log.Printf("[DEBUG] Refreshing Backends for (%s)", d.Id())
remoteState, err := conn.ListBackends(&gofastly.ListBackendsInput{
ServiceID: d.Id(),
Expand Down
2 changes: 1 addition & 1 deletion fastly/block_fastly_service_cachesetting.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ func (h *CacheSettingServiceAttributeHandler) Create(_ context.Context, d *schem
func (h *CacheSettingServiceAttributeHandler) 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) {
if len(localState) > 0 || d.Get("imported").(bool) || d.Get("force_refresh").(bool) {
log.Printf("[DEBUG] Refreshing Cache Settings for (%s)", d.Id())
remoteState, err := conn.ListCacheSettings(&gofastly.ListCacheSettingsInput{
ServiceID: d.Id(),
Expand Down
2 changes: 1 addition & 1 deletion fastly/block_fastly_service_condition.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ func (h *ConditionServiceAttributeHandler) Create(_ context.Context, d *schema.R
func (h *ConditionServiceAttributeHandler) 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) {
if len(localState) > 0 || d.Get("imported").(bool) || d.Get("force_refresh").(bool) {
log.Printf("[DEBUG] Refreshing Conditions for (%s)", d.Id())
remoteState, err := conn.ListConditions(&gofastly.ListConditionsInput{
ServiceID: d.Id(),
Expand Down
2 changes: 1 addition & 1 deletion fastly/block_fastly_service_dictionary.go
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ func (h *DictionaryServiceAttributeHandler) Create(_ context.Context, d *schema.
func (h *DictionaryServiceAttributeHandler) 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) {
if len(localState) > 0 || d.Get("imported").(bool) || d.Get("force_refresh").(bool) {
log.Printf("[DEBUG] Refreshing Dictionaries for (%s)", d.Id())
remoteState, err := conn.ListDictionaries(&gofastly.ListDictionariesInput{
ServiceID: d.Id(),
Expand Down
2 changes: 1 addition & 1 deletion fastly/block_fastly_service_director.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ func (h *DirectorServiceAttributeHandler) Create(_ context.Context, d *schema.Re
func (h *DirectorServiceAttributeHandler) 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) {
if len(localState) > 0 || d.Get("imported").(bool) || d.Get("force_refresh").(bool) {
log.Printf("[DEBUG] Refreshing Directors for (%s)", d.Id())
remoteState, err := conn.ListDirectors(&gofastly.ListDirectorsInput{
ServiceID: d.Id(),
Expand Down
2 changes: 1 addition & 1 deletion fastly/block_fastly_service_domain.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func (h *DomainServiceAttributeHandler) Create(_ context.Context, d *schema.Reso
func (h *DomainServiceAttributeHandler) 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) {
if len(localState) > 0 || d.Get("imported").(bool) || d.Get("force_refresh").(bool) {
// TODO: update go-fastly to support an ActiveVersion struct, which contains
// domain and backend info in the response. Here we do 2 additional queries
// to find out that info
Expand Down
2 changes: 1 addition & 1 deletion fastly/block_fastly_service_dynamicsnippet.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ func (h *DynamicSnippetServiceAttributeHandler) Create(_ context.Context, d *sch
func (h *DynamicSnippetServiceAttributeHandler) 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) {
if len(localState) > 0 || d.Get("imported").(bool) || d.Get("force_refresh").(bool) {
log.Printf("[DEBUG] Refreshing VCL Snippets for (%s)", d.Id())
remoteState, err := conn.ListSnippets(&gofastly.ListSnippetsInput{
ServiceID: d.Id(),
Expand Down
2 changes: 1 addition & 1 deletion fastly/block_fastly_service_gzip.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ func (h *GzipServiceAttributeHandler) Create(_ context.Context, d *schema.Resour
func (h *GzipServiceAttributeHandler) 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) {
if len(localState) > 0 || d.Get("imported").(bool) || d.Get("force_refresh").(bool) {
log.Printf("[DEBUG] Refreshing Gzips for (%s)", d.Id())
remoteState, err := conn.ListGzips(&gofastly.ListGzipsInput{
ServiceID: d.Id(),
Expand Down
2 changes: 1 addition & 1 deletion fastly/block_fastly_service_header.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ func (h *HeaderServiceAttributeHandler) Create(_ context.Context, d *schema.Reso
func (h *HeaderServiceAttributeHandler) 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) {
if len(localState) > 0 || d.Get("imported").(bool) || d.Get("force_refresh").(bool) {
log.Printf("[DEBUG] Refreshing Headers for (%s)", d.Id())
remoteState, err := conn.ListHeaders(&gofastly.ListHeadersInput{
ServiceID: d.Id(),
Expand Down
2 changes: 1 addition & 1 deletion fastly/block_fastly_service_healthcheck.go
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ func (h *HealthCheckServiceAttributeHandler) Create(_ context.Context, d *schema
func (h *HealthCheckServiceAttributeHandler) 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) {
if len(localState) > 0 || d.Get("imported").(bool) || d.Get("force_refresh").(bool) {
log.Printf("[DEBUG] Refreshing Healthcheck for (%s)", d.Id())
remoteState, err := conn.ListHealthChecks(&gofastly.ListHealthChecksInput{
ServiceID: d.Id(),
Expand Down
2 changes: 1 addition & 1 deletion fastly/block_fastly_service_logging_bigquery.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ func (h *BigQueryLoggingServiceAttributeHandler) Create(_ context.Context, d *sc
func (h *BigQueryLoggingServiceAttributeHandler) 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) {
if len(localState) > 0 || d.Get("imported").(bool) || d.Get("force_refresh").(bool) {
log.Printf("[DEBUG] Refreshing BigQuery for (%s)", d.Id())
remoteState, err := conn.ListBigQueries(&gofastly.ListBigQueriesInput{
ServiceID: d.Id(),
Expand Down
2 changes: 1 addition & 1 deletion fastly/block_fastly_service_logging_blobstorage.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,7 +194,7 @@ func (h *BlobStorageLoggingServiceAttributeHandler) Create(_ context.Context, d
func (h *BlobStorageLoggingServiceAttributeHandler) 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) {
if len(localState) > 0 || d.Get("imported").(bool) || d.Get("force_refresh").(bool) {
log.Printf("[DEBUG] Refreshing Blob Storages for (%s)", d.Id())
remoteState, err := conn.ListBlobStorages(&gofastly.ListBlobStoragesInput{
ServiceID: d.Id(),
Expand Down
2 changes: 1 addition & 1 deletion fastly/block_fastly_service_logging_cloudfiles.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ func (h *CloudfilesServiceAttributeHandler) Create(_ context.Context, d *schema.
func (h *CloudfilesServiceAttributeHandler) 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) {
if len(localState) > 0 || d.Get("imported").(bool) || d.Get("force_refresh").(bool) {
// Refresh Cloud Files.
log.Printf("[DEBUG] Refreshing Cloud Files logging endpoints for (%s)", d.Id())
remoteState, err := conn.ListCloudfiles(&gofastly.ListCloudfilesInput{
Expand Down
2 changes: 1 addition & 1 deletion fastly/block_fastly_service_logging_datadog.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ func (h *DatadogServiceAttributeHandler) Create(_ context.Context, d *schema.Res
func (h *DatadogServiceAttributeHandler) 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) {
if len(localState) > 0 || d.Get("imported").(bool) || d.Get("force_refresh").(bool) {
log.Printf("[DEBUG] Refreshing Datadog logging endpoints for (%s)", d.Id())
remoteState, err := conn.ListDatadog(&gofastly.ListDatadogInput{
ServiceID: d.Id(),
Expand Down
2 changes: 1 addition & 1 deletion fastly/block_fastly_service_logging_digitalocean.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ func (h *DigitalOceanServiceAttributeHandler) Create(_ context.Context, d *schem
func (h *DigitalOceanServiceAttributeHandler) 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) {
if len(localState) > 0 || d.Get("imported").(bool) || d.Get("force_refresh").(bool) {
log.Printf("[DEBUG] Refreshing DigitalOcean Spaces logging endpoints for (%s)", d.Id())
remoteState, err := conn.ListDigitalOceans(&gofastly.ListDigitalOceansInput{
ServiceID: d.Id(),
Expand Down
2 changes: 1 addition & 1 deletion fastly/block_fastly_service_logging_elasticsearch.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ func (h *ElasticSearchServiceAttributeHandler) Create(_ context.Context, d *sche
func (h *ElasticSearchServiceAttributeHandler) 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) {
if len(localState) > 0 || d.Get("imported").(bool) || d.Get("force_refresh").(bool) {
log.Printf("[DEBUG] Refreshing Elasticsearch logging endpoints for (%s)", d.Id())
remoteState, err := conn.ListElasticsearch(&gofastly.ListElasticsearchInput{
ServiceID: d.Id(),
Expand Down
2 changes: 1 addition & 1 deletion fastly/block_fastly_service_logging_ftp.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ func (h *FTPServiceAttributeHandler) Create(_ context.Context, d *schema.Resourc
func (h *FTPServiceAttributeHandler) 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) {
if len(localState) > 0 || d.Get("imported").(bool) || d.Get("force_refresh").(bool) {
log.Printf("[DEBUG] Refreshing FTP logging endpoints for (%s)", d.Id())
remoteState, err := conn.ListFTPs(&gofastly.ListFTPsInput{
ServiceID: d.Id(),
Expand Down
2 changes: 1 addition & 1 deletion fastly/block_fastly_service_logging_gcs.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ func (h *GCSLoggingServiceAttributeHandler) Create(_ context.Context, d *schema.
func (h *GCSLoggingServiceAttributeHandler) 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) {
if len(localState) > 0 || d.Get("imported").(bool) || d.Get("force_refresh").(bool) {
log.Printf("[DEBUG] Refreshing GCS for (%s)", d.Id())
remoteState, err := conn.ListGCSs(&gofastly.ListGCSsInput{
ServiceID: d.Id(),
Expand Down
2 changes: 1 addition & 1 deletion fastly/block_fastly_service_logging_googlepubsub.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ func (h *GooglePubSubServiceAttributeHandler) Create(_ context.Context, d *schem
func (h *GooglePubSubServiceAttributeHandler) 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) {
if len(localState) > 0 || d.Get("imported").(bool) || d.Get("force_refresh").(bool) {
log.Printf("[DEBUG] Refreshing Google Cloud Pub/Sub logging endpoints for (%s)", d.Id())
remoteState, err := conn.ListPubsubs(&gofastly.ListPubsubsInput{
ServiceID: d.Id(),
Expand Down
2 changes: 1 addition & 1 deletion fastly/block_fastly_service_logging_heroku.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ func (h *HerokuServiceAttributeHandler) Create(_ context.Context, d *schema.Reso
func (h *HerokuServiceAttributeHandler) 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) {
if len(localState) > 0 || d.Get("imported").(bool) || d.Get("force_refresh").(bool) {
log.Printf("[DEBUG] Refreshing Heroku logging endpoints for (%s)", d.Id())
remoteState, err := conn.ListHerokus(&gofastly.ListHerokusInput{
ServiceID: d.Id(),
Expand Down
2 changes: 1 addition & 1 deletion fastly/block_fastly_service_logging_honeycomb.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ func (h *HoneycombServiceAttributeHandler) Create(_ context.Context, d *schema.R
func (h *HoneycombServiceAttributeHandler) 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) {
if len(localState) > 0 || d.Get("imported").(bool) || d.Get("force_refresh").(bool) {
log.Printf("[DEBUG] Refreshing Honeycomb logging endpoints for (%s)", d.Id())
remoteState, err := conn.ListHoneycombs(&gofastly.ListHoneycombsInput{
ServiceID: d.Id(),
Expand Down
2 changes: 1 addition & 1 deletion fastly/block_fastly_service_logging_https.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ func (h *HTTPSLoggingServiceAttributeHandler) Create(_ context.Context, d *schem
func (h *HTTPSLoggingServiceAttributeHandler) 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) {
if len(localState) > 0 || d.Get("imported").(bool) || d.Get("force_refresh").(bool) {
log.Printf("[DEBUG] Refreshing HTTPS logging endpoints for (%s)", d.Id())
remoteState, err := conn.ListHTTPS(&gofastly.ListHTTPSInput{
ServiceID: d.Id(),
Expand Down
2 changes: 1 addition & 1 deletion fastly/block_fastly_service_logging_kafka.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ func (h *KafkaServiceAttributeHandler) Create(_ context.Context, d *schema.Resou
func (h *KafkaServiceAttributeHandler) 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) {
if len(localState) > 0 || d.Get("imported").(bool) || d.Get("force_refresh").(bool) {
log.Printf("[DEBUG] Refreshing Kafka logging endpoints for (%s)", d.Id())
remoteState, err := conn.ListKafkas(&gofastly.ListKafkasInput{
ServiceID: d.Id(),
Expand Down
2 changes: 1 addition & 1 deletion fastly/block_fastly_service_logging_kinesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ func (h *KinesisServiceAttributeHandler) Create(_ context.Context, d *schema.Res
func (h *KinesisServiceAttributeHandler) 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) {
if len(localState) > 0 || d.Get("imported").(bool) || d.Get("force_refresh").(bool) {
log.Printf("[DEBUG] Refreshing Kinesis logging endpoints for (%s)", d.Id())
remoteState, err := conn.ListKinesis(&gofastly.ListKinesisInput{
ServiceID: d.Id(),
Expand Down
Loading