Skip to content

Commit

Permalink
Merge pull request #1517 from BGrasnick/master
Browse files Browse the repository at this point in the history
Add docs for SecurityGroupRule to fix #1516
  • Loading branch information
haarchri authored Oct 7, 2022
2 parents eaf99fb + 1632dca commit 02d807e
Show file tree
Hide file tree
Showing 6 changed files with 20 additions and 14 deletions.
7 changes: 5 additions & 2 deletions apis/ec2/manualv1alpha1/securitygrouprule_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,14 +58,17 @@ type SecurityGroupRuleParameters struct {
// +kubebuilder:validation:Required
Region *string `json:"region"`

// If using a SecurityGroup managed by crossplane as reference,
// enable ignoreIngress or ignoreEgress on the sg to prevent the
// rules to be constantly created and deleted
// +crossplane:generate:reference:type=github.com/crossplane-contrib/provider-aws/apis/ec2/v1beta1.SecurityGroup
// +kubebuilder:validation:Optional
// +immutable
SecurityGroupID *string `json:"securityGroupId,omitempty"`

// If using a SecurittyGroup managed by crossplane as reference,
// If using a SecurityGroup managed by crossplane as reference,
// enable ignoreIngress or ignoreEgress on the sg to prevent the
// roules to be constantly created and deleted
// rules to be constantly created and deleted
// +kubebuilder:validation:Optional
// +immutable
SecurityGroupIDRef *xpv1.Reference `json:"securityGroupIdRef,omitempty"`
Expand Down
4 changes: 2 additions & 2 deletions apis/ec2/v1beta1/securitygroup_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,10 @@ type SecurityGroupParameters struct {
VPCIDSelector *xpv1.Selector `json:"vpcIdSelector,omitempty"`

// Dont manage the ingress settings for the created resource
IgnorIngress *bool `json:"ignoreIngress,omitempty"`
IgnoreIngress *bool `json:"ignoreIngress,omitempty"`

// Dont manage the egress settings for the created resource
IgnorEgress *bool `json:"ignoreEgress,omitempty"`
IgnoreEgress *bool `json:"ignoreEgress,omitempty"`
}

// IPRange describes an IPv4 range.
Expand Down
8 changes: 4 additions & 4 deletions apis/ec2/v1beta1/zz_generated.deepcopy.go

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

7 changes: 5 additions & 2 deletions package/crds/ec2.aws.crossplane.io_securitygrouprules.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,14 @@ spec:
be created in.
type: string
securityGroupId:
description: If using a SecurityGroup managed by crossplane as
reference, enable ignoreIngress or ignoreEgress on the sg to
prevent the rules to be constantly created and deleted
type: string
securityGroupIdRef:
description: If using a SecurittyGroup managed by crossplane as
description: If using a SecurityGroup managed by crossplane as
reference, enable ignoreIngress or ignoreEgress on the sg to
prevent the roules to be constantly created and deleted
prevent the rules to be constantly created and deleted
properties:
name:
description: Name of the referenced object.
Expand Down
4 changes: 2 additions & 2 deletions pkg/clients/ec2/securitygroup.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,13 +130,13 @@ func IsSGUpToDate(sg v1beta1.SecurityGroupParameters, observed ec2types.Security
return false
}

if !awsclients.BoolValue(sg.IgnorIngress) {
if !awsclients.BoolValue(sg.IgnoreIngress) {
add, remove := DiffPermissions(GenerateEC2Permissions(sg.Ingress), observed.IpPermissions)
if len(add) > 0 || len(remove) > 0 {
return false
}
}
if !awsclients.BoolValue(sg.IgnorEgress) {
if !awsclients.BoolValue(sg.IgnoreEgress) {
add, remove := DiffPermissions(GenerateEC2Permissions(sg.Egress), observed.IpPermissionsEgress)
if len(add) > 0 || len(remove) > 0 {
return false
Expand Down
4 changes: 2 additions & 2 deletions pkg/controller/ec2/securitygroup/controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ func (e *external) Update(ctx context.Context, mgd resource.Managed) (managed.Ex
}
}

if !awsclient.BoolValue(cr.Spec.ForProvider.IgnorIngress) {
if !awsclient.BoolValue(cr.Spec.ForProvider.IgnoreIngress) {
add, remove := ec2.DiffPermissions(ec2.GenerateEC2Permissions(cr.Spec.ForProvider.Ingress), response.SecurityGroups[0].IpPermissions)
if len(remove) > 0 {
if _, err := e.sg.RevokeSecurityGroupIngress(ctx, &awsec2.RevokeSecurityGroupIngressInput{
Expand All @@ -261,7 +261,7 @@ func (e *external) Update(ctx context.Context, mgd resource.Managed) (managed.Ex
}
}

if !awsclient.BoolValue(cr.Spec.ForProvider.IgnorEgress) {
if !awsclient.BoolValue(cr.Spec.ForProvider.IgnoreEgress) {
add, remove := ec2.DiffPermissions(ec2.GenerateEC2Permissions(cr.Spec.ForProvider.Egress), response.SecurityGroups[0].IpPermissionsEgress)
if len(remove) > 0 {
if _, err = e.sg.RevokeSecurityGroupEgress(ctx, &awsec2.RevokeSecurityGroupEgressInput{
Expand Down

0 comments on commit 02d807e

Please sign in to comment.