diff --git a/apis/clusters/v1beta1/generic_spec.go b/apis/clusters/v1beta1/generic_spec.go index f7f9502c..45d52fe4 100644 --- a/apis/clusters/v1beta1/generic_spec.go +++ b/apis/clusters/v1beta1/generic_spec.go @@ -209,7 +209,7 @@ func (s *GenericDataCentreSpec) cloudProviderSettingsFromInstAPI(instaModel *mod } switch { - case len(instaModel.AWSSettings) > 0: + case len(instaModel.AWSSettings) > 0 && instaModel.HasAWSCloudProviderSettings(): setting := instaModel.AWSSettings[0] s.AWSSettings = []*AWSSettings{{ DiskEncryptionKey: setting.EBSEncryptionKey, diff --git a/pkg/models/apiv2_generic.go b/pkg/models/apiv2_generic.go index e7ea9c85..46529604 100644 --- a/pkg/models/apiv2_generic.go +++ b/pkg/models/apiv2_generic.go @@ -25,3 +25,18 @@ type GenericDataCentreFields struct { *CloudProviderSettings `json:",inline"` } + +func (dc *CloudProviderSettings) HasAWSCloudProviderSettings() bool { + if dc == nil { + return false + } + + zero := AWSSetting{} + for _, s := range dc.AWSSettings { + if *s == zero { + return false + } + } + + return true +}