Skip to content

Commit

Permalink
Support modify vpc peering options (#1459)
Browse files Browse the repository at this point in the history
Signed-off-by: zhengjiajin <zhengjiajin@pingcap.com>

Signed-off-by: zhengjiajin <zhengjiajin@pingcap.com>
  • Loading branch information
zjj2wry committed Sep 19, 2022
1 parent 6d69baf commit ffae9f2
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 0 deletions.
7 changes: 7 additions & 0 deletions apis/ec2/v1alpha1/custom_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,13 @@ type CustomVPCPeeringConnectionParameters struct {
// Metadata tagging key value pairs
// +optional
Tags []Tag `json:"tags,omitempty"`

// RequesterPeeringOptions describes the Requester VPC peering connection options.
// +optional
RequesterPeeringOptions *VPCPeeringConnectionOptionsDescription `json:"requesterPeeringOptions,omitempty"`
// AccepterRequesterPeeringOptions describes the Accepter VPC peering connection options.
// +optional
AccepterPeeringOptions *VPCPeeringConnectionOptionsDescription `json:"accepterPeeringOptions,omitempty"`
}

// CustomTransitGatewayParameters are custom parameters for TransitGateway
Expand Down
10 changes: 10 additions & 0 deletions apis/ec2/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 22 additions & 0 deletions package/crds/ec2.aws.crossplane.io_vpcpeeringconnections.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,17 @@ spec:
will be in pending-acceptance state. This will only lead to
an active connection if both VPCs are in the same tenant.
type: boolean
accepterPeeringOptions:
description: AccepterRequesterPeeringOptions describes the Accepter
VPC peering connection options.
properties:
allowDNSResolutionFromRemoteVPC:
type: boolean
allowEgressFromLocalClassicLinkToRemoteVPC:
type: boolean
allowEgressFromLocalVPCToRemoteClassicLink:
type: boolean
type: object
peerOwnerID:
description: "The Amazon Web Services account ID of the owner
of the accepter VPC. \n Default: Your Amazon Web Services account
Expand Down Expand Up @@ -164,6 +175,17 @@ spec:
description: Region is which region the VPCPeeringConnection will
be created.
type: string
requesterPeeringOptions:
description: RequesterPeeringOptions describes the Requester VPC
peering connection options.
properties:
allowDNSResolutionFromRemoteVPC:
type: boolean
allowEgressFromLocalClassicLinkToRemoteVPC:
type: boolean
allowEgressFromLocalVPCToRemoteClassicLink:
type: boolean
type: object
tagSpecifications:
description: The tags to assign to the peering connection.
items:
Expand Down
27 changes: 27 additions & 0 deletions pkg/controller/ec2/vpcpeeringconnection/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package vpcpeeringconnection

import (
"context"
"reflect"
"sort"
"time"

Expand Down Expand Up @@ -96,6 +97,32 @@ func (e *custom) postObserve(_ context.Context, cr *svcapitypes.VPCPeeringConnec
}
}

if !reflect.DeepEqual(obj.VpcPeeringConnections[0].AccepterVpcInfo.PeeringOptions, cr.Spec.ForProvider.AccepterPeeringOptions) ||
!reflect.DeepEqual(obj.VpcPeeringConnections[0].RequesterVpcInfo.PeeringOptions, cr.Spec.ForProvider.RequesterPeeringOptions) {
req := svcsdk.ModifyVpcPeeringConnectionOptionsInput{
VpcPeeringConnectionId: awsclients.String(*obj.VpcPeeringConnections[0].VpcPeeringConnectionId),
}
if cr.Spec.ForProvider.AccepterPeeringOptions != nil {
req.AccepterPeeringConnectionOptions = &svcsdk.PeeringConnectionOptionsRequest{
AllowDnsResolutionFromRemoteVpc: cr.Spec.ForProvider.AccepterPeeringOptions.AllowDNSResolutionFromRemoteVPC,
AllowEgressFromLocalClassicLinkToRemoteVpc: cr.Spec.ForProvider.AccepterPeeringOptions.AllowEgressFromLocalClassicLinkToRemoteVPC,
AllowEgressFromLocalVpcToRemoteClassicLink: cr.Spec.ForProvider.AccepterPeeringOptions.AllowEgressFromLocalVPCToRemoteClassicLink,
}
}
if cr.Spec.ForProvider.RequesterPeeringOptions != nil {
req.RequesterPeeringConnectionOptions = &svcsdk.PeeringConnectionOptionsRequest{
AllowDnsResolutionFromRemoteVpc: cr.Spec.ForProvider.RequesterPeeringOptions.AllowDNSResolutionFromRemoteVPC,
AllowEgressFromLocalClassicLinkToRemoteVpc: cr.Spec.ForProvider.RequesterPeeringOptions.AllowEgressFromLocalClassicLinkToRemoteVPC,
AllowEgressFromLocalVpcToRemoteClassicLink: cr.Spec.ForProvider.RequesterPeeringOptions.AllowEgressFromLocalVPCToRemoteClassicLink,
}
}
request, _ := e.client.ModifyVpcPeeringConnectionOptionsRequest(&req)
err := request.Send()
if err != nil {
return obs, err
}
}

available := setCondition(obj.VpcPeeringConnections[0].Status, cr)
if !available {
return managed.ExternalObservation{ResourceExists: false}, nil
Expand Down

0 comments on commit ffae9f2

Please sign in to comment.