Skip to content

Commit

Permalink
PLT-150-1:Added VPCID check for static provisioning (#179)
Browse files Browse the repository at this point in the history
  • Loading branch information
SivaanandM authored Dec 12, 2022
1 parent 5d8a0b7 commit ddce923
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions spectrocloud/resource_cluster_aws.go
Original file line number Diff line number Diff line change
Expand Up @@ -578,8 +578,8 @@ func resourceClusterAwsUpdate(ctx context.Context, d *schema.ResourceData, m int
name := machinePoolResource["name"].(string)
if name != "" {
hash := resourceMachinePoolAwsHash(machinePoolResource)

machinePool := toMachinePoolAws(machinePoolResource)
vpcId := d.Get("cloud_config").([]interface{})[0].(map[string]interface{})["vpc_id"]
machinePool := toMachinePoolAws(machinePoolResource, vpcId.(string))

var err error
if oldMachinePool, ok := osMap[name]; !ok {
Expand Down Expand Up @@ -649,7 +649,7 @@ func toAwsCluster(c *client.V1Client, d *schema.ResourceData) *models.V1SpectroA
//for _, machinePool := range d.Get("machine_pool").([]interface{}) {
machinePoolConfigs := make([]*models.V1AwsMachinePoolConfigEntity, 0)
for _, machinePool := range d.Get("machine_pool").(*schema.Set).List() {
mp := toMachinePoolAws(machinePool)
mp := toMachinePoolAws(machinePool, cluster.Spec.CloudConfig.VpcID)
machinePoolConfigs = append(machinePoolConfigs, mp)
}

Expand All @@ -659,7 +659,7 @@ func toAwsCluster(c *client.V1Client, d *schema.ResourceData) *models.V1SpectroA
return cluster
}

func toMachinePoolAws(machinePool interface{}) *models.V1AwsMachinePoolConfigEntity {
func toMachinePoolAws(machinePool interface{}, vpcId string) *models.V1AwsMachinePoolConfigEntity {
m := machinePool.(map[string]interface{})

labels := make([]string, 0)
Expand All @@ -675,7 +675,7 @@ func toMachinePoolAws(machinePool interface{}) *models.V1AwsMachinePoolConfigEnt
capacityType = m["capacity_type"].(string)
}
azSubnetsConfigs := make([]*models.V1AwsSubnetEntity, 0)
if m["az_subnets"] != nil && len(m["az_subnets"].(map[string]interface{})) > 0 {
if m["az_subnets"] != nil && len(m["az_subnets"].(map[string]interface{})) > 0 && vpcId != "" {
for key, azSubnet := range m["az_subnets"].(map[string]interface{}) {
azs = append(azs, key)
azSubnetsConfigs = append(azSubnetsConfigs, &models.V1AwsSubnetEntity{
Expand Down

0 comments on commit ddce923

Please sign in to comment.