Skip to content
Open
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
32 changes: 30 additions & 2 deletions examples/test.tf
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
provider "shell" {}


//test complete data resource
//test complete data resource
data "shell_script" "test" {
lifecycle_commands {
create = <<EOF
touch test
EOF
read = <<EOF
echo '{"commit_id": "b8f2b8b"}' >&3
EOF
Expand Down Expand Up @@ -113,4 +115,30 @@ resource "shell_script" "test6" {
triggers = {
abc = 123
}
}

//resource with triggers
resource "shell_script" "test7" {
lifecycle_commands {
create = file("${path.module}/scripts/create.sh")
read = file("${path.module}/scripts/read.sh")
delete = file("${path.module}/scripts/delete.sh")
}

working_directory = "${path.module}"

environment = {
yolo = "yolo"
ball = "room"
}

triggers = {
abc = 123
}
timeouts {
create = "2m"
delete = "3m"
update = "2m"
read = "5m"
}
}
16 changes: 13 additions & 3 deletions shell/data_source_shell_script.go
Original file line number Diff line number Diff line change
@@ -1,16 +1,21 @@
package shell

import (
"log"

"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
"github.com/rs/xid"
"log"
"time"
)

func dataSourceShellScript() *schema.Resource {
return &schema.Resource{
Read: dataSourceShellScriptRead,

Timeouts: &schema.ResourceTimeout{
Create: schema.DefaultTimeout(10 * time.Minute),
Read: schema.DefaultTimeout(10 * time.Minute),
Update: schema.DefaultTimeout(10 * time.Minute),
Delete: schema.DefaultTimeout(10 * time.Minute),
},
Schema: map[string]*schema.Schema{
"lifecycle_commands": {
Type: schema.TypeList,
Expand All @@ -24,6 +29,11 @@ func dataSourceShellScript() *schema.Resource {
Required: true,
ForceNew: true,
},
"create": {
Type: schema.TypeString,
Required: true,
ForceNew: true,
},
},
},
},
Expand Down
12 changes: 9 additions & 3 deletions shell/resource_shell_script.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
package shell

import (
"log"
"reflect"

"github.com/hashicorp/terraform-plugin-sdk/helper/schema"
"github.com/rs/xid"
"log"
"reflect"
"time"
)

func resourceShellScript() *schema.Resource {
Expand All @@ -14,6 +14,12 @@ func resourceShellScript() *schema.Resource {
Delete: resourceShellScriptDelete,
Read: resourceShellScriptRead,
Update: resourceShellScriptUpdate,
Timeouts: &schema.ResourceTimeout{
Create: schema.DefaultTimeout(10 * time.Minute),
Read: schema.DefaultTimeout(10 * time.Minute),
Update: schema.DefaultTimeout(10 * time.Minute),
Delete: schema.DefaultTimeout(10 * time.Minute),
},
Schema: map[string]*schema.Schema{
"lifecycle_commands": {
Type: schema.TypeList,
Expand Down