Skip to content

Commit 6802196

Browse files
committed
pre-release
1 parent 31af450 commit 6802196

File tree

4 files changed

+17
-19
lines changed

4 files changed

+17
-19
lines changed

examples/main.tf

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,14 +11,14 @@ provider "iterative" {}
1111

1212

1313
resource "iterative_machine" "machine-aws" {
14-
driver = "aws"
14+
cloud = "aws"
1515
region = "us-west"
1616
instance_type = "t2.micro" //fallback to known instance type
1717
}
1818

1919

20-
resource "iterative_machine" "machine-azure" {
21-
driver = "azure"
20+
/* resource "iterative_machine" "machine-azure" {
21+
cloud = "azure"
2222
region = "us-west"
2323
instance_type = "m"
2424
@@ -33,11 +33,11 @@ resource "iterative_machine" "machine-azure" {
3333
host = "${self.instance_ip}"
3434
}
3535
}
36-
}
36+
} */
3737

3838

3939
/* resource "iterative_machine" "machine-azure-gpu" {
40-
driver = "azure"
40+
cloud = "azure"
4141
region = "us-east"
4242
instance_type = "m"
4343
instance_gpu = "k80"

iterative/aws/provider.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ func ResourceMachineCreate(ctx context.Context, d *schema.ResourceData, m interf
2828
}
2929

3030
// Image
31-
ami := ""
31+
ami := d.Get("image").(string)
3232
if ami == "" {
3333
ami = "iterative-cml"
3434
}

iterative/azure/provider.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ func ResourceMachineCreate(ctx context.Context, d *schema.ResourceData, m interf
3030
vmName := d.Get("instance_name").(string)
3131
hddSize := int32(d.Get("instance_hdd_size").(int))
3232

33-
image := d.Get("ami").(string)
33+
image := d.Get("image").(string)
3434
if image == "" {
3535
image = "Canonical:UbuntuServer:18.04-LTS:latest"
3636
}

iterative/resource_machine.go

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ func resourceMachine() *schema.Resource {
2020
ReadContext: resourceMachineRead,
2121
UpdateContext: resourceMachineUpdate,
2222
Schema: map[string]*schema.Schema{
23-
"driver": &schema.Schema{
23+
"cloud": &schema.Schema{
2424
Type: schema.TypeString,
2525
Required: true,
2626
ForceNew: true,
@@ -31,7 +31,7 @@ func resourceMachine() *schema.Resource {
3131
ForceNew: true,
3232
Default: "us-west",
3333
},
34-
"ami": &schema.Schema{
34+
"image": &schema.Schema{
3535
Type: schema.TypeString,
3636
Optional: true,
3737
ForceNew: true,
@@ -61,7 +61,6 @@ func resourceMachine() *schema.Resource {
6161
ForceNew: true,
6262
Default: "",
6363
},
64-
6564
"instance_id": &schema.Schema{
6665
Type: schema.TypeString,
6766
Optional: true,
@@ -89,12 +88,12 @@ func resourceMachine() *schema.Resource {
8988
Optional: true,
9089
Computed: true,
9190
},
91+
9292
"key_name": &schema.Schema{
9393
Type: schema.TypeString,
9494
Optional: true,
9595
Computed: true,
9696
},
97-
9897
"aws_security_group": &schema.Schema{
9998
Type: schema.TypeString,
10099
Optional: true,
@@ -109,7 +108,6 @@ func resourceMachineCreate(ctx context.Context, d *schema.ResourceData, m interf
109108
var diags diag.Diagnostics
110109

111110
keyPublic := d.Get("key_public").(string)
112-
//keyPrivate := d.Get("key_private").(string)
113111

114112
if len(keyPublic) == 0 {
115113
public, private, _ := utils.SSHKeyPair()
@@ -127,30 +125,30 @@ func resourceMachineCreate(ctx context.Context, d *schema.ResourceData, m interf
127125
d.Set("instance_name", instanceName)
128126
}
129127

130-
driver := d.Get("driver").(string)
128+
cloud := d.Get("cloud").(string)
131129

132-
if driver == "aws" {
130+
if cloud == "aws" {
133131
return aws.ResourceMachineCreate(ctx, d, m)
134132
}
135133

136-
if driver == "azure" {
134+
if cloud == "azure" {
137135
return azure.ResourceMachineCreate(ctx, d, m)
138136
}
139137

140138
diags = append(diags, diag.Diagnostic{
141139
Severity: diag.Error,
142-
Summary: fmt.Sprintf("Unknown provider: %s", driver),
140+
Summary: fmt.Sprintf("Unknown cloud: %s", cloud),
143141
})
144142
return diags
145143
}
146144

147145
func resourceMachineDelete(ctx context.Context, d *schema.ResourceData, m interface{}) diag.Diagnostics {
148-
driver := d.Get("driver").(string)
149-
if driver == "aws" {
146+
cloud := d.Get("cloud").(string)
147+
if cloud == "aws" {
150148
return aws.ResourceMachineDelete(ctx, d, m)
151149
}
152150

153-
if driver == "azure" {
151+
if cloud == "azure" {
154152
return azure.ResourceMachineDelete(ctx, d, m)
155153
}
156154

0 commit comments

Comments
 (0)