Skip to content

Commit b5e38e4

Browse files
DavidGOrtegarestyled-io[bot]restyled-commits
authored
release/0.5.1 Add ami input to provider (#7)
* Add ami input to provider * Restyled by prettier-markdown (#8) Co-authored-by: Restyled.io <commits@restyled.io> Co-authored-by: restyled-io[bot] <32688539+restyled-io[bot]@users.noreply.github.com> Co-authored-by: Restyled.io <commits@restyled.io>
1 parent 51169af commit b5e38e4

File tree

2 files changed

+57
-35
lines changed

2 files changed

+57
-35
lines changed

README.md

Lines changed: 47 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@
22

33
# Terraform Provider Iterative
44

5-
The Terraform Iterative provider is a plugin for Terraform that allows for the full lifecycle management of GPU or non GPU cloud resources with your favourite [vendor](#supported-vendors). The provider offers a simple and homogeneous way to deploy a GPU or a cluster of them reducing the complexity.
5+
The Terraform Iterative provider is a plugin for Terraform that allows for the
6+
full lifecycle management of GPU or non GPU cloud resources with your favourite
7+
[vendor](#supported-vendors). The provider offers a simple and homogeneous way
8+
to deploy a GPU or a cluster of them reducing the complexity.
69

710
# Usage
811

@@ -11,7 +14,7 @@ terraform {
1114
required_providers {
1215
iterative = {
1316
source = "iterative/iterative"
14-
version = "0.5.0"
17+
version = "0.5.1"
1518
}
1619
}
1720
}
@@ -29,39 +32,50 @@ resource "iterative_machine" "machine" {
2932

3033
## Argument reference
3134

32-
| Variable | Values | Default | |
33-
| ------- | ------ | -------- | ------------- |
34-
| ```region``` | ```us-west``` ```us-east``` ```eu-west``` ```eu-north``` | ```us-west``` | Sets the collocation region |
35-
| ```instance_name``` | | cml_{UID} | Sets the instance name and related resources like AWS key pair. |
36-
| ```instance_hdd_size``` | | 10 | Sets the instance hard disk size in gb |
37-
| ```instance_type``` | ```m```, ```l```, ```xl``` | ```m``` | Sets thee instance computing size. You can also specify vendor specific machines in AWS i.e. ```t2.micro``` |
38-
| ```instance_gpu``` | ``` ```, ```testla```, ```k80``` | ``` ``` | Sets the desired GPU if the ```instance_type``` is one of our types. |
39-
| ```key_public``` | | | Set up ssh access with your OpenSSH public key. If not provided one be automatically generated and returned in terraform.tfstate |
40-
| aws_security_group | | ```cml``` | AWS specific variable to setup an specific security group. If specified the instance will be launched in with that sg within the vpc managed by the specified sg. If not a new sg called ```cml``` will be created under the default vpc |
41-
35+
| Variable | Values | Default | |
36+
| ------------------- | ---------------------------------------- | --------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
37+
| `region` | `us-west` `us-east` `eu-west` `eu-north` | `us-west` | Sets the collocation region |
38+
| `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) |
39+
| `instance_name` | | cml\_{UID} | Sets the instance name and related resources like AWS key pair. |
40+
| `instance_hdd_size` | | 10 | Sets the instance hard disk size in gb |
41+
| `instance_type` | `m`, `l`, `xl` | `m` | Sets thee instance computing size. You can also specify vendor specific machines in AWS i.e. `t2.micro` |
42+
| `instance_gpu` | ``, `testla`, `k80` | `` | Sets the desired GPU if the `instance_type` is one of our types. |
43+
| `key_public` | | | Set up ssh access with your OpenSSH public key. If not provided one be automatically generated and returned in terraform.tfstate |
44+
| aws_security_group | | `cml` | AWS specific variable to setup an specific security group. If specified the instance will be launched in with that sg within the vpc managed by the specified sg. If not a new sg called `cml` will be created under the default vpc |
4245

4346
# Supported vendors
4447

45-
- AWS
46-
48+
- AWS
49+
4750
### AWS instance equivalences.
48-
The instance type in AWS is calculated joining the ```instance_type``` and ```instance_gpu```
49-
50-
| type | gpu | aws |
51-
| ------- | ------ | -------- |
52-
| m | | m5.2xlarge |
53-
| l | | m5.8xlarge |
54-
| xl | | m5.16xlarge |
55-
| m | k80 | p2.xlarge |
56-
| l | k80 | p2.8xlarge |
57-
| xl | k80 | p2.16xlarge |
58-
| m | tesla | p3.xlarge |
59-
| l | tesla | p3.8xlarge |
60-
| xl | tesla | p3.16xlarge |
61-
62-
| region | aws |
63-
| ------- | ------ |
64-
| us-west | us-west-1 |
65-
| us-east | us-east-1 |
51+
52+
The instance type in AWS is calculated joining the `instance_type` and
53+
`instance_gpu`
54+
55+
| type | gpu | aws |
56+
| ---- | ----- | ----------- |
57+
| m | | m5.2xlarge |
58+
| l | | m5.8xlarge |
59+
| xl | | m5.16xlarge |
60+
| m | k80 | p2.xlarge |
61+
| l | k80 | p2.8xlarge |
62+
| xl | k80 | p2.16xlarge |
63+
| m | tesla | p3.xlarge |
64+
| l | tesla | p3.8xlarge |
65+
| xl | tesla | p3.16xlarge |
66+
67+
| region | aws |
68+
| -------- | ---------- |
69+
| us-west | us-west-1 |
70+
| us-east | us-east-1 |
6671
| eu-north | us-north-1 |
67-
| eu-west | us-west-1 |
72+
| eu-west | us-west-1 |
73+
74+
# Iterative CML image
75+
76+
It's a GPU ready image based on Ubuntu 18.04. It has the following stack already
77+
installed:
78+
79+
- nvidia drivers
80+
- docker
81+
- 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)