Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reverting the changes from v1.212.0 to v1.211.0 #633

Merged
merged 1 commit into from
Mar 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
## Unreleased

## 1.213.0 (March, 13 2025)
BUG FIX:
* resource/spotinst_elastigroup_aws: Reverted `availability_zones` object to array of string as existing customer facing an issue.

## 1.212.0 (March, 12 2025)
ENHANCEMENTS:
* resource/spotinst_elastigroup_aws: Fixed `availability_zones` object to align with API route.
Expand Down
14 changes: 3 additions & 11 deletions docs/resources/elastigroup_aws.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,6 @@ resource "spotinst_elastigroup_aws" "default-elastigroup" {
region = "us-west-2"
subnet_ids = ["sb-123456", "sb-456789"]

# When availability_zones is set, subnet_ids should be left unused.
availability_zones {
availability_zones_name = "us-west-2a"
subnet_ids = ["subnet-123456"]
placement_group_name = "placementGroupName"
}

image_id = "ami-a27d8fda"
iam_instance_profile = "iam-profile"
key_name = "my-key.ssh"
Expand Down Expand Up @@ -167,10 +160,9 @@ The following arguments are supported:
* `product` - (Required) Operation system type. Valid values: `"Linux/UNIX"`, `"SUSE Linux"`, `"Windows"`.
For EC2 Classic instances: `"SUSE Linux (Amazon VPC)"`, `"Windows (Amazon VPC)"`.

* `availability_zones` - (Optional) One or more availability Zones for the group. When this parameter is set, compute.subnetIds should be left unused.
* `availability_zones_name` - (Required) The Availability Zone name.
* `subnet_ids` - (Optional) A comma-separated list of subnet identifiers for your group.
* `placement_group_name` - (Optional) specify a Placement Group name, the instances will be launched in the Placement Group for the AZ.
* `availability_zones` - (Optional) List of Strings of availability zones. When this parameter is set, `subnet_ids` should be left unused.
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:
`availability_zones = ["us-east-1a:subnet-123456:ClusterI03"]`

* `subnet_ids` - (Optional) List of Strings of subnet identifiers.
Note: When this parameter is set, `availability_zones` should be left unused.
Expand Down
10 changes: 5 additions & 5 deletions spotinst/elastigroup_aws/consts.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ const (
HealthCheckType commons.FieldName = "health_check_type"
HealthCheckUnhealthyDurationBeforeReplacement commons.FieldName = "health_check_unhealthy_duration_before_replacement"

Region commons.FieldName = "region"
SubnetIDs commons.FieldName = "subnet_ids"
AvailabilityZones commons.FieldName = "availability_zones"
PlacementGroupName commons.FieldName = "placement_group_name"
AvailabilityZoneName commons.FieldName = "availability_zones_name"
Region commons.FieldName = "region"
SubnetIDs commons.FieldName = "subnet_ids"
AvailabilityZones commons.FieldName = "availability_zones"
//PlacementGroupName commons.FieldName = "placement_group_name"
//AvailabilityZoneName commons.FieldName = "availability_zones_name"
PreferredAvailabilityZones commons.FieldName = "preferred_availability_zones"
ElasticLoadBalancers commons.FieldName = "elastic_load_balancers"
TargetGroupArns commons.FieldName = "target_group_arns"
Expand Down
45 changes: 32 additions & 13 deletions spotinst/elastigroup_aws/fields_spotinst_elastigroup_aws.go
Original file line number Diff line number Diff line change
Expand Up @@ -537,8 +537,9 @@ func Setup(fieldsMap map[commons.FieldName]*commons.GenericField) {
AvailabilityZones,
&schema.Schema{
Type: schema.TypeList,
Elem: &schema.Schema{Type: schema.TypeString},
Optional: true,
Elem: &schema.Resource{
/*Elem: &schema.Resource{
Schema: map[string]*schema.Schema{
string(SubnetIDs): {
Type: schema.TypeList,
Expand All @@ -555,10 +556,10 @@ func Setup(fieldsMap map[commons.FieldName]*commons.GenericField) {
Optional: true,
},
},
},
},*/
},
func(resourceObject interface{}, resourceData *schema.ResourceData, meta interface{}) error {
egWrapper := resourceObject.(*commons.ElastigroupWrapper)
/*egWrapper := resourceObject.(*commons.ElastigroupWrapper)
elastigroup := egWrapper.GetElastigroup()
var result []interface{} = nil
if elastigroup.Compute != nil && elastigroup.Compute.AvailabilityZones != nil {
Expand All @@ -569,33 +570,51 @@ func Setup(fieldsMap map[commons.FieldName]*commons.GenericField) {
if err := resourceData.Set(string(AvailabilityZones), result); err != nil {
return fmt.Errorf("failed to set availabilityZone configuration: %#v", err)
}
}
}*/
return nil
},
func(resourceObject interface{}, resourceData *schema.ResourceData, meta interface{}) error {
egWrapper := resourceObject.(*commons.ElastigroupWrapper)
elastigroup := egWrapper.GetElastigroup()
if v, ok := resourceData.GetOk(string(AvailabilityZones)); ok {
if availabilityZones, err := expandAvailabilityZones(v); err != nil {
return err
} else {
elastigroup.Compute.SetAvailabilityZones(availabilityZones)

if _, exists := resourceData.GetOk(string(SubnetIDs)); !exists {
if value, ok := resourceData.GetOk(string(AvailabilityZones)); ok {
if zones, err := expandAvailabilityZonesSlice(value); err != nil {
return err
} else {
elastigroup.Compute.SetAvailabilityZones(zones)
}
//this will be analysed again
/*if v, ok := resourceData.GetOk(string(AvailabilityZones)); ok {
if availabilityZones, err := expandAvailabilityZones(v); err != nil {
return err
} else {
elastigroup.Compute.SetAvailabilityZones(availabilityZones)*/
}
}
return nil
},
func(resourceObject interface{}, resourceData *schema.ResourceData, meta interface{}) error {
egWrapper := resourceObject.(*commons.ElastigroupWrapper)
elastigroup := egWrapper.GetElastigroup()
var result []*aws.AvailabilityZone = nil
/*var result []*aws.AvailabilityZone = nil
if v, ok := resourceData.GetOk(string(AvailabilityZones)); ok {
if availabilityZones, err := expandAvailabilityZones(v); err != nil {
return err
} else {
result = availabilityZones
}
}
elastigroup.Compute.SetAvailabilityZones(result)
elastigroup.Compute.SetAvailabilityZones(result)*/
if _, exists := resourceData.GetOk(string(SubnetIDs)); !exists {
if value, ok := resourceData.GetOk(string(AvailabilityZones)); ok {
if zones, err := expandAvailabilityZonesSlice(value); err != nil {
return err
} else {
elastigroup.Compute.SetAvailabilityZones(zones)
}
}
}
return nil
},
nil,
Expand Down Expand Up @@ -1412,7 +1431,7 @@ func extractTargetGroupFromArn(arn string) (string, error) {
return name, nil
}

func expandAvailabilityZones(data interface{}) ([]*aws.AvailabilityZone, error) {
/*func expandAvailabilityZones(data interface{}) ([]*aws.AvailabilityZone, error) {
if list := data.([]interface{}); len(list) > 0 {
availabilityZones := make([]*aws.AvailabilityZone, 0, len(list))
for _, item := range list {
Expand Down Expand Up @@ -1456,4 +1475,4 @@ func flattenAvailabilityZones(availabilityZones []*aws.AvailabilityZone) []inter
result = append(result, m)
}
return result
}
}*/