Don't assign CIDRs to shared subnets

This commit is contained in:
John Gardiner Myers 2021-11-30 21:33:40 -08:00
parent 1e1a148280
commit d9d8708c7f
1 changed files with 7 additions and 1 deletions

View File

@ -192,6 +192,12 @@ func (s *Subnet) CheckChanges(a, e, changes *Subnet) error {
if changes.IPv6CIDR != nil && a.IPv6CIDR != nil {
errors = append(errors, fi.FieldIsImmutable(e.IPv6CIDR, a.IPv6CIDR, fieldPath.Child("IPv6CIDR")))
}
if fi.BoolValue(e.Shared) {
if changes.IPv6CIDR != nil && a.IPv6CIDR == nil {
errors = append(errors, field.Forbidden(fieldPath.Child("IPv6CIDR"), "field cannot be set on shared subnet"))
}
}
}
if len(errors) != 0 {
@ -206,7 +212,7 @@ func (_ *Subnet) RenderAWS(t *awsup.AWSAPITarget, a, e, changes *Subnet) error {
if shared {
// Verify the subnet was found
if a == nil {
return fmt.Errorf("Subnet with id %q not found", fi.StringValue(e.ID))
return fmt.Errorf("subnet with id %q not found", fi.StringValue(e.ID))
}
}