Skip to content

Commit 1327dd4

Browse files
committed
Add ami input to provider
1 parent 51169af commit 1327dd4

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

README.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ terraform {
1111
required_providers {
1212
iterative = {
1313
source = "iterative/iterative"
14-
version = "0.5.0"
14+
version = "0.5.1"
1515
}
1616
}
1717
}
@@ -32,6 +32,7 @@ resource "iterative_machine" "machine" {
3232
| Variable | Values | Default | |
3333
| ------- | ------ | -------- | ------------- |
3434
| ```region``` | ```us-west``` ```us-east``` ```eu-west``` ```eu-north``` | ```us-west``` | Sets the collocation region |
35+
| ```ami``` | | ```iterative-cml``` | Sets the ami to be used. For that the provider does a search in the cloud provider by image name not by id, taking the lastest version in case there are many with the same name. Defaults to [iterative-cml image](#iterative-cml-image) |
3536
| ```instance_name``` | | cml_{UID} | Sets the instance name and related resources like AWS key pair. |
3637
| ```instance_hdd_size``` | | 10 | Sets the instance hard disk size in gb |
3738
| ```instance_type``` | ```m```, ```l```, ```xl``` | ```m``` | Sets thee instance computing size. You can also specify vendor specific machines in AWS i.e. ```t2.micro``` |
@@ -65,3 +66,11 @@ The instance type in AWS is calculated joining the ```instance_type``` and ```in
6566
| us-east | us-east-1 |
6667
| eu-north | us-north-1 |
6768
| eu-west | us-west-1 |
69+
70+
# Iterative CML image
71+
72+
It's a GPU ready image based on Ubuntu 18.04. It has the following stack already installed:
73+
74+
- nvidia drivers
75+
- docker
76+
- nvidia-docker

iterative/resource_machine.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,12 @@ func resourceMachine() *schema.Resource {
2727
ForceNew: true,
2828
Default: "us-west",
2929
},
30+
"ami": &schema.Schema{
31+
Type: schema.TypeString,
32+
Optional: true,
33+
ForceNew: true,
34+
Default: "iterative-cml",
35+
},
3036
"instance_name": &schema.Schema{
3137
Type: schema.TypeString,
3238
Optional: true,
@@ -112,11 +118,13 @@ func resourceMachineCreate(ctx context.Context, d *schema.ResourceData, m interf
112118
return diag.FromErr(errClient)
113119
}
114120

121+
ami := d.Get("ami").(string)
122+
115123
imagesRes, imagesErr := svc.DescribeImages(&ec2.DescribeImagesInput{
116124
Filters: []*ec2.Filter{
117125
{
118126
Name: aws.String("name"),
119-
Values: []*string{aws.String("iterative-cml")},
127+
Values: []*string{aws.String(ami)},
120128
},
121129
{
122130
Name: aws.String("architecture"),
@@ -130,7 +138,7 @@ func resourceMachineCreate(ctx context.Context, d *schema.ResourceData, m interf
130138
if len(imagesRes.Images) == 0 {
131139
diags = append(diags, diag.Diagnostic{
132140
Severity: diag.Error,
133-
Summary: "iterative-cml ami not found in region",
141+
Summary: ami + " ami not found in region",
134142
})
135143

136144
return diags

0 commit comments

Comments
 (0)