Skip to content

Commit 76dbbbc

Browse files
authored
Always validate VCL services after applying changes. (#942)
In PR #733 the validation logic was changed to only attempt validation of services if they would also be activated, in order to avoid failing validation of Compute services which do not have WASM packages attached to them. Unfortunately this breaks customer workflows for VCL services, as they no longer get feedback about validation failures until they attempt to activate the service outside of Terraform. This patch changes the logic so that VCL services are always validated, even if they will not be activated or staged.
1 parent 9b22388 commit 76dbbbc

File tree

2 files changed

+14
-17
lines changed

2 files changed

+14
-17
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ ENHANCEMENTS:
77

88
BUG FIXES:
99

10+
- fix(fastly_vcl_service): Always 'validate' services after applying changes.
11+
1012
DEPENDENCIES:
1113

1214
- build(deps): `github.com/hashicorp/terraform-plugin-docs` from 0.19.4 to 0.21.0 ([#937](https://github.com/fastly/terraform-provider-fastly/pull/937))

fastly/base_fastly_service.go

Lines changed: 12 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -457,23 +457,18 @@ func resourceServiceUpdate(ctx context.Context, d *schema.ResourceData, meta any
457457
}
458458
}
459459

460-
// Only validate the service if `activate = true` or `stage = true`.
461-
// This is primarily for compute services with no package defined.
462-
// The user needs to set `activate = false` and `stage = false` to prevent errors.
463-
// As they can't activate or stage a service without a package.
464-
// There's no value showing validation errors to users in 'draft' mode.
465-
mustValidate := false
466-
if i := d.Get("activate"); i != nil {
467-
if i.(bool) {
468-
mustValidate = true
469-
}
470-
}
471-
if i := d.Get("stage"); i != nil {
472-
if i.(bool) {
473-
mustValidate = true
474-
}
475-
}
476-
if mustValidate {
460+
// Delivery (VCL) services should always be validated
461+
// after changes are made, even if they will not be
462+
// activated or staged.
463+
//
464+
// Compute (WASM) services should only be validated if
465+
// they will be activated or staged, since the service
466+
// may not have a WASM package attached while it is
467+
// 'draft' and validation would fail. If the user is
468+
// expecting to activate or stage the service, though,
469+
// it must have a WASM package attached and pass
470+
// validation.
471+
if (serviceDef.GetType() == ServiceTypeVCL) || d.Get("activate").(bool) || d.Get("stage").(bool) {
477472
// Validate version.
478473
log.Printf("[DEBUG] Validating Fastly Service (%s), Version (%v)", d.Id(), latestVersion)
479474
valid, msg, err := conn.ValidateVersion(&gofastly.ValidateVersionInput{

0 commit comments

Comments
 (0)