Skip to content
This repository was archived by the owner on Mar 8, 2022. It is now read-only.

Commit 52f1ccc

Browse files
authored
Merge pull request #476 from alexkappa/fix-action-deployment
Fix action deployment
2 parents 4aa5534 + bb98407 commit 52f1ccc

File tree

3 files changed

+46
-10
lines changed

3 files changed

+46
-10
lines changed

CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## 0.24.1
2+
3+
BUG FIXES:
4+
5+
* resource/auth0_action: Secrets would not be created causing deployments to fail ([#473](https://github.com/alexkappa/terraform-provider-auth0/pull/473))
6+
17
## 0.24.0
28

39
ENHANCEMENTS:

auth0/resource_auth0_action.go

+16-10
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package auth0
33
import (
44
"fmt"
55
"net/http"
6+
"strings"
67

78
"github.com/alexkappa/terraform-provider-auth0/auth0/internal/hash"
89
"github.com/hashicorp/terraform-plugin-sdk/helper/resource"
@@ -189,31 +190,36 @@ func updateAction(d *schema.ResourceData, m interface{}) error {
189190
}
190191

191192
func deployAction(d *schema.ResourceData, m interface{}) error {
193+
192194
if d.Get("deploy").(bool) == true {
195+
193196
api := m.(*management.Management)
194-
v, err := api.Action.Deploy(d.Id())
195-
if err != nil {
196-
return err
197-
}
198-
d.Set("version_id", v.GetID())
199197

200-
err = resource.Retry(d.Timeout(schema.TimeoutCreate), func() *resource.RetryError {
198+
err := resource.Retry(d.Timeout(schema.TimeoutCreate), func() *resource.RetryError {
201199

202200
a, err := api.Action.Read(d.Id())
203201
if err != nil {
204202
return resource.NonRetryableError(err)
205203
}
206204

207-
if a.DeployedVersion == nil || a.DeployedVersion.GetID() != v.GetID() {
205+
if strings.ToLower(a.GetStatus()) != "built" {
208206
return resource.RetryableError(
209-
fmt.Errorf("Expected deployed version %q to equal %q",
210-
a.DeployedVersion.GetID(),
211-
v.GetID()),
207+
fmt.Errorf(`Expected action status %q to equal "built"`, a.GetStatus()),
212208
)
213209
}
214210

215211
return nil
216212
})
213+
if err != nil {
214+
return fmt.Errorf("Action never reached built state. %w", err)
215+
}
216+
217+
v, err := api.Action.Deploy(d.Id())
218+
if err != nil {
219+
return err
220+
}
221+
222+
d.Set("version_id", v.GetID())
217223
}
218224
return nil
219225
}

example/action/main.tf

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
terraform {
2+
required_providers {
3+
auth0 = {
4+
source = "alexkappa/auth0"
5+
version = "0.24.1"
6+
}
7+
}
8+
}
9+
10+
provider "auth0" {}
11+
12+
resource "auth0_action" "do" {
13+
name = "Test Action ${timestamp()}"
14+
supported_triggers {
15+
id = "post-login"
16+
version = "v2"
17+
}
18+
code = <<-EOT
19+
exports.onContinuePostLogin = async (event, api) => {
20+
console.log(event)
21+
};"
22+
EOT
23+
deploy = true
24+
}

0 commit comments

Comments
 (0)