in pkg/ec2helper/ec2helper.go [1062:1118]
func (h *EC2Helper) GetDefaultSimpleConfig() (*config.SimpleInfo, error) {
simpleConfig := config.NewSimpleInfo()
simpleConfig.Region = *h.Sess.Config.Region
// get info about the instance type
simpleConfig.InstanceType = "t2.micro"
defaultInstanceType, err := h.GetDefaultFreeTierInstanceType()
if err != nil {
return nil, err
}
if defaultInstanceType != nil {
simpleConfig.InstanceType = *defaultInstanceType.InstanceType
}
instanceTypeInfo, err := h.GetInstanceType(simpleConfig.InstanceType)
if err != nil {
return nil, err
}
// Use instance-store if supported
rootDeviceType := "ebs"
if *instanceTypeInfo.InstanceStorageSupported {
rootDeviceType = "instance-store"
}
image, err := h.GetDefaultImage(&rootDeviceType)
if err != nil {
return nil, err
}
simpleConfig.ImageId = *image.ImageId
vpc, err := h.getDefaultVpc()
if err != nil {
return nil, err
}
// Only set up network configuration when default VPC exists
if vpc != nil {
// Simply get all subnets and pick the first available subnet
subnets, err := h.GetSubnetsByVpc(*vpc.VpcId)
if err != nil {
return nil, err
}
subnet := subnets[0]
simpleConfig.SubnetId = *subnet.SubnetId
// Get the default security group
defaultSg, err := h.getDefaultSecurityGroup(*vpc.VpcId)
if err != nil {
return nil, err
}
simpleConfig.SecurityGroupIds = []string{*defaultSg.GroupId}
}
return simpleConfig, nil
}