Skip to content

Commit 82f858d

Browse files
authored
Fix Iterative regions in AWS (#336)
* Fix Iterative regions in AWS * missing error * restore subnet code
1 parent 9463ea7 commit 82f858d

File tree

1 file changed

+11
-10
lines changed

1 file changed

+11
-10
lines changed

iterative/aws/provider.go

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ func ResourceMachineCreate(ctx context.Context, d *schema.ResourceData, m interf
2626
userData := d.Get("startup_script").(string)
2727
pairName := d.Id()
2828
hddSize := d.Get("instance_hdd_size").(int)
29-
region := GetRegion(d.Get("region").(string))
3029
instanceType := getInstanceType(d.Get("instance_type").(string), d.Get("instance_gpu").(string))
3130
ami := d.Get("image").(string)
3231
keyPublic := d.Get("ssh_public").(string)
@@ -35,7 +34,9 @@ func ResourceMachineCreate(ctx context.Context, d *schema.ResourceData, m interf
3534
spotPrice := d.Get("spot_price").(float64)
3635
instanceProfile := d.Get("instance_permission_set").(string)
3736
subnetId := d.Get("aws_subnet_id").(string)
38-
availabilityZone := GetAvailabilityZone(d.Get("region").(string))
37+
38+
region := GetRegion(d.Get("region").(string))
39+
availabilityZone := GetAvailabilityZone(region)
3940

4041
metadata := map[string]string{
4142
"Name": d.Get("name").(string),
@@ -417,14 +418,6 @@ func awsClient(region string) (aws.Config, error) {
417418
)
418419
}
419420

420-
func GetAvailabilityZone(region string) string {
421-
lastChar := region[len(region)-1]
422-
if lastChar >= 'a' && lastChar <= 'z' {
423-
return region
424-
}
425-
return ""
426-
}
427-
428421
//GetRegion maps region to real cloud regions
429422
func GetRegion(region string) string {
430423
instanceRegions := make(map[string]string)
@@ -439,6 +432,14 @@ func GetRegion(region string) string {
439432
return utils.StripAvailabilityZone(region)
440433
}
441434

435+
func GetAvailabilityZone(region string) string {
436+
lastChar := region[len(region)-1]
437+
if lastChar >= 'a' && lastChar <= 'z' {
438+
return region
439+
}
440+
return ""
441+
}
442+
442443
func getInstanceType(instanceType string, instanceGPU string) string {
443444
instanceTypes := make(map[string]string)
444445
instanceTypes["m"] = "m5.2xlarge"

0 commit comments

Comments
 (0)