@@ -249,16 +249,36 @@ type NetworkSpec struct {
249
249
// IPv6 contains ipv6 specific settings for the network.
250
250
type IPv6 struct {
251
251
// CidrBlock is the CIDR block provided by Amazon when VPC has enabled IPv6.
252
+ // Mutually exclusive with IPAMPool.
252
253
// +optional
253
254
CidrBlock string `json:"cidrBlock,omitempty"`
254
255
255
256
// PoolID is the IP pool which must be defined in case of BYO IP is defined.
257
+ // Must be specified if CidrBlock is set.
258
+ // Mutually exclusive with IPAMPool.
256
259
// +optional
257
260
PoolID string `json:"poolId,omitempty"`
258
261
259
262
// EgressOnlyInternetGatewayID is the id of the egress only internet gateway associated with an IPv6 enabled VPC.
260
263
// +optional
261
264
EgressOnlyInternetGatewayID * string `json:"egressOnlyInternetGatewayId,omitempty"`
265
+
266
+ // IPAMPool defines the IPAMv6 pool to be used for VPC.
267
+ // Mutually exclusive with CidrBlock.
268
+ // +optional
269
+ IPAMPool * IPAMPool `json:"ipamPool,omitempty"`
270
+ }
271
+
272
+ // IPAMPool defines the IPAM pool to be used for VPC.
273
+ type IPAMPool struct {
274
+ // ID is the ID of the IPAM pool this provider should use to create VPC.
275
+ ID string `json:"id,omitempty"`
276
+ // Name is the name of the IPAM pool this provider should use to create VPC.
277
+ Name string `json:"name,omitempty"`
278
+ // The netmask length of the IPv4 CIDR you want to allocate to VPC from
279
+ // an Amazon VPC IP Address Manager (IPAM) pool.
280
+ // Defaults to /16 for IPv4 if not specified.
281
+ NetmaskLength int64 `json:"netmaskLength,omitempty"`
262
282
}
263
283
264
284
// VPCSpec configures an AWS VPC.
@@ -268,8 +288,13 @@ type VPCSpec struct {
268
288
269
289
// CidrBlock is the CIDR block to be used when the provider creates a managed VPC.
270
290
// Defaults to 10.0.0.0/16.
291
+ // Mutually exclusive with IPAMPool.
271
292
CidrBlock string `json:"cidrBlock,omitempty"`
272
293
294
+ // IPAMPool defines the IPAMv4 pool to be used for VPC.
295
+ // Mutually exclusive with CidrBlock.
296
+ IPAMPool * IPAMPool `json:"ipamPool,omitempty"`
297
+
273
298
// IPv6 contains ipv6 specific settings for the network. Supported only in managed clusters.
274
299
// This field cannot be set on AWSCluster object.
275
300
// +optional
@@ -323,8 +348,20 @@ func (v *VPCSpec) IsIPv6Enabled() bool {
323
348
// SubnetSpec configures an AWS Subnet.
324
349
type SubnetSpec struct {
325
350
// ID defines a unique identifier to reference this resource.
351
+ // If you're bringing your subnet, set the AWS subnet-id here, it must start with `subnet-`.
352
+ //
353
+ // When the VPC is managed by CAPA, and you'd like the provider to create a subnet for you,
354
+ // the id can be set to any placeholder value that does not start with `subnet-`;
355
+ // upon creation, the subnet AWS identifier will be populated in the `ResourceID` field and
356
+ // the `id` field is going to be used as the subnet name. If you specify a tag
357
+ // called `Name`, it takes precedence.
326
358
ID string `json:"id"`
327
359
360
+ // ResourceID is the subnet identifier from AWS, READ ONLY.
361
+ // This field is populated when the provider manages the subnet.
362
+ // +optional
363
+ ResourceID string `json:"resourceID,omitempty"`
364
+
328
365
// CidrBlock is the CIDR block to be used when the provider creates a managed VPC.
329
366
CidrBlock string `json:"cidrBlock,omitempty"`
330
367
@@ -359,9 +396,18 @@ type SubnetSpec struct {
359
396
Tags Tags `json:"tags,omitempty"`
360
397
}
361
398
399
+ // GetResourceID returns the identifier for this subnet,
400
+ // if the subnet was not created or reconciled, it returns the subnet ID.
401
+ func (s * SubnetSpec ) GetResourceID () string {
402
+ if s .ResourceID != "" {
403
+ return s .ResourceID
404
+ }
405
+ return s .ID
406
+ }
407
+
362
408
// String returns a string representation of the subnet.
363
409
func (s * SubnetSpec ) String () string {
364
- return fmt .Sprintf ("id=%s/az=%s/public=%v" , s .ID , s .AvailabilityZone , s .IsPublic )
410
+ return fmt .Sprintf ("id=%s/az=%s/public=%v" , s .GetResourceID () , s .AvailabilityZone , s .IsPublic )
365
411
}
366
412
367
413
// Subnets is a slice of Subnet.
@@ -374,7 +420,7 @@ func (s Subnets) ToMap() map[string]*SubnetSpec {
374
420
res := make (map [string ]* SubnetSpec )
375
421
for i := range s {
376
422
x := s [i ]
377
- res [x .ID ] = & x
423
+ res [x .GetResourceID () ] = & x
378
424
}
379
425
return res
380
426
}
@@ -383,19 +429,18 @@ func (s Subnets) ToMap() map[string]*SubnetSpec {
383
429
func (s Subnets ) IDs () []string {
384
430
res := []string {}
385
431
for _ , subnet := range s {
386
- res = append (res , subnet .ID )
432
+ res = append (res , subnet .GetResourceID () )
387
433
}
388
434
return res
389
435
}
390
436
391
437
// FindByID returns a single subnet matching the given id or nil.
392
438
func (s Subnets ) FindByID (id string ) * SubnetSpec {
393
439
for _ , x := range s {
394
- if x .ID == id {
440
+ if x .GetResourceID () == id {
395
441
return & x
396
442
}
397
443
}
398
-
399
444
return nil
400
445
}
401
446
@@ -404,7 +449,9 @@ func (s Subnets) FindByID(id string) *SubnetSpec {
404
449
// or if they are in the same vpc and the cidr block is the same.
405
450
func (s Subnets ) FindEqual (spec * SubnetSpec ) * SubnetSpec {
406
451
for _ , x := range s {
407
- if (spec .ID != "" && x .ID == spec .ID ) || (spec .CidrBlock == x .CidrBlock ) || (spec .IPv6CidrBlock != "" && spec .IPv6CidrBlock == x .IPv6CidrBlock ) {
452
+ if (spec .GetResourceID () != "" && x .GetResourceID () == spec .GetResourceID ()) ||
453
+ (spec .CidrBlock == x .CidrBlock ) ||
454
+ (spec .IPv6CidrBlock != "" && spec .IPv6CidrBlock == x .IPv6CidrBlock ) {
408
455
return & x
409
456
}
410
457
}
@@ -543,14 +590,17 @@ var (
543
590
544
591
// SecurityGroupProtocolICMPv6 represents the ICMPv6 protocol in ingress rules.
545
592
SecurityGroupProtocolICMPv6 = SecurityGroupProtocol ("58" )
593
+
594
+ // SecurityGroupProtocolESP represents the ESP protocol in ingress rules.
595
+ SecurityGroupProtocolESP = SecurityGroupProtocol ("50" )
546
596
)
547
597
548
598
// IngressRule defines an AWS ingress rule for security groups.
549
599
type IngressRule struct {
550
600
// Description provides extended information about the ingress rule.
551
601
Description string `json:"description"`
552
- // Protocol is the protocol for the ingress rule. Accepted values are "-1" (all), "4" (IP in IP),"tcp", "udp", "icmp", and "58" (ICMPv6).
553
- // +kubebuilder:validation:Enum="-1";"4";tcp;udp;icmp;"58"
602
+ // Protocol is the protocol for the ingress rule. Accepted values are "-1" (all), "4" (IP in IP),"tcp", "udp", "icmp", and "58" (ICMPv6), "50" (ESP) .
603
+ // +kubebuilder:validation:Enum="-1";"4";tcp;udp;icmp;"58";"50"
554
604
Protocol SecurityGroupProtocol `json:"protocol"`
555
605
// FromPort is the start of port range.
556
606
FromPort int64 `json:"fromPort"`
@@ -659,7 +709,7 @@ func (i *IngressRule) Equals(o *IngressRule) bool {
659
709
SecurityGroupProtocolICMP ,
660
710
SecurityGroupProtocolICMPv6 :
661
711
return i .FromPort == o .FromPort && i .ToPort == o .ToPort
662
- case SecurityGroupProtocolAll , SecurityGroupProtocolIPinIP :
712
+ case SecurityGroupProtocolAll , SecurityGroupProtocolIPinIP , SecurityGroupProtocolESP :
663
713
// FromPort / ToPort are not applicable
664
714
}
665
715
0 commit comments