From b6fd58714cd9ccfdb01fda109abbbd134bffef7f Mon Sep 17 00:00:00 2001 From: Luke Andrew Date: Thu, 18 Jul 2024 17:02:43 +0100 Subject: [PATCH] fix: Update domain activation for mTLS after creation The mutual_authentication_id can only be set once an activation has already been created. This commit implements the Update call immediately after the Create call if the mutual_authentication_id is set in the resource configuration. It fixes the failing test case added in the previous commit. --- fastly/resource_fastly_tls_activation.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/fastly/resource_fastly_tls_activation.go b/fastly/resource_fastly_tls_activation.go index 3aeb55328..2e03f4900 100644 --- a/fastly/resource_fastly_tls_activation.go +++ b/fastly/resource_fastly_tls_activation.go @@ -47,8 +47,8 @@ func resourceFastlyTLSActivation() *schema.Resource { "mutual_authentication_id": { Type: schema.TypeString, Optional: true, - Computed: true, Description: "An alphanumeric string identifying a mutual authentication.", + Computed: true, }, }, } @@ -56,6 +56,7 @@ func resourceFastlyTLSActivation() *schema.Resource { func resourceFastlyTLSActivationCreate(ctx context.Context, d *schema.ResourceData, meta any) diag.Diagnostics { conn := meta.(*APIClient).conn + var diags diag.Diagnostics var configuration *fastly.TLSConfiguration if v, ok := d.GetOk("configuration_id"); ok { @@ -73,7 +74,14 @@ func resourceFastlyTLSActivationCreate(ctx context.Context, d *schema.ResourceDa d.SetId(activation.ID) - return resourceFastlyTLSActivationRead(ctx, d, meta) + // Setting the mutual_authentication_id is only possible through an update via PATCH. + // See https://github.com/fastly/terraform-provider-fastly/issues/873 + mtlsID := d.Get("mutual_authentication_id").(string) + if mtlsID != "" { + diags = append(diags, resourceFastlyTLSActivationUpdate(ctx, d, meta)...) + } + + return append(diags, resourceFastlyTLSActivationRead(ctx, d, meta)...) } func resourceFastlyTLSActivationRead(_ context.Context, d *schema.ResourceData, meta any) diag.Diagnostics {