Skip to content

Commit

Permalink
fix: Update domain activation for mTLS after creation
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
landrew57 committed Jul 22, 2024
1 parent 4aceb05 commit b6fd587
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions fastly/resource_fastly_tls_activation.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,16 @@ func resourceFastlyTLSActivation() *schema.Resource {
"mutual_authentication_id": {
Type: schema.TypeString,
Optional: true,
Computed: true,
Description: "An alphanumeric string identifying a mutual authentication.",
Computed: true,
},
},
}
}

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 {
Expand All @@ -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 {
Expand Down

0 comments on commit b6fd587

Please sign in to comment.