Skip to content

Commit 94664a5

Browse files
committed
credentials
1 parent 7f20aac commit 94664a5

File tree

2 files changed

+29
-16
lines changed

2 files changed

+29
-16
lines changed

examples/main.tf

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
terraform {
22
required_providers {
3-
# iterative = {
4-
# versions = ["0.6"]
5-
# source = "github.com/iterative/iterative"
6-
# }
7-
83
iterative = {
9-
source = "iterative/iterative"
10-
version = "0.5.5"
4+
versions = ["0.6"]
5+
source = "github.com/iterative/iterative"
116
}
7+
8+
# iterative = {
9+
# source = "iterative/iterative"
10+
# version = "0.5.6"
11+
# }
1212
}
1313
}
1414

@@ -23,7 +23,7 @@ resource "iterative_machine" "machine-az" {
2323
*/
2424

2525

26-
/* resource "iterative_runner" "runner-az" {
26+
resource "iterative_runner" "runner-az" {
2727
name = "holy-moly56"
2828
token = "arszDpb3xtNdKaXmQ6vN"
2929
repo = "https://gitlab.com/DavidGOrtega/3_tensorboard"
@@ -33,7 +33,7 @@ resource "iterative_machine" "machine-az" {
3333
cloud = "azure"
3434
region = "us-west"
3535
instance_type = "m"
36-
} */
36+
}
3737

3838
/*
3939
resource "iterative_machine" "machine-aws" {

iterative/resource_runner.go

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"encoding/json"
88
"fmt"
99
"html/template"
10+
"os"
1011
"strconv"
1112

1213
"github.com/hashicorp/terraform-plugin-sdk/v2/diag"
@@ -143,14 +144,12 @@ func resourceRunnerCreate(ctx context.Context, d *schema.ResourceData, m interfa
143144
}
144145
d.Set("custom_data", customData)
145146

146-
/*
147-
diags = append(diags, diag.Diagnostic{
148-
Severity: diag.Error,
149-
Summary: d.Get("custom_data").(string),
150-
})
147+
diags = append(diags, diag.Diagnostic{
148+
Severity: diag.Error,
149+
Summary: d.Get("custom_data").(string),
150+
})
151151

152-
return diags
153-
*/
152+
return diags
154153

155154
cloud := d.Get("cloud").(string)
156155
if len(cloud) == 0 {
@@ -220,14 +219,28 @@ func provisionerCode(d *schema.ResourceData) (string, error) {
220219
data["idle_timeout"] = strconv.Itoa(d.Get("idle_timeout").(int))
221220
data["name"] = d.Get("name").(string)
222221
data["tf_resource"] = base64.StdEncoding.EncodeToString(jsonResource)
222+
data["AWS_SECRET_ACCESS_KEY"] = os.Getenv("AWS_SECRET_ACCESS_KEY")
223+
data["AWS_ACCESS_KEY_ID"] = os.Getenv("AWS_ACCESS_KEY_ID")
224+
data["AZURE_CLIENT_ID"] = os.Getenv("AZURE_CLIENT_ID")
225+
data["AZURE_CLIENT_SECRET"] = os.Getenv("AZURE_CLIENT_SECRET")
226+
data["AZURE_SUBSCRIPTION_ID"] = os.Getenv("AZURE_SUBSCRIPTION_ID")
227+
data["AZURE_TENANT_ID"] = os.Getenv("AZURE_TENANT_ID")
223228

224229
tmpl, err := template.New("deploy").Parse(`#!/bin/bash
230+
export DEBIAN_FRONTEND=noninteractive
225231
echo "APT::Get::Assume-Yes \"true\";" | sudo tee -a /etc/apt/apt.conf.d/90assumeyes
226232
curl -sL https://deb.nodesource.com/setup_12.x | sudo bash
227233
curl -fsSL https://apt.releases.hashicorp.com/gpg | sudo apt-key add -
228234
sudo apt-add-repository "deb [arch=amd64] https://apt.releases.hashicorp.com $(lsb_release -cs) main"
229235
sudo apt update && sudo apt-get install -y terraform nodejs
230236
sudo npm install -g git+https://github.com/iterative/cml.git#cml-runner
237+
238+
export AWS_SECRET_ACCESS_KEY={{.AWS_SECRET_ACCESS_KEY}}
239+
export AWS_ACCESS_KEY_ID={{.AWS_ACCESS_KEY_ID}}
240+
export AZURE_CLIENT_ID={{.AZURE_CLIENT_ID}}
241+
export AZURE_CLIENT_SECRET={{.AZURE_CLIENT_SECRET}}
242+
export AZURE_SUBSCRIPTION_ID={{.AZURE_SUBSCRIPTION_ID}}
243+
export AZURE_TENANT_ID={{.AZURE_TENANT_ID}}
231244
nohup cml-runner{{if .name}} --name {{.name}}{{end}}{{if .labels}} --labels {{.labels}}{{end}}{{if .idle_timeout}} --idle-timeout {{.idle_timeout}}{{end}}{{if .driver}} --driver {{.driver}}{{end}}{{if .repo}} --repo {{.repo}}{{end}}{{if .token}} --token {{.token}}{{end}}{{if .tf_resource}} --tf_resource={{.tf_resource}}{{end}} < /dev/null > std.out 2> std.err &
232245
sleep 10
233246
`)

0 commit comments

Comments
 (0)