Skip to content

Commit 8ae7933

Browse files
committed
hotfix/CML_TOKEN check
1 parent 793d2c8 commit 8ae7933

File tree

2 files changed

+105
-1
lines changed

2 files changed

+105
-1
lines changed

examples/main.tf

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
terraform {
2+
required_providers {
3+
iterative = {
4+
versions = ["0.6"]
5+
source = "github.com/iterative/iterative"
6+
}
7+
8+
# iterative = {
9+
# source = "iterative/iterative"
10+
# // version = "0.5.7"
11+
# }
12+
}
13+
}
14+
15+
provider "iterative" {}
16+
17+
18+
resource "iterative_cml_runner" "runner-aws" {
19+
name = "holy-moly57"
20+
repo = "https://github.com/DavidGOrtega/3_tensorboard"
21+
driver = "github"
22+
labels = "tf"
23+
24+
cloud = "aws"
25+
region = "us-west"
26+
instance_type = "t2.micro"
27+
}
28+
29+
30+
resource "iterative_cml_runner" "runner-az" {
31+
name = "holy-moly56"
32+
repo = "https://github.com/DavidGOrtega/3_tensorboard"
33+
driver = "github"
34+
labels = "tf"
35+
36+
cloud = "azure"
37+
region = "us-west"
38+
instance_type = "m"
39+
}
40+
41+
42+
/*
43+
resource "iterative_machine" "machine-az" {
44+
cloud = "azure"
45+
region = "us-east"
46+
instance_type = "m"
47+
48+
provisioner "remote-exec" {
49+
scripts = [
50+
"provision.sh",
51+
]
52+
53+
connection {
54+
user = "ubuntu"
55+
private_key = "${self.ssh_private}"
56+
host = "${self.instance_ip}"
57+
}
58+
}
59+
}
60+
*/
61+
62+
63+
/* resource "iterative_machine" "machine-azure-gpu" {
64+
cloud = "azure"
65+
region = "us-east"
66+
instance_type = "m"
67+
instance_gpu = "k80"
68+
69+
provisioner "remote-exec" {
70+
inline = [
71+
"echo 'hello azure'",
72+
"nvidia-smi"
73+
]
74+
75+
connection {
76+
user = "ubuntu"
77+
private_key = "${self.key_private}"
78+
host = "${self.instance_ip}"
79+
}
80+
}
81+
} */
82+
/*
83+
resource "iterative_machine" "machine-aws" {
84+
name = "cml-aws4"
85+
cloud = "aws"
86+
region = "us-west"
87+
instance_type = "t2.micro" //fallback to known instance type
88+
} */
89+
90+
/* resource "iterative_machine" "machine-az" {
91+
name = "cml-azure"
92+
cloud = "azure"
93+
region = "us-west"
94+
instance_type = "m"
95+
} */

iterative/resource_runner.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,9 @@ func resourceRunner() *schema.Resource {
2929
},
3030
"token": &schema.Schema{
3131
Type: schema.TypeString,
32-
Required: true,
32+
Optional: true,
3333
ForceNew: true,
34+
Default: "",
3435
},
3536
"driver": &schema.Schema{
3637
Type: schema.TypeString,
@@ -131,6 +132,14 @@ func resourceRunnerCreate(ctx context.Context, d *schema.ResourceData, m interfa
131132
d.Set("token", token)
132133
}
133134

135+
if len(d.Get("token").(string)) == 0 {
136+
diags = append(diags, diag.Diagnostic{
137+
Severity: diag.Error,
138+
Summary: fmt.Sprintf("Token not found nor in tf file nor in env CML_TOKEN"),
139+
})
140+
return diags
141+
}
142+
134143
startupScript, err := provisionerCode(d)
135144
if err != nil {
136145
diags = append(diags, diag.Diagnostic{

0 commit comments

Comments
 (0)