Skip to content

Commit

Permalink
Feature/flowlog (crossplane-contrib#1415)
Browse files Browse the repository at this point in the history
* feat: Implemented FlowLog Resource

Signed-off-by: André Kesser <andre.kesser@dkb.de>
  • Loading branch information
akesser authored Aug 11, 2022
1 parent 978d56a commit 67f59ae
Show file tree
Hide file tree
Showing 25 changed files with 3,015 additions and 38 deletions.
38 changes: 38 additions & 0 deletions apis/cloudwatchlogs/generator-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,41 @@ ignore:
- ExportTask
field_paths:
- CreateLogGroupInput.KmsKeyId
resources:
LogGroup:
fields:
ARN:
is_read_only: true
from:
operation: DescribeLogGroups
path: LogGroups.Arn
CreationTime:
is_read_only: true
from:
operation: DescribeLogGroups
path: LogGroups.CreationTime
KmsKeyId:
is_read_only: true
from:
operation: DescribeLogGroups
path: LogGroups.KmsKeyId
LogGroupName:
is_read_only: true
from:
operation: DescribeLogGroups
path: LogGroups.LogGroupName
MetricFilterCount:
is_read_only: true
from:
operation: DescribeLogGroups
path: LogGroups.MetricFilterCount
RetentionInDays:
is_read_only: true
from:
operation: DescribeLogGroups
path: LogGroups.RetentionInDays
StoredBytes:
is_read_only: true
from:
operation: DescribeLogGroups
path: LogGroups.StoredBytes
33 changes: 33 additions & 0 deletions apis/cloudwatchlogs/v1alpha1/referencers.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
Copyright 2021 The Crossplane Authors.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package v1alpha1

import (
"github.com/crossplane/crossplane-runtime/pkg/reference"
resource "github.com/crossplane/crossplane-runtime/pkg/resource"
)

// LogGroupARN returns the status.atProvider.ARN of a LogGroup.
func LogGroupARN() reference.ExtractValueFn {
return func(mg resource.Managed) string {
r, ok := mg.(*LogGroup)
if !ok {
return ""
}
if r.Status.AtProvider.ARN == nil {
return ""
}
return *r.Status.AtProvider.ARN
}
}
37 changes: 36 additions & 1 deletion apis/cloudwatchlogs/v1alpha1/zz_generated.deepcopy.go

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

15 changes: 15 additions & 0 deletions apis/cloudwatchlogs/v1alpha1/zz_log_group.go

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

48 changes: 48 additions & 0 deletions apis/ec2/generator-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,17 @@ ignore:
- CreateVolumeInput.ClientToken
- CreateVpcEndpointInput.ClientToken
- CreateVpcEndpointOutput.ClientToken
- CreateFlowLogsInput.ResourceIds
- CreateFlowLogsInput.ResourceType
- CreateFlowLogsInput.TagSpecifications
- CreateFlowLogsInput.DeliverLogsPermissionARN
- DescribeFlowLogsInput.FlowLogIds
- DescribeFlowLogsInput.DryRun
- CreateFlowLogsOutput.FlowLogIds
- CreateFlowLogsOutput.Unsuccessful
- CreateFlowLogsInput.DryRun
- DeleteFlowLogsInput.FlowLogIds
- DeleteFlowLogsInput.DryRun
resources:
Volume:
exceptions:
Expand All @@ -146,3 +157,40 @@ resources:
errors:
404:
code: InvalidRoute.NotFound
FlowLog:
fields:
FlowLogId:
is_read_only: true
from:
operation: DescribeFlowLogs
path: FlowLogs.FlowLogId
FlowLogStatus:
is_read_only: true
from:
operation: DescribeFlowLogs
path: FlowLogs.FlowLogStatus
DeliverLogsStatus:
is_read_only: true
from:
operation: DescribeFlowLogs
path: FlowLogs.DeliverLogsStatus
CreationTime:
is_read_only: true
from:
operation: DescribeFlowLogs
path: FlowLogs.CreationTime
ResourceId:
is_read_only: true
from:
operation: DescribeFlowLogs
path: FlowLogs.ResourceId
Tags:
is_read_only: true
from:
operation: DescribeFlowLogs
path: FlowLogs.Tags
operations:
CreateFlowLogs:
operation_type:
- Create
resource_name: FlowLog
129 changes: 129 additions & 0 deletions apis/ec2/v1alpha1/custom_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -449,3 +449,132 @@ type CustomTransitGatewayRouteTableParameters struct {
// +optional
Tags []Tag `json:"tags,omitempty"`
}

// CustomFlowLogParameters are custom parameters for FlowLogParameters
type CustomFlowLogParameters struct {
// Metadata tagging key value pairs
// +optional
Tags []Tag `json:"tags,omitempty"`
// The ID of the subnet, network interface, or VPC for which you want to create
// a flow log.
//
// Constraints: Maximum of 1000 resources
// +optional
ResourceIDs []*string `json:"resourceIDs"`
// The type of resource for which to create the flow log. For example, if you
// specified a VPC ID for the ResourceId property, specify VPC for this property.
// +optional
ResourceType *string `json:"resourceType"`
// The ID of the VPC for which you want to create a flow log.
// +optional
// +crossplane:generate:reference:type=github.com/crossplane-contrib/provider-aws/apis/ec2/v1beta1.VPC
VPCID *string `json:"vpcId,omitempty"`
// VPCIDRef is a reference to an API used to set
// the VPCID.
// +optional
VPCIDRef *xpv1.Reference `json:"vpcIdRef,omitempty"`
// VPCIDSelector selects references to API used
// to set the VPCID.
// +optional
VPCIDSelector *xpv1.Selector `json:"vpcIdSelector,omitempty"`

// The ID of the TransitGateway for which you want to create a flow log.
// +optional
// +crossplane:generate:reference:type=TransitGateway
TransitGatewayID *string `json:"transitGatewayId,omitempty"`

// TransitGatewayIDRef is a reference to an API used to set
// the TransitGatewayID.
// +optional
TransitGatewayIDRef *xpv1.Reference `json:"transitGatewayIdRef,omitempty"`

// TransitGatewayIDSelector selects references to API used
// to set the TransitGatewayID.
// +optional
TransitGatewayIDSelector *xpv1.Selector `json:"transitGatewayIdSelector,omitempty"`

// The ID of the TransitGatewayAttachment for which you want to create a flow log.
// +optional
// +crossplane:generate:reference:type=TransitGatewayVPCAttachment
TransitGatewayAttachmentID *string `json:"transitGatewayAttachmentId,omitempty"`

// TransitGatewayAttachmentIDRef is a reference to an API used to set
// the TransitGatewayAttachmentID.
// +optional
TransitGatewayAttachmentIDRef *xpv1.Reference `json:"transitGatewayAttachmentIdRef,omitempty"`

// TransitGatewayAttachmentIDSelector selects references to API used
// to set the TransitGatewayAttachmentID.
// +optional
TransitGatewayAttachmentIDSelector *xpv1.Selector `json:"transitGatewayAttachmentIdSelector,omitempty"`

// The ID of the one or more Subnets for which you want to create a flow log.
// +optional
// +crossplane:generate:reference:type=github.com/crossplane-contrib/provider-aws/apis/ec2/v1beta1.Subnet
SubnetID *string `json:"subnetId,omitempty"`

// SubnetIDRefs is a referenc to a SubnetID used to set
// the SubnetID.
// +optional
SubnetIDRef *xpv1.Reference `json:"subnetIdRef,omitempty"`

// SubnetIDSelector selects reference to a SubnetID used
// to set the SubnetID.
// +optional
SubnetIDSelector *xpv1.Selector `json:"subnetIdSelector,omitempty"`

// The ID of the NetworkInterface for which you want to create a flow log.
// +optional
NetworkInterfaceID *string `json:"networkInterfaceId"`

// The Amazon Resource Names (ARNs) of an IAM Role.
// +crossplane:generate:reference:type=github.com/crossplane-contrib/provider-aws/apis/iam/v1beta1.Role
// +crossplane:generate:reference:extractor=github.com/crossplane-contrib/provider-aws/apis/iam/v1beta1.RoleARN()
DeliverLogsPermissionARN *string `json:"deliverLogsPermissionArn,omitempty"`

// DeliverLogsPermissionARNRef is a reference to DeliverLogsPermissionARN used to set
// the DeliverLogsPermissionARN.
// +optional
DeliverLogsPermissionARNRef *xpv1.Reference `json:"deliverLogsPermissionArnRef,omitempty"`

// DeliverLogsPermissionARNelector selects a reference to DeliverLogsPermissionARN used
// to set the DeliverLogsPermissionARN.
// +optional
DeliverLogsPermissionARNSelector *xpv1.Selector `json:"deliverLogsPermissionArnSelector,omitempty"`

// The Amazon Resource Names (ARNs) of a CloudWatch Log Group.
// +crossplane:generate:reference:type=github.com/crossplane-contrib/provider-aws/apis/cloudwatchlogs/v1alpha1.LogGroup
// +crossplane:generate:reference:extractor=github.com/crossplane-contrib/provider-aws/apis/cloudwatchlogs/v1alpha1.LogGroupARN()
CloudWatchLogDestination *string `json:"cloudWatchLogDestination,omitempty"`

// CloudWatchLogDestinationRef is a reference to a CloudWatch Log Group used to set
// the CloudWatchLogDestination.
// +optional
CloudWatchLogDestinationRef *xpv1.Reference `json:"cloudWatchLogDestinationRef,omitempty"`

// CloudWatchLogDestinationSelector selects a reference to a CloudWatch Log Group used
// to set the CloudWatchLogDestination.
// +optional
CloudWatchLogDestinationSelector *xpv1.Selector `json:"cloudWatchLogDestinationSelector,omitempty"`

// The Amazon Resource Names (ARNs) of a CloudWatch Log Group.
// +crossplane:generate:reference:type=github.com/crossplane-contrib/provider-aws/apis/s3/v1beta1.Bucket
// +crossplane:generate:reference:extractor=github.com/crossplane-contrib/provider-aws/apis/s3/v1beta1.BucketARN()
S3BucketLogDestination *string `json:"s3BucketLogDestination,omitempty"`

// S3BucketLogDestinationRef is a reference to a S3 Bucket to set
// the S3BucketLogDestination.
// +optional
S3BucketLogDestinationRef *xpv1.Reference `json:"s3BucketLogDestinationRef,omitempty"`

// S3BucketLogDestinationSelector selects a reference to a S3 Bucket used
// to set the S3BucketLogDestination.
// +optional
S3BucketLogDestinationSelector *xpv1.Selector `json:"s3BucketLogDestinationSelector,omitempty"`

// S3BucketSubfolder allows you to use a subfolder in a S3Bucket, if S3BucketLogDestination is used to determin the ARN of a Bucket managed by crossplane
// S3BucketSubfolder starts and ends without an slash e.g. test/test2
// You cannot use AWSLogs as a subfolder name. This is a reserved term.
// +optional
S3BucketSubfolder *string `json:"s3BucketSubfolder,omitempty"`
}
Loading

0 comments on commit 67f59ae

Please sign in to comment.