Skip to content

Commit 49a8042

Browse files
committed
reverting the changes from v1.212.0 to v1.211.0
reverting the changes from v1.212.0 to v1.211.0
1 parent 908e299 commit 49a8042

File tree

4 files changed

+44
-29
lines changed

4 files changed

+44
-29
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
## Unreleased
22

3+
## 1.213.0 (March, 13 2025)
4+
BUG FIX:
5+
* resource/spotinst_elastigroup_aws: Reverted `availability_zones` object to array of string as existing customer facing an issue.
6+
37
## 1.212.0 (March, 12 2025)
48
ENHANCEMENTS:
59
* resource/spotinst_elastigroup_aws: Fixed `availability_zones` object to align with API route.

docs/resources/elastigroup_aws.md

+3-11
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,6 @@ resource "spotinst_elastigroup_aws" "default-elastigroup" {
2828
region = "us-west-2"
2929
subnet_ids = ["sb-123456", "sb-456789"]
3030
31-
# When availability_zones is set, subnet_ids should be left unused.
32-
availability_zones {
33-
availability_zones_name = "us-west-2a"
34-
subnet_ids = ["subnet-123456"]
35-
placement_group_name = "placementGroupName"
36-
}
37-
3831
image_id = "ami-a27d8fda"
3932
iam_instance_profile = "iam-profile"
4033
key_name = "my-key.ssh"
@@ -167,10 +160,9 @@ The following arguments are supported:
167160
* `product` - (Required) Operation system type. Valid values: `"Linux/UNIX"`, `"SUSE Linux"`, `"Windows"`.
168161
For EC2 Classic instances: `"SUSE Linux (Amazon VPC)"`, `"Windows (Amazon VPC)"`.
169162

170-
* `availability_zones` - (Optional) One or more availability Zones for the group. When this parameter is set, compute.subnetIds should be left unused.
171-
* `availability_zones_name` - (Required) The Availability Zone name.
172-
* `subnet_ids` - (Optional) A comma-separated list of subnet identifiers for your group.
173-
* `placement_group_name` - (Optional) specify a Placement Group name, the instances will be launched in the Placement Group for the AZ.
163+
* `availability_zones` - (Optional) List of Strings of availability zones. When this parameter is set, `subnet_ids` should be left unused.
164+
Note: `availability_zones` naming syntax follows the convention `availability-zone:subnet:placement-group-name`. For example, to set an AZ in `us-east-1` with subnet `subnet-123456` and placement group `ClusterI03`, you would set:
165+
`availability_zones = ["us-east-1a:subnet-123456:ClusterI03"]`
174166

175167
* `subnet_ids` - (Optional) List of Strings of subnet identifiers.
176168
Note: When this parameter is set, `availability_zones` should be left unused.

spotinst/elastigroup_aws/consts.go

+5-5
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,11 @@ const (
3434
HealthCheckType commons.FieldName = "health_check_type"
3535
HealthCheckUnhealthyDurationBeforeReplacement commons.FieldName = "health_check_unhealthy_duration_before_replacement"
3636

37-
Region commons.FieldName = "region"
38-
SubnetIDs commons.FieldName = "subnet_ids"
39-
AvailabilityZones commons.FieldName = "availability_zones"
40-
PlacementGroupName commons.FieldName = "placement_group_name"
41-
AvailabilityZoneName commons.FieldName = "availability_zones_name"
37+
Region commons.FieldName = "region"
38+
SubnetIDs commons.FieldName = "subnet_ids"
39+
AvailabilityZones commons.FieldName = "availability_zones"
40+
//PlacementGroupName commons.FieldName = "placement_group_name"
41+
//AvailabilityZoneName commons.FieldName = "availability_zones_name"
4242
PreferredAvailabilityZones commons.FieldName = "preferred_availability_zones"
4343
ElasticLoadBalancers commons.FieldName = "elastic_load_balancers"
4444
TargetGroupArns commons.FieldName = "target_group_arns"

spotinst/elastigroup_aws/fields_spotinst_elastigroup_aws.go

+32-13
Original file line numberDiff line numberDiff line change
@@ -537,8 +537,9 @@ func Setup(fieldsMap map[commons.FieldName]*commons.GenericField) {
537537
AvailabilityZones,
538538
&schema.Schema{
539539
Type: schema.TypeList,
540+
Elem: &schema.Schema{Type: schema.TypeString},
540541
Optional: true,
541-
Elem: &schema.Resource{
542+
/*Elem: &schema.Resource{
542543
Schema: map[string]*schema.Schema{
543544
string(SubnetIDs): {
544545
Type: schema.TypeList,
@@ -555,10 +556,10 @@ func Setup(fieldsMap map[commons.FieldName]*commons.GenericField) {
555556
Optional: true,
556557
},
557558
},
558-
},
559+
},*/
559560
},
560561
func(resourceObject interface{}, resourceData *schema.ResourceData, meta interface{}) error {
561-
egWrapper := resourceObject.(*commons.ElastigroupWrapper)
562+
/*egWrapper := resourceObject.(*commons.ElastigroupWrapper)
562563
elastigroup := egWrapper.GetElastigroup()
563564
var result []interface{} = nil
564565
if elastigroup.Compute != nil && elastigroup.Compute.AvailabilityZones != nil {
@@ -569,33 +570,51 @@ func Setup(fieldsMap map[commons.FieldName]*commons.GenericField) {
569570
if err := resourceData.Set(string(AvailabilityZones), result); err != nil {
570571
return fmt.Errorf("failed to set availabilityZone configuration: %#v", err)
571572
}
572-
}
573+
}*/
573574
return nil
574575
},
575576
func(resourceObject interface{}, resourceData *schema.ResourceData, meta interface{}) error {
576577
egWrapper := resourceObject.(*commons.ElastigroupWrapper)
577578
elastigroup := egWrapper.GetElastigroup()
578-
if v, ok := resourceData.GetOk(string(AvailabilityZones)); ok {
579-
if availabilityZones, err := expandAvailabilityZones(v); err != nil {
580-
return err
581-
} else {
582-
elastigroup.Compute.SetAvailabilityZones(availabilityZones)
579+
580+
if _, exists := resourceData.GetOk(string(SubnetIDs)); !exists {
581+
if value, ok := resourceData.GetOk(string(AvailabilityZones)); ok {
582+
if zones, err := expandAvailabilityZonesSlice(value); err != nil {
583+
return err
584+
} else {
585+
elastigroup.Compute.SetAvailabilityZones(zones)
586+
}
587+
//this will be analysed again
588+
/*if v, ok := resourceData.GetOk(string(AvailabilityZones)); ok {
589+
if availabilityZones, err := expandAvailabilityZones(v); err != nil {
590+
return err
591+
} else {
592+
elastigroup.Compute.SetAvailabilityZones(availabilityZones)*/
583593
}
584594
}
585595
return nil
586596
},
587597
func(resourceObject interface{}, resourceData *schema.ResourceData, meta interface{}) error {
588598
egWrapper := resourceObject.(*commons.ElastigroupWrapper)
589599
elastigroup := egWrapper.GetElastigroup()
590-
var result []*aws.AvailabilityZone = nil
600+
/*var result []*aws.AvailabilityZone = nil
591601
if v, ok := resourceData.GetOk(string(AvailabilityZones)); ok {
592602
if availabilityZones, err := expandAvailabilityZones(v); err != nil {
593603
return err
594604
} else {
595605
result = availabilityZones
596606
}
597607
}
598-
elastigroup.Compute.SetAvailabilityZones(result)
608+
elastigroup.Compute.SetAvailabilityZones(result)*/
609+
if _, exists := resourceData.GetOk(string(SubnetIDs)); !exists {
610+
if value, ok := resourceData.GetOk(string(AvailabilityZones)); ok {
611+
if zones, err := expandAvailabilityZonesSlice(value); err != nil {
612+
return err
613+
} else {
614+
elastigroup.Compute.SetAvailabilityZones(zones)
615+
}
616+
}
617+
}
599618
return nil
600619
},
601620
nil,
@@ -1412,7 +1431,7 @@ func extractTargetGroupFromArn(arn string) (string, error) {
14121431
return name, nil
14131432
}
14141433

1415-
func expandAvailabilityZones(data interface{}) ([]*aws.AvailabilityZone, error) {
1434+
/*func expandAvailabilityZones(data interface{}) ([]*aws.AvailabilityZone, error) {
14161435
if list := data.([]interface{}); len(list) > 0 {
14171436
availabilityZones := make([]*aws.AvailabilityZone, 0, len(list))
14181437
for _, item := range list {
@@ -1456,4 +1475,4 @@ func flattenAvailabilityZones(availabilityZones []*aws.AvailabilityZone) []inter
14561475
result = append(result, m)
14571476
}
14581477
return result
1459-
}
1478+
}*/

0 commit comments

Comments
 (0)