diff --git a/apis/cloudwatchlogs/generator-config.yaml b/apis/cloudwatchlogs/generator-config.yaml index 8a35200b1a..b81f1c52a7 100644 --- a/apis/cloudwatchlogs/generator-config.yaml +++ b/apis/cloudwatchlogs/generator-config.yaml @@ -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 diff --git a/apis/cloudwatchlogs/v1alpha1/referencers.go b/apis/cloudwatchlogs/v1alpha1/referencers.go new file mode 100644 index 0000000000..4dcd9cd74f --- /dev/null +++ b/apis/cloudwatchlogs/v1alpha1/referencers.go @@ -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 + } +} diff --git a/apis/cloudwatchlogs/v1alpha1/zz_generated.deepcopy.go b/apis/cloudwatchlogs/v1alpha1/zz_generated.deepcopy.go index 031ca509f2..136d896708 100644 --- a/apis/cloudwatchlogs/v1alpha1/zz_generated.deepcopy.go +++ b/apis/cloudwatchlogs/v1alpha1/zz_generated.deepcopy.go @@ -248,6 +248,41 @@ func (in *LogGroupList) DeepCopyObject() runtime.Object { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *LogGroupObservation) DeepCopyInto(out *LogGroupObservation) { *out = *in + if in.ARN != nil { + in, out := &in.ARN, &out.ARN + *out = new(string) + **out = **in + } + if in.CreationTime != nil { + in, out := &in.CreationTime, &out.CreationTime + *out = new(int64) + **out = **in + } + if in.KMSKeyID != nil { + in, out := &in.KMSKeyID, &out.KMSKeyID + *out = new(string) + **out = **in + } + if in.LogGroupName != nil { + in, out := &in.LogGroupName, &out.LogGroupName + *out = new(string) + **out = **in + } + if in.MetricFilterCount != nil { + in, out := &in.MetricFilterCount, &out.MetricFilterCount + *out = new(int64) + **out = **in + } + if in.RetentionInDays != nil { + in, out := &in.RetentionInDays, &out.RetentionInDays + *out = new(int64) + **out = **in + } + if in.StoredBytes != nil { + in, out := &in.StoredBytes, &out.StoredBytes + *out = new(int64) + **out = **in + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new LogGroupObservation. @@ -317,7 +352,7 @@ func (in *LogGroupSpec) DeepCopy() *LogGroupSpec { func (in *LogGroupStatus) DeepCopyInto(out *LogGroupStatus) { *out = *in in.ResourceStatus.DeepCopyInto(&out.ResourceStatus) - out.AtProvider = in.AtProvider + in.AtProvider.DeepCopyInto(&out.AtProvider) } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new LogGroupStatus. diff --git a/apis/cloudwatchlogs/v1alpha1/zz_log_group.go b/apis/cloudwatchlogs/v1alpha1/zz_log_group.go index b3c3f618c8..6dcc1291c3 100644 --- a/apis/cloudwatchlogs/v1alpha1/zz_log_group.go +++ b/apis/cloudwatchlogs/v1alpha1/zz_log_group.go @@ -50,6 +50,21 @@ type LogGroupSpec struct { // LogGroupObservation defines the observed state of LogGroup type LogGroupObservation struct { + // The Amazon Resource Name (ARN) of the log group. + ARN *string `json:"arn,omitempty"` + // The creation time of the log group, expressed as the number of milliseconds + // after Jan 1, 1970 00:00:00 UTC. + CreationTime *int64 `json:"creationTime,omitempty"` + // The Amazon Resource Name (ARN) of the CMK to use when encrypting log data. + KMSKeyID *string `json:"kmsKeyID,omitempty"` + // The name of the log group. + LogGroupName *string `json:"logGroupName,omitempty"` + // The number of metric filters. + MetricFilterCount *int64 `json:"metricFilterCount,omitempty"` + + RetentionInDays *int64 `json:"retentionInDays,omitempty"` + // The number of bytes stored. + StoredBytes *int64 `json:"storedBytes,omitempty"` } // LogGroupStatus defines the observed state of LogGroup. diff --git a/apis/ec2/generator-config.yaml b/apis/ec2/generator-config.yaml index f2f6c43490..e2274caa64 100644 --- a/apis/ec2/generator-config.yaml +++ b/apis/ec2/generator-config.yaml @@ -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: @@ -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 \ No newline at end of file diff --git a/apis/ec2/v1alpha1/custom_types.go b/apis/ec2/v1alpha1/custom_types.go index 8508194404..31b109a550 100644 --- a/apis/ec2/v1alpha1/custom_types.go +++ b/apis/ec2/v1alpha1/custom_types.go @@ -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"` +} diff --git a/apis/ec2/v1alpha1/zz_flow_log.go b/apis/ec2/v1alpha1/zz_flow_log.go new file mode 100644 index 0000000000..998f5c3177 --- /dev/null +++ b/apis/ec2/v1alpha1/zz_flow_log.go @@ -0,0 +1,164 @@ +/* +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. +*/ + +// Code generated by ack-generate. DO NOT EDIT. + +package v1alpha1 + +import ( + xpv1 "github.com/crossplane/crossplane-runtime/apis/common/v1" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + "k8s.io/apimachinery/pkg/runtime/schema" +) + +// FlowLogParameters defines the desired state of FlowLog +type FlowLogParameters struct { + // Region is which region the FlowLog will be created. + // +kubebuilder:validation:Required + Region string `json:"region"` + // Unique, case-sensitive identifier that you provide to ensure the idempotency + // of the request. For more information, see How to ensure idempotency (https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/Run_Instance_Idempotency.html). + ClientToken *string `json:"clientToken,omitempty"` + // The ARN for the IAM role that permits Amazon EC2 to publish flow logs to + // a CloudWatch Logs log group in your account. + // + // If you specify LogDestinationType as s3, do not specify DeliverLogsPermissionArn + // or LogGroupName. + DeliverLogsPermissionARN *string `json:"deliverLogsPermissionARN,omitempty"` + // The destination options. + DestinationOptions *DestinationOptionsRequest `json:"destinationOptions,omitempty"` + // The destination to which the flow log data is to be published. Flow log data + // can be published to a CloudWatch Logs log group or an Amazon S3 bucket. The + // value specified for this parameter depends on the value specified for LogDestinationType. + // + // If LogDestinationType is not specified or cloud-watch-logs, specify the Amazon + // Resource Name (ARN) of the CloudWatch Logs log group. For example, to publish + // to a log group called my-logs, specify arn:aws:logs:us-east-1:123456789012:log-group:my-logs. + // Alternatively, use LogGroupName instead. + // + // If LogDestinationType is s3, specify the ARN of the Amazon S3 bucket. You + // can also specify a subfolder in the bucket. To specify a subfolder in the + // bucket, use the following ARN format: bucket_ARN/subfolder_name/. For example, + // to specify a subfolder named my-logs in a bucket named my-bucket, use the + // following ARN: arn:aws:s3:::my-bucket/my-logs/. You cannot use AWSLogs as + // a subfolder name. This is a reserved term. + LogDestination *string `json:"logDestination,omitempty"` + // The type of destination to which the flow log data is to be published. Flow + // log data can be published to CloudWatch Logs or Amazon S3. To publish flow + // log data to CloudWatch Logs, specify cloud-watch-logs. To publish flow log + // data to Amazon S3, specify s3. + // + // If you specify LogDestinationType as s3, do not specify DeliverLogsPermissionArn + // or LogGroupName. + // + // Default: cloud-watch-logs + LogDestinationType *string `json:"logDestinationType,omitempty"` + // The fields to include in the flow log record, in the order in which they + // should appear. For a list of available fields, see Flow log records (https://docs.aws.amazon.com/vpc/latest/userguide/flow-logs.html#flow-log-records). + // If you omit this parameter, the flow log is created using the default format. + // If you specify this parameter, you must specify at least one field. + // + // Specify the fields using the ${field-id} format, separated by spaces. For + // the CLI, surround this parameter value with single quotes on Linux or double + // quotes on Windows. + LogFormat *string `json:"logFormat,omitempty"` + // The name of a new or existing CloudWatch Logs log group where Amazon EC2 + // publishes your flow logs. + // + // If you specify LogDestinationType as s3, do not specify DeliverLogsPermissionArn + // or LogGroupName. + LogGroupName *string `json:"logGroupName,omitempty"` + // The maximum interval of time during which a flow of packets is captured and + // aggregated into a flow log record. You can specify 60 seconds (1 minute) + // or 600 seconds (10 minutes). + // + // When a network interface is attached to a Nitro-based instance (https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instance-types.html#ec2-nitro-instances), + // the aggregation interval is always 60 seconds or less, regardless of the + // value that you specify. + // + // Default: 600 + MaxAggregationInterval *int64 `json:"maxAggregationInterval,omitempty"` + // The type of traffic to log. You can log traffic that the resource accepts + // or rejects, or all traffic. + // +kubebuilder:validation:Required + TrafficType *string `json:"trafficType"` + CustomFlowLogParameters `json:",inline"` +} + +// FlowLogSpec defines the desired state of FlowLog +type FlowLogSpec struct { + xpv1.ResourceSpec `json:",inline"` + ForProvider FlowLogParameters `json:"forProvider"` +} + +// FlowLogObservation defines the observed state of FlowLog +type FlowLogObservation struct { + // The date and time the flow log was created. + CreationTime *metav1.Time `json:"creationTime,omitempty"` + // The status of the logs delivery (SUCCESS | FAILED). + DeliverLogsStatus *string `json:"deliverLogsStatus,omitempty"` + // The flow log ID. + FlowLogID *string `json:"flowLogID,omitempty"` + // The status of the flow log (ACTIVE). + FlowLogStatus *string `json:"flowLogStatus,omitempty"` + // The ID of the resource on which the flow log was created. + ResourceID *string `json:"resourceID,omitempty"` + // The tags for the flow log. + Tags []*Tag `json:"tags,omitempty"` +} + +// FlowLogStatus defines the observed state of FlowLog. +type FlowLogStatus struct { + xpv1.ResourceStatus `json:",inline"` + AtProvider FlowLogObservation `json:"atProvider,omitempty"` +} + +// +kubebuilder:object:root=true + +// FlowLog is the Schema for the FlowLogs API +// +kubebuilder:printcolumn:name="READY",type="string",JSONPath=".status.conditions[?(@.type=='Ready')].status" +// +kubebuilder:printcolumn:name="SYNCED",type="string",JSONPath=".status.conditions[?(@.type=='Synced')].status" +// +kubebuilder:printcolumn:name="EXTERNAL-NAME",type="string",JSONPath=".metadata.annotations.crossplane\\.io/external-name" +// +kubebuilder:subresource:status +// +kubebuilder:storageversion +// +kubebuilder:resource:scope=Cluster,categories={crossplane,managed,aws} +type FlowLog struct { + metav1.TypeMeta `json:",inline"` + metav1.ObjectMeta `json:"metadata,omitempty"` + Spec FlowLogSpec `json:"spec"` + Status FlowLogStatus `json:"status,omitempty"` +} + +// +kubebuilder:object:root=true + +// FlowLogList contains a list of FlowLogs +type FlowLogList struct { + metav1.TypeMeta `json:",inline"` + metav1.ListMeta `json:"metadata,omitempty"` + Items []FlowLog `json:"items"` +} + +// Repository type metadata. +var ( + FlowLogKind = "FlowLog" + FlowLogGroupKind = schema.GroupKind{Group: CRDGroup, Kind: FlowLogKind}.String() + FlowLogKindAPIVersion = FlowLogKind + "." + GroupVersion.String() + FlowLogGroupVersionKind = GroupVersion.WithKind(FlowLogKind) +) + +func init() { + SchemeBuilder.Register(&FlowLog{}, &FlowLogList{}) +} diff --git a/apis/ec2/v1alpha1/zz_generated.deepcopy.go b/apis/ec2/v1alpha1/zz_generated.deepcopy.go index 4c1d781a16..d3105b6b96 100644 --- a/apis/ec2/v1alpha1/zz_generated.deepcopy.go +++ b/apis/ec2/v1alpha1/zz_generated.deepcopy.go @@ -2427,6 +2427,159 @@ func (in *CreditSpecificationRequest) DeepCopy() *CreditSpecificationRequest { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *CustomFlowLogParameters) DeepCopyInto(out *CustomFlowLogParameters) { + *out = *in + if in.Tags != nil { + in, out := &in.Tags, &out.Tags + *out = make([]Tag, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.ResourceIDs != nil { + in, out := &in.ResourceIDs, &out.ResourceIDs + *out = make([]*string, len(*in)) + for i := range *in { + if (*in)[i] != nil { + in, out := &(*in)[i], &(*out)[i] + *out = new(string) + **out = **in + } + } + } + if in.ResourceType != nil { + in, out := &in.ResourceType, &out.ResourceType + *out = new(string) + **out = **in + } + if in.VPCID != nil { + in, out := &in.VPCID, &out.VPCID + *out = new(string) + **out = **in + } + if in.VPCIDRef != nil { + in, out := &in.VPCIDRef, &out.VPCIDRef + *out = new(v1.Reference) + (*in).DeepCopyInto(*out) + } + if in.VPCIDSelector != nil { + in, out := &in.VPCIDSelector, &out.VPCIDSelector + *out = new(v1.Selector) + (*in).DeepCopyInto(*out) + } + if in.TransitGatewayID != nil { + in, out := &in.TransitGatewayID, &out.TransitGatewayID + *out = new(string) + **out = **in + } + if in.TransitGatewayIDRef != nil { + in, out := &in.TransitGatewayIDRef, &out.TransitGatewayIDRef + *out = new(v1.Reference) + (*in).DeepCopyInto(*out) + } + if in.TransitGatewayIDSelector != nil { + in, out := &in.TransitGatewayIDSelector, &out.TransitGatewayIDSelector + *out = new(v1.Selector) + (*in).DeepCopyInto(*out) + } + if in.TransitGatewayAttachmentID != nil { + in, out := &in.TransitGatewayAttachmentID, &out.TransitGatewayAttachmentID + *out = new(string) + **out = **in + } + if in.TransitGatewayAttachmentIDRef != nil { + in, out := &in.TransitGatewayAttachmentIDRef, &out.TransitGatewayAttachmentIDRef + *out = new(v1.Reference) + (*in).DeepCopyInto(*out) + } + if in.TransitGatewayAttachmentIDSelector != nil { + in, out := &in.TransitGatewayAttachmentIDSelector, &out.TransitGatewayAttachmentIDSelector + *out = new(v1.Selector) + (*in).DeepCopyInto(*out) + } + if in.SubnetID != nil { + in, out := &in.SubnetID, &out.SubnetID + *out = new(string) + **out = **in + } + if in.SubnetIDRef != nil { + in, out := &in.SubnetIDRef, &out.SubnetIDRef + *out = new(v1.Reference) + (*in).DeepCopyInto(*out) + } + if in.SubnetIDSelector != nil { + in, out := &in.SubnetIDSelector, &out.SubnetIDSelector + *out = new(v1.Selector) + (*in).DeepCopyInto(*out) + } + if in.NetworkInterfaceID != nil { + in, out := &in.NetworkInterfaceID, &out.NetworkInterfaceID + *out = new(string) + **out = **in + } + if in.DeliverLogsPermissionARN != nil { + in, out := &in.DeliverLogsPermissionARN, &out.DeliverLogsPermissionARN + *out = new(string) + **out = **in + } + if in.DeliverLogsPermissionARNRef != nil { + in, out := &in.DeliverLogsPermissionARNRef, &out.DeliverLogsPermissionARNRef + *out = new(v1.Reference) + (*in).DeepCopyInto(*out) + } + if in.DeliverLogsPermissionARNSelector != nil { + in, out := &in.DeliverLogsPermissionARNSelector, &out.DeliverLogsPermissionARNSelector + *out = new(v1.Selector) + (*in).DeepCopyInto(*out) + } + if in.CloudWatchLogDestination != nil { + in, out := &in.CloudWatchLogDestination, &out.CloudWatchLogDestination + *out = new(string) + **out = **in + } + if in.CloudWatchLogDestinationRef != nil { + in, out := &in.CloudWatchLogDestinationRef, &out.CloudWatchLogDestinationRef + *out = new(v1.Reference) + (*in).DeepCopyInto(*out) + } + if in.CloudWatchLogDestinationSelector != nil { + in, out := &in.CloudWatchLogDestinationSelector, &out.CloudWatchLogDestinationSelector + *out = new(v1.Selector) + (*in).DeepCopyInto(*out) + } + if in.S3BucketLogDestination != nil { + in, out := &in.S3BucketLogDestination, &out.S3BucketLogDestination + *out = new(string) + **out = **in + } + if in.S3BucketLogDestinationRef != nil { + in, out := &in.S3BucketLogDestinationRef, &out.S3BucketLogDestinationRef + *out = new(v1.Reference) + (*in).DeepCopyInto(*out) + } + if in.S3BucketLogDestinationSelector != nil { + in, out := &in.S3BucketLogDestinationSelector, &out.S3BucketLogDestinationSelector + *out = new(v1.Selector) + (*in).DeepCopyInto(*out) + } + if in.S3BucketSubfolder != nil { + in, out := &in.S3BucketSubfolder, &out.S3BucketSubfolder + *out = new(string) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CustomFlowLogParameters. +func (in *CustomFlowLogParameters) DeepCopy() *CustomFlowLogParameters { + if in == nil { + return nil + } + out := new(CustomFlowLogParameters) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *CustomLaunchTemplateParameters) DeepCopyInto(out *CustomLaunchTemplateParameters) { *out = *in @@ -3428,6 +3581,11 @@ func (in *DescribeFleetsInstances) DeepCopy() *DescribeFleetsInstances { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *DestinationOptionsRequest) DeepCopyInto(out *DestinationOptionsRequest) { *out = *in + if in.FileFormat != nil { + in, out := &in.FileFormat, &out.FileFormat + *out = new(string) + **out = **in + } if in.HiveCompatiblePartitions != nil { in, out := &in.HiveCompatiblePartitions, &out.HiveCompatiblePartitions *out = new(bool) @@ -3453,6 +3611,11 @@ func (in *DestinationOptionsRequest) DeepCopy() *DestinationOptionsRequest { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *DestinationOptionsResponse) DeepCopyInto(out *DestinationOptionsResponse) { *out = *in + if in.FileFormat != nil { + in, out := &in.FileFormat, &out.FileFormat + *out = new(string) + **out = **in + } if in.HiveCompatiblePartitions != nil { in, out := &in.HiveCompatiblePartitions, &out.HiveCompatiblePartitions *out = new(bool) @@ -5068,6 +5231,210 @@ func (in *FleetSpotCapacityRebalanceRequest) DeepCopy() *FleetSpotCapacityRebala // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *FlowLog) DeepCopyInto(out *FlowLog) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + in.Spec.DeepCopyInto(&out.Spec) + in.Status.DeepCopyInto(&out.Status) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FlowLog. +func (in *FlowLog) DeepCopy() *FlowLog { + if in == nil { + return nil + } + out := new(FlowLog) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *FlowLog) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *FlowLogList) DeepCopyInto(out *FlowLogList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]FlowLog, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FlowLogList. +func (in *FlowLogList) DeepCopy() *FlowLogList { + if in == nil { + return nil + } + out := new(FlowLogList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *FlowLogList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *FlowLogObservation) DeepCopyInto(out *FlowLogObservation) { + *out = *in + if in.CreationTime != nil { + in, out := &in.CreationTime, &out.CreationTime + *out = (*in).DeepCopy() + } + if in.DeliverLogsStatus != nil { + in, out := &in.DeliverLogsStatus, &out.DeliverLogsStatus + *out = new(string) + **out = **in + } + if in.FlowLogID != nil { + in, out := &in.FlowLogID, &out.FlowLogID + *out = new(string) + **out = **in + } + if in.FlowLogStatus != nil { + in, out := &in.FlowLogStatus, &out.FlowLogStatus + *out = new(string) + **out = **in + } + if in.ResourceID != nil { + in, out := &in.ResourceID, &out.ResourceID + *out = new(string) + **out = **in + } + if in.Tags != nil { + in, out := &in.Tags, &out.Tags + *out = make([]*Tag, len(*in)) + for i := range *in { + if (*in)[i] != nil { + in, out := &(*in)[i], &(*out)[i] + *out = new(Tag) + (*in).DeepCopyInto(*out) + } + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FlowLogObservation. +func (in *FlowLogObservation) DeepCopy() *FlowLogObservation { + if in == nil { + return nil + } + out := new(FlowLogObservation) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *FlowLogParameters) DeepCopyInto(out *FlowLogParameters) { + *out = *in + if in.ClientToken != nil { + in, out := &in.ClientToken, &out.ClientToken + *out = new(string) + **out = **in + } + if in.DeliverLogsPermissionARN != nil { + in, out := &in.DeliverLogsPermissionARN, &out.DeliverLogsPermissionARN + *out = new(string) + **out = **in + } + if in.DestinationOptions != nil { + in, out := &in.DestinationOptions, &out.DestinationOptions + *out = new(DestinationOptionsRequest) + (*in).DeepCopyInto(*out) + } + if in.LogDestination != nil { + in, out := &in.LogDestination, &out.LogDestination + *out = new(string) + **out = **in + } + if in.LogDestinationType != nil { + in, out := &in.LogDestinationType, &out.LogDestinationType + *out = new(string) + **out = **in + } + if in.LogFormat != nil { + in, out := &in.LogFormat, &out.LogFormat + *out = new(string) + **out = **in + } + if in.LogGroupName != nil { + in, out := &in.LogGroupName, &out.LogGroupName + *out = new(string) + **out = **in + } + if in.MaxAggregationInterval != nil { + in, out := &in.MaxAggregationInterval, &out.MaxAggregationInterval + *out = new(int64) + **out = **in + } + if in.TrafficType != nil { + in, out := &in.TrafficType, &out.TrafficType + *out = new(string) + **out = **in + } + in.CustomFlowLogParameters.DeepCopyInto(&out.CustomFlowLogParameters) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FlowLogParameters. +func (in *FlowLogParameters) DeepCopy() *FlowLogParameters { + if in == nil { + return nil + } + out := new(FlowLogParameters) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *FlowLogSpec) DeepCopyInto(out *FlowLogSpec) { + *out = *in + in.ResourceSpec.DeepCopyInto(&out.ResourceSpec) + in.ForProvider.DeepCopyInto(&out.ForProvider) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FlowLogSpec. +func (in *FlowLogSpec) DeepCopy() *FlowLogSpec { + if in == nil { + return nil + } + out := new(FlowLogSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *FlowLogStatus) DeepCopyInto(out *FlowLogStatus) { + *out = *in + in.ResourceStatus.DeepCopyInto(&out.ResourceStatus) + in.AtProvider.DeepCopyInto(&out.AtProvider) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FlowLogStatus. +func (in *FlowLogStatus) DeepCopy() *FlowLogStatus { + if in == nil { + return nil + } + out := new(FlowLogStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *FlowLog_SDK) DeepCopyInto(out *FlowLog_SDK) { *out = *in if in.CreationTime != nil { in, out := &in.CreationTime, &out.CreationTime @@ -5088,6 +5455,11 @@ func (in *FlowLog) DeepCopyInto(out *FlowLog) { *out = new(string) **out = **in } + if in.DestinationOptions != nil { + in, out := &in.DestinationOptions, &out.DestinationOptions + *out = new(DestinationOptionsResponse) + (*in).DeepCopyInto(*out) + } if in.FlowLogID != nil { in, out := &in.FlowLogID, &out.FlowLogID *out = new(string) @@ -5103,6 +5475,11 @@ func (in *FlowLog) DeepCopyInto(out *FlowLog) { *out = new(string) **out = **in } + if in.LogDestinationType != nil { + in, out := &in.LogDestinationType, &out.LogDestinationType + *out = new(string) + **out = **in + } if in.LogFormat != nil { in, out := &in.LogFormat, &out.LogFormat *out = new(string) @@ -5134,14 +5511,19 @@ func (in *FlowLog) DeepCopyInto(out *FlowLog) { } } } + if in.TrafficType != nil { + in, out := &in.TrafficType, &out.TrafficType + *out = new(string) + **out = **in + } } -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FlowLog. -func (in *FlowLog) DeepCopy() *FlowLog { +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new FlowLog_SDK. +func (in *FlowLog_SDK) DeepCopy() *FlowLog_SDK { if in == nil { return nil } - out := new(FlowLog) + out := new(FlowLog_SDK) in.DeepCopyInto(out) return out } diff --git a/apis/ec2/v1alpha1/zz_generated.managed.go b/apis/ec2/v1alpha1/zz_generated.managed.go index aaf87b5748..6a8eb9a4c2 100644 --- a/apis/ec2/v1alpha1/zz_generated.managed.go +++ b/apis/ec2/v1alpha1/zz_generated.managed.go @@ -20,6 +20,72 @@ package v1alpha1 import xpv1 "github.com/crossplane/crossplane-runtime/apis/common/v1" +// GetCondition of this FlowLog. +func (mg *FlowLog) GetCondition(ct xpv1.ConditionType) xpv1.Condition { + return mg.Status.GetCondition(ct) +} + +// GetDeletionPolicy of this FlowLog. +func (mg *FlowLog) GetDeletionPolicy() xpv1.DeletionPolicy { + return mg.Spec.DeletionPolicy +} + +// GetProviderConfigReference of this FlowLog. +func (mg *FlowLog) GetProviderConfigReference() *xpv1.Reference { + return mg.Spec.ProviderConfigReference +} + +/* +GetProviderReference of this FlowLog. +Deprecated: Use GetProviderConfigReference. +*/ +func (mg *FlowLog) GetProviderReference() *xpv1.Reference { + return mg.Spec.ProviderReference +} + +// GetPublishConnectionDetailsTo of this FlowLog. +func (mg *FlowLog) GetPublishConnectionDetailsTo() *xpv1.PublishConnectionDetailsTo { + return mg.Spec.PublishConnectionDetailsTo +} + +// GetWriteConnectionSecretToReference of this FlowLog. +func (mg *FlowLog) GetWriteConnectionSecretToReference() *xpv1.SecretReference { + return mg.Spec.WriteConnectionSecretToReference +} + +// SetConditions of this FlowLog. +func (mg *FlowLog) SetConditions(c ...xpv1.Condition) { + mg.Status.SetConditions(c...) +} + +// SetDeletionPolicy of this FlowLog. +func (mg *FlowLog) SetDeletionPolicy(r xpv1.DeletionPolicy) { + mg.Spec.DeletionPolicy = r +} + +// SetProviderConfigReference of this FlowLog. +func (mg *FlowLog) SetProviderConfigReference(r *xpv1.Reference) { + mg.Spec.ProviderConfigReference = r +} + +/* +SetProviderReference of this FlowLog. +Deprecated: Use SetProviderConfigReference. +*/ +func (mg *FlowLog) SetProviderReference(r *xpv1.Reference) { + mg.Spec.ProviderReference = r +} + +// SetPublishConnectionDetailsTo of this FlowLog. +func (mg *FlowLog) SetPublishConnectionDetailsTo(r *xpv1.PublishConnectionDetailsTo) { + mg.Spec.PublishConnectionDetailsTo = r +} + +// SetWriteConnectionSecretToReference of this FlowLog. +func (mg *FlowLog) SetWriteConnectionSecretToReference(r *xpv1.SecretReference) { + mg.Spec.WriteConnectionSecretToReference = r +} + // GetCondition of this LaunchTemplate. func (mg *LaunchTemplate) GetCondition(ct xpv1.ConditionType) xpv1.Condition { return mg.Status.GetCondition(ct) diff --git a/apis/ec2/v1alpha1/zz_generated.managedlist.go b/apis/ec2/v1alpha1/zz_generated.managedlist.go index e351cb234e..eaaa5a38c4 100644 --- a/apis/ec2/v1alpha1/zz_generated.managedlist.go +++ b/apis/ec2/v1alpha1/zz_generated.managedlist.go @@ -20,6 +20,15 @@ package v1alpha1 import resource "github.com/crossplane/crossplane-runtime/pkg/resource" +// GetItems of this FlowLogList. +func (l *FlowLogList) GetItems() []resource.Managed { + items := make([]resource.Managed, len(l.Items)) + for i := range l.Items { + items[i] = &l.Items[i] + } + return items +} + // GetItems of this LaunchTemplateList. func (l *LaunchTemplateList) GetItems() []resource.Managed { items := make([]resource.Managed, len(l.Items)) diff --git a/apis/ec2/v1alpha1/zz_generated.resolvers.go b/apis/ec2/v1alpha1/zz_generated.resolvers.go index b9651c4836..38cf035f50 100644 --- a/apis/ec2/v1alpha1/zz_generated.resolvers.go +++ b/apis/ec2/v1alpha1/zz_generated.resolvers.go @@ -20,15 +20,140 @@ package v1alpha1 import ( "context" + v1alpha1 "github.com/crossplane-contrib/provider-aws/apis/cloudwatchlogs/v1alpha1" manualv1alpha1 "github.com/crossplane-contrib/provider-aws/apis/ec2/manualv1alpha1" v1beta1 "github.com/crossplane-contrib/provider-aws/apis/ec2/v1beta1" - v1alpha1 "github.com/crossplane-contrib/provider-aws/apis/elbv2/v1alpha1" - v1alpha11 "github.com/crossplane-contrib/provider-aws/apis/kms/v1alpha1" + v1alpha11 "github.com/crossplane-contrib/provider-aws/apis/elbv2/v1alpha1" + v1beta11 "github.com/crossplane-contrib/provider-aws/apis/iam/v1beta1" + v1alpha12 "github.com/crossplane-contrib/provider-aws/apis/kms/v1alpha1" + v1beta12 "github.com/crossplane-contrib/provider-aws/apis/s3/v1beta1" reference "github.com/crossplane/crossplane-runtime/pkg/reference" errors "github.com/pkg/errors" client "sigs.k8s.io/controller-runtime/pkg/client" ) +// ResolveReferences of this FlowLog. +func (mg *FlowLog) ResolveReferences(ctx context.Context, c client.Reader) error { + r := reference.NewAPIResolver(c, mg) + + var rsp reference.ResolutionResponse + var err error + + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.CustomFlowLogParameters.VPCID), + Extract: reference.ExternalName(), + Reference: mg.Spec.ForProvider.CustomFlowLogParameters.VPCIDRef, + Selector: mg.Spec.ForProvider.CustomFlowLogParameters.VPCIDSelector, + To: reference.To{ + List: &v1beta1.VPCList{}, + Managed: &v1beta1.VPC{}, + }, + }) + if err != nil { + return errors.Wrap(err, "mg.Spec.ForProvider.CustomFlowLogParameters.VPCID") + } + mg.Spec.ForProvider.CustomFlowLogParameters.VPCID = reference.ToPtrValue(rsp.ResolvedValue) + mg.Spec.ForProvider.CustomFlowLogParameters.VPCIDRef = rsp.ResolvedReference + + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.CustomFlowLogParameters.TransitGatewayID), + Extract: reference.ExternalName(), + Reference: mg.Spec.ForProvider.CustomFlowLogParameters.TransitGatewayIDRef, + Selector: mg.Spec.ForProvider.CustomFlowLogParameters.TransitGatewayIDSelector, + To: reference.To{ + List: &TransitGatewayList{}, + Managed: &TransitGateway{}, + }, + }) + if err != nil { + return errors.Wrap(err, "mg.Spec.ForProvider.CustomFlowLogParameters.TransitGatewayID") + } + mg.Spec.ForProvider.CustomFlowLogParameters.TransitGatewayID = reference.ToPtrValue(rsp.ResolvedValue) + mg.Spec.ForProvider.CustomFlowLogParameters.TransitGatewayIDRef = rsp.ResolvedReference + + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.CustomFlowLogParameters.TransitGatewayAttachmentID), + Extract: reference.ExternalName(), + Reference: mg.Spec.ForProvider.CustomFlowLogParameters.TransitGatewayAttachmentIDRef, + Selector: mg.Spec.ForProvider.CustomFlowLogParameters.TransitGatewayAttachmentIDSelector, + To: reference.To{ + List: &TransitGatewayVPCAttachmentList{}, + Managed: &TransitGatewayVPCAttachment{}, + }, + }) + if err != nil { + return errors.Wrap(err, "mg.Spec.ForProvider.CustomFlowLogParameters.TransitGatewayAttachmentID") + } + mg.Spec.ForProvider.CustomFlowLogParameters.TransitGatewayAttachmentID = reference.ToPtrValue(rsp.ResolvedValue) + mg.Spec.ForProvider.CustomFlowLogParameters.TransitGatewayAttachmentIDRef = rsp.ResolvedReference + + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.CustomFlowLogParameters.SubnetID), + Extract: reference.ExternalName(), + Reference: mg.Spec.ForProvider.CustomFlowLogParameters.SubnetIDRef, + Selector: mg.Spec.ForProvider.CustomFlowLogParameters.SubnetIDSelector, + To: reference.To{ + List: &v1beta1.SubnetList{}, + Managed: &v1beta1.Subnet{}, + }, + }) + if err != nil { + return errors.Wrap(err, "mg.Spec.ForProvider.CustomFlowLogParameters.SubnetID") + } + mg.Spec.ForProvider.CustomFlowLogParameters.SubnetID = reference.ToPtrValue(rsp.ResolvedValue) + mg.Spec.ForProvider.CustomFlowLogParameters.SubnetIDRef = rsp.ResolvedReference + + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.CustomFlowLogParameters.DeliverLogsPermissionARN), + Extract: v1beta11.RoleARN(), + Reference: mg.Spec.ForProvider.CustomFlowLogParameters.DeliverLogsPermissionARNRef, + Selector: mg.Spec.ForProvider.CustomFlowLogParameters.DeliverLogsPermissionARNSelector, + To: reference.To{ + List: &v1beta11.RoleList{}, + Managed: &v1beta11.Role{}, + }, + }) + if err != nil { + return errors.Wrap(err, "mg.Spec.ForProvider.CustomFlowLogParameters.DeliverLogsPermissionARN") + } + mg.Spec.ForProvider.CustomFlowLogParameters.DeliverLogsPermissionARN = reference.ToPtrValue(rsp.ResolvedValue) + mg.Spec.ForProvider.CustomFlowLogParameters.DeliverLogsPermissionARNRef = rsp.ResolvedReference + + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.CustomFlowLogParameters.CloudWatchLogDestination), + Extract: v1alpha1.LogGroupARN(), + Reference: mg.Spec.ForProvider.CustomFlowLogParameters.CloudWatchLogDestinationRef, + Selector: mg.Spec.ForProvider.CustomFlowLogParameters.CloudWatchLogDestinationSelector, + To: reference.To{ + List: &v1alpha1.LogGroupList{}, + Managed: &v1alpha1.LogGroup{}, + }, + }) + if err != nil { + return errors.Wrap(err, "mg.Spec.ForProvider.CustomFlowLogParameters.CloudWatchLogDestination") + } + mg.Spec.ForProvider.CustomFlowLogParameters.CloudWatchLogDestination = reference.ToPtrValue(rsp.ResolvedValue) + mg.Spec.ForProvider.CustomFlowLogParameters.CloudWatchLogDestinationRef = rsp.ResolvedReference + + rsp, err = r.Resolve(ctx, reference.ResolutionRequest{ + CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.CustomFlowLogParameters.S3BucketLogDestination), + Extract: v1beta12.BucketARN(), + Reference: mg.Spec.ForProvider.CustomFlowLogParameters.S3BucketLogDestinationRef, + Selector: mg.Spec.ForProvider.CustomFlowLogParameters.S3BucketLogDestinationSelector, + To: reference.To{ + List: &v1beta12.BucketList{}, + Managed: &v1beta12.Bucket{}, + }, + }) + if err != nil { + return errors.Wrap(err, "mg.Spec.ForProvider.CustomFlowLogParameters.S3BucketLogDestination") + } + mg.Spec.ForProvider.CustomFlowLogParameters.S3BucketLogDestination = reference.ToPtrValue(rsp.ResolvedValue) + mg.Spec.ForProvider.CustomFlowLogParameters.S3BucketLogDestinationRef = rsp.ResolvedReference + + return nil +} + // ResolveReferences of this LaunchTemplateVersion. func (mg *LaunchTemplateVersion) ResolveReferences(ctx context.Context, c client.Reader) error { r := reference.NewAPIResolver(c, mg) @@ -392,8 +517,8 @@ func (mg *VPCEndpointServiceConfiguration) ResolveReferences(ctx context.Context References: mg.Spec.ForProvider.CustomVPCEndpointServiceConfigurationParameters.GatewayLoadBalancerARNRefs, Selector: mg.Spec.ForProvider.CustomVPCEndpointServiceConfigurationParameters.GatewayLoadBalancerARNSelector, To: reference.To{ - List: &v1alpha1.LoadBalancerList{}, - Managed: &v1alpha1.LoadBalancer{}, + List: &v1alpha11.LoadBalancerList{}, + Managed: &v1alpha11.LoadBalancer{}, }, }) if err != nil { @@ -408,8 +533,8 @@ func (mg *VPCEndpointServiceConfiguration) ResolveReferences(ctx context.Context References: mg.Spec.ForProvider.CustomVPCEndpointServiceConfigurationParameters.NetworkLoadBalancerARNRefs, Selector: mg.Spec.ForProvider.CustomVPCEndpointServiceConfigurationParameters.NetworkLoadBalancerARNSelector, To: reference.To{ - List: &v1alpha1.LoadBalancerList{}, - Managed: &v1alpha1.LoadBalancer{}, + List: &v1alpha11.LoadBalancerList{}, + Managed: &v1alpha11.LoadBalancer{}, }, }) if err != nil { @@ -476,8 +601,8 @@ func (mg *Volume) ResolveReferences(ctx context.Context, c client.Reader) error Reference: mg.Spec.ForProvider.CustomVolumeParameters.KMSKeyIDRef, Selector: mg.Spec.ForProvider.CustomVolumeParameters.KMSKeyIDSelector, To: reference.To{ - List: &v1alpha11.KeyList{}, - Managed: &v1alpha11.Key{}, + List: &v1alpha12.KeyList{}, + Managed: &v1alpha12.Key{}, }, }) if err != nil { diff --git a/apis/ec2/v1alpha1/zz_types.go b/apis/ec2/v1alpha1/zz_types.go index 8cb88018ce..9975aca921 100644 --- a/apis/ec2/v1alpha1/zz_types.go +++ b/apis/ec2/v1alpha1/zz_types.go @@ -840,6 +840,8 @@ type DescribeFleetsInstances struct { // +kubebuilder:skipversion type DestinationOptionsRequest struct { + FileFormat *string `json:"fileFormat,omitempty"` + HiveCompatiblePartitions *bool `json:"hiveCompatiblePartitions,omitempty"` PerHourPartition *bool `json:"perHourPartition,omitempty"` @@ -847,6 +849,8 @@ type DestinationOptionsRequest struct { // +kubebuilder:skipversion type DestinationOptionsResponse struct { + FileFormat *string `json:"fileFormat,omitempty"` + HiveCompatiblePartitions *bool `json:"hiveCompatiblePartitions,omitempty"` PerHourPartition *bool `json:"perHourPartition,omitempty"` @@ -1356,7 +1360,7 @@ type FleetSpotCapacityRebalanceRequest struct { } // +kubebuilder:skipversion -type FlowLog struct { +type FlowLog_SDK struct { CreationTime *metav1.Time `json:"creationTime,omitempty"` DeliverLogsErrorMessage *string `json:"deliverLogsErrorMessage,omitempty"` @@ -1364,6 +1368,8 @@ type FlowLog struct { DeliverLogsPermissionARN *string `json:"deliverLogsPermissionARN,omitempty"` DeliverLogsStatus *string `json:"deliverLogsStatus,omitempty"` + // Describes the destination options for a flow log. + DestinationOptions *DestinationOptionsResponse `json:"destinationOptions,omitempty"` FlowLogID *string `json:"flowLogID,omitempty"` @@ -1371,6 +1377,8 @@ type FlowLog struct { LogDestination *string `json:"logDestination,omitempty"` + LogDestinationType *string `json:"logDestinationType,omitempty"` + LogFormat *string `json:"logFormat,omitempty"` LogGroupName *string `json:"logGroupName,omitempty"` @@ -1380,6 +1388,8 @@ type FlowLog struct { ResourceID *string `json:"resourceID,omitempty"` Tags []*Tag `json:"tags,omitempty"` + + TrafficType *string `json:"trafficType,omitempty"` } // +kubebuilder:skipversion diff --git a/examples/ec2/flowlog.yaml b/examples/ec2/flowlog.yaml new file mode 100644 index 0000000000..95f34e2f87 --- /dev/null +++ b/examples/ec2/flowlog.yaml @@ -0,0 +1,116 @@ +# --- +# apiVersion: iam.aws.crossplane.io/v1beta1 +# kind: Role +# metadata: +# name: flowlogs-role +# spec: +# forProvider: +# assumeRolePolicyDocument: | +# { +# "Version": "2012-10-17", +# "Statement": [ +# { +# "Sid": "", +# "Effect": "Allow", +# "Principal": { +# "Service": "vpc-flow-logs.amazonaws.com" +# }, +# "Action": "sts:AssumeRole" +# } +# ] +# } +# providerConfigRef: +# name: example +# --- +# apiVersion: iam.aws.crossplane.io/v1beta1 +# kind: Policy +# metadata: +# name: flowlogs-policy +# spec: +# forProvider: +# name: flowlogs-policy +# document: | +# { +# "Version": "2012-10-17", +# "Statement": [ +# { +# "Action": [ +# "logs:CreateLogGroup", +# "logs:CreateLogStream", +# "logs:PutLogEvents", +# "logs:DescribeLogGroups", +# "logs:DescribeLogStreams" +# ], +# "Effect": "Allow", +# "Resource": "*" +# } +# ] +# } +# providerConfigRef: +# name: example +# --- +# apiVersion: iam.aws.crossplane.io/v1beta1 +# kind: RolePolicyAttachment +# metadata: +# name: flowlogs-policy-attachement +# spec: +# forProvider: +# policyArnRef: +# name: flowlogs-policy +# roleNameRef: +# name: flowlogs-role +# providerConfigRef: +# name: example + +# --- +# apiVersion: cloudwatchlogs.aws.crossplane.io/v1alpha1 +# kind: LogGroup +# metadata: +# name: sample-loggroup +# spec: +# forProvider: +# logGroupName: /aws/flow-logs-test +# region: us-east-1 +# retentionInDays: 1 +# providerConfigRef: +# name: example +--- +apiVersion: ec2.aws.crossplane.io/v1alpha1 +kind: FlowLog +metadata: + name: flowlog-example-cloud-watch +spec: + forProvider: + region: us-east-1 + trafficType: ALL + deliverLogsPermissionArnRef: + name: flowlogs-role + cloudWatchLogDestinationRef: + name: sample-loggroup + vpcId: vpc-0123456789 + tags: + - key: Name + value: example + providerConfigRef: + name: example +--- +apiVersion: ec2.aws.crossplane.io/v1alpha1 +kind: FlowLog +metadata: + name: flowlog-example-s3 +spec: + forProvider: + region: us-east-1 + trafficType: ALL + logDestinationType: s3 + s3BucketLogDestination: arn:aws:s3:::ctest-bucket + s3BucketSubfolder: test/test2 + vpcId: vpc-0123456789 + destinationOptions: + fileFormat: parquet + perHourPartition: true + tags: + - key: Name + value: example + providerConfigRef: + name: example \ No newline at end of file diff --git a/go.sum b/go.sum index ca5b498841..c88fd4560a 100644 --- a/go.sum +++ b/go.sum @@ -146,10 +146,10 @@ github.com/aws/aws-sdk-go-v2/service/sts v1.12.0 h1:7g0252k2TF3eA1DtfkTQB/tqI41Y github.com/aws/aws-sdk-go-v2/service/sts v1.12.0/go.mod h1:UV2N5HaPfdbDpkgkz4sRzWCvQswZjdO1FfqCWl0t7RA= github.com/aws/smithy-go v1.9.0/go.mod h1:SObp3lf9smib00L/v3U2eAKG8FyQ7iLrJnQiAmR5n+E= github.com/aws/smithy-go v1.11.2/go.mod h1:3xHYmszWVx2c0kIwQeEVf9uSm4fYZt67FBJnwub1bgM= -github.com/barkimedes/go-deepcopy v0.0.0-20220514131651-17c30cfc62df h1:GSoSVRLoBaFpOOds6QyY1L8AX7uoY+Ln3BHc22W40X0= -github.com/barkimedes/go-deepcopy v0.0.0-20220514131651-17c30cfc62df/go.mod h1:hiVxq5OP2bUGBRNS3Z/bt/reCLFNbdcST6gISi1fiOM= github.com/aws/smithy-go v1.12.0 h1:gXpeZel/jPoWQ7OEmLIgCUnhkFftqNfwWUwAHSlp1v0= github.com/aws/smithy-go v1.12.0/go.mod h1:Tg+OJXh4MB2R/uN61Ko2f6hTZwB/ZYGOtib8J3gBHzA= +github.com/barkimedes/go-deepcopy v0.0.0-20220514131651-17c30cfc62df h1:GSoSVRLoBaFpOOds6QyY1L8AX7uoY+Ln3BHc22W40X0= +github.com/barkimedes/go-deepcopy v0.0.0-20220514131651-17c30cfc62df/go.mod h1:hiVxq5OP2bUGBRNS3Z/bt/reCLFNbdcST6gISi1fiOM= github.com/benbjohnson/clock v1.0.3/go.mod h1:bGMdMPoPVvcYyt1gHDf4J2KE153Yf9BuiUKYMaxlTDM= github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8= github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= diff --git a/package/crds/cloudwatchlogs.aws.crossplane.io_loggroups.yaml b/package/crds/cloudwatchlogs.aws.crossplane.io_loggroups.yaml index ae2127a26c..196119c492 100644 --- a/package/crds/cloudwatchlogs.aws.crossplane.io_loggroups.yaml +++ b/package/crds/cloudwatchlogs.aws.crossplane.io_loggroups.yaml @@ -362,6 +362,33 @@ spec: properties: atProvider: description: LogGroupObservation defines the observed state of LogGroup + properties: + arn: + description: The Amazon Resource Name (ARN) of the log group. + type: string + creationTime: + description: The creation time of the log group, expressed as + the number of milliseconds after Jan 1, 1970 00:00:00 UTC. + format: int64 + type: integer + kmsKeyID: + description: The Amazon Resource Name (ARN) of the CMK to use + when encrypting log data. + type: string + logGroupName: + description: The name of the log group. + type: string + metricFilterCount: + description: The number of metric filters. + format: int64 + type: integer + retentionInDays: + format: int64 + type: integer + storedBytes: + description: The number of bytes stored. + format: int64 + type: integer type: object conditions: description: Conditions of the resource. diff --git a/package/crds/ec2.aws.crossplane.io_flowlogs.yaml b/package/crds/ec2.aws.crossplane.io_flowlogs.yaml new file mode 100644 index 0000000000..c802302fb4 --- /dev/null +++ b/package/crds/ec2.aws.crossplane.io_flowlogs.yaml @@ -0,0 +1,985 @@ +--- +apiVersion: apiextensions.k8s.io/v1 +kind: CustomResourceDefinition +metadata: + annotations: + controller-gen.kubebuilder.io/version: v0.8.0 + creationTimestamp: null + name: flowlogs.ec2.aws.crossplane.io +spec: + group: ec2.aws.crossplane.io + names: + categories: + - crossplane + - managed + - aws + kind: FlowLog + listKind: FlowLogList + plural: flowlogs + singular: flowlog + scope: Cluster + versions: + - additionalPrinterColumns: + - jsonPath: .status.conditions[?(@.type=='Ready')].status + name: READY + type: string + - jsonPath: .status.conditions[?(@.type=='Synced')].status + name: SYNCED + type: string + - jsonPath: .metadata.annotations.crossplane\.io/external-name + name: EXTERNAL-NAME + type: string + name: v1alpha1 + schema: + openAPIV3Schema: + description: FlowLog is the Schema for the FlowLogs API + properties: + apiVersion: + description: 'APIVersion defines the versioned schema of this representation + of an object. Servers should convert recognized schemas to the latest + internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources' + type: string + kind: + description: 'Kind is a string value representing the REST resource this + object represents. Servers may infer this from the endpoint the client + submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds' + type: string + metadata: + type: object + spec: + description: FlowLogSpec defines the desired state of FlowLog + properties: + deletionPolicy: + default: Delete + description: DeletionPolicy specifies what will happen to the underlying + external when this managed resource is deleted - either "Delete" + or "Orphan" the external resource. + enum: + - Orphan + - Delete + type: string + forProvider: + description: FlowLogParameters defines the desired state of FlowLog + properties: + clientToken: + description: Unique, case-sensitive identifier that you provide + to ensure the idempotency of the request. For more information, + see How to ensure idempotency (https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/Run_Instance_Idempotency.html). + type: string + cloudWatchLogDestination: + description: The Amazon Resource Names (ARNs) of a CloudWatch + Log Group. + type: string + cloudWatchLogDestinationRef: + description: CloudWatchLogDestinationRef is a reference to a CloudWatch + Log Group used to set the CloudWatchLogDestination. + properties: + name: + description: Name of the referenced object. + type: string + policy: + description: Policies for referencing. + properties: + resolution: + default: Required + description: Resolution specifies whether resolution of + this reference is required. The default is 'Required', + which means the reconcile will fail if the reference + cannot be resolved. 'Optional' means this reference + will be a no-op if it cannot be resolved. + enum: + - Required + - Optional + type: string + resolve: + description: Resolve specifies when this reference should + be resolved. The default is 'IfNotPresent', which will + attempt to resolve the reference only when the corresponding + field is not present. Use 'Always' to resolve the reference + on every reconcile. + enum: + - Always + - IfNotPresent + type: string + type: object + required: + - name + type: object + cloudWatchLogDestinationSelector: + description: CloudWatchLogDestinationSelector selects a reference + to a CloudWatch Log Group used to set the CloudWatchLogDestination. + properties: + matchControllerRef: + description: MatchControllerRef ensures an object with the + same controller reference as the selecting object is selected. + type: boolean + matchLabels: + additionalProperties: + type: string + description: MatchLabels ensures an object with matching labels + is selected. + type: object + policy: + description: Policies for selection. + properties: + resolution: + default: Required + description: Resolution specifies whether resolution of + this reference is required. The default is 'Required', + which means the reconcile will fail if the reference + cannot be resolved. 'Optional' means this reference + will be a no-op if it cannot be resolved. + enum: + - Required + - Optional + type: string + resolve: + description: Resolve specifies when this reference should + be resolved. The default is 'IfNotPresent', which will + attempt to resolve the reference only when the corresponding + field is not present. Use 'Always' to resolve the reference + on every reconcile. + enum: + - Always + - IfNotPresent + type: string + type: object + type: object + deliverLogsPermissionARN: + description: "The ARN for the IAM role that permits Amazon EC2 + to publish flow logs to a CloudWatch Logs log group in your + account. \n If you specify LogDestinationType as s3, do not + specify DeliverLogsPermissionArn or LogGroupName." + type: string + deliverLogsPermissionArn: + description: The Amazon Resource Names (ARNs) of an IAM Role. + type: string + deliverLogsPermissionArnRef: + description: DeliverLogsPermissionARNRef is a reference to DeliverLogsPermissionARN + used to set the DeliverLogsPermissionARN. + properties: + name: + description: Name of the referenced object. + type: string + policy: + description: Policies for referencing. + properties: + resolution: + default: Required + description: Resolution specifies whether resolution of + this reference is required. The default is 'Required', + which means the reconcile will fail if the reference + cannot be resolved. 'Optional' means this reference + will be a no-op if it cannot be resolved. + enum: + - Required + - Optional + type: string + resolve: + description: Resolve specifies when this reference should + be resolved. The default is 'IfNotPresent', which will + attempt to resolve the reference only when the corresponding + field is not present. Use 'Always' to resolve the reference + on every reconcile. + enum: + - Always + - IfNotPresent + type: string + type: object + required: + - name + type: object + deliverLogsPermissionArnSelector: + description: DeliverLogsPermissionARNelector selects a reference + to DeliverLogsPermissionARN used to set the DeliverLogsPermissionARN. + properties: + matchControllerRef: + description: MatchControllerRef ensures an object with the + same controller reference as the selecting object is selected. + type: boolean + matchLabels: + additionalProperties: + type: string + description: MatchLabels ensures an object with matching labels + is selected. + type: object + policy: + description: Policies for selection. + properties: + resolution: + default: Required + description: Resolution specifies whether resolution of + this reference is required. The default is 'Required', + which means the reconcile will fail if the reference + cannot be resolved. 'Optional' means this reference + will be a no-op if it cannot be resolved. + enum: + - Required + - Optional + type: string + resolve: + description: Resolve specifies when this reference should + be resolved. The default is 'IfNotPresent', which will + attempt to resolve the reference only when the corresponding + field is not present. Use 'Always' to resolve the reference + on every reconcile. + enum: + - Always + - IfNotPresent + type: string + type: object + type: object + destinationOptions: + description: The destination options. + properties: + fileFormat: + type: string + hiveCompatiblePartitions: + type: boolean + perHourPartition: + type: boolean + type: object + logDestination: + description: "The destination to which the flow log data is to + be published. Flow log data can be published to a CloudWatch + Logs log group or an Amazon S3 bucket. The value specified for + this parameter depends on the value specified for LogDestinationType. + \n If LogDestinationType is not specified or cloud-watch-logs, + specify the Amazon Resource Name (ARN) of the CloudWatch Logs + log group. For example, to publish to a log group called my-logs, + specify arn:aws:logs:us-east-1:123456789012:log-group:my-logs. + Alternatively, use LogGroupName instead. \n If LogDestinationType + is s3, specify the ARN of the Amazon S3 bucket. You can also + specify a subfolder in the bucket. To specify a subfolder in + the bucket, use the following ARN format: bucket_ARN/subfolder_name/. + For example, to specify a subfolder named my-logs in a bucket + named my-bucket, use the following ARN: arn:aws:s3:::my-bucket/my-logs/. + You cannot use AWSLogs as a subfolder name. This is a reserved + term." + type: string + logDestinationType: + description: "The type of destination to which the flow log data + is to be published. Flow log data can be published to CloudWatch + Logs or Amazon S3. To publish flow log data to CloudWatch Logs, + specify cloud-watch-logs. To publish flow log data to Amazon + S3, specify s3. \n If you specify LogDestinationType as s3, + do not specify DeliverLogsPermissionArn or LogGroupName. \n + Default: cloud-watch-logs" + type: string + logFormat: + description: "The fields to include in the flow log record, in + the order in which they should appear. For a list of available + fields, see Flow log records (https://docs.aws.amazon.com/vpc/latest/userguide/flow-logs.html#flow-log-records). + If you omit this parameter, the flow log is created using the + default format. If you specify this parameter, you must specify + at least one field. \n Specify the fields using the ${field-id} + format, separated by spaces. For the CLI, surround this parameter + value with single quotes on Linux or double quotes on Windows." + type: string + logGroupName: + description: "The name of a new or existing CloudWatch Logs log + group where Amazon EC2 publishes your flow logs. \n If you specify + LogDestinationType as s3, do not specify DeliverLogsPermissionArn + or LogGroupName." + type: string + maxAggregationInterval: + description: "The maximum interval of time during which a flow + of packets is captured and aggregated into a flow log record. + You can specify 60 seconds (1 minute) or 600 seconds (10 minutes). + \n When a network interface is attached to a Nitro-based instance + (https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instance-types.html#ec2-nitro-instances), + the aggregation interval is always 60 seconds or less, regardless + of the value that you specify. \n Default: 600" + format: int64 + type: integer + networkInterfaceId: + description: The ID of the NetworkInterface for which you want + to create a flow log. + type: string + region: + description: Region is which region the FlowLog will be created. + type: string + resourceIDs: + description: "The ID of the subnet, network interface, or VPC + for which you want to create a flow log. \n Constraints: Maximum + of 1000 resources" + items: + type: string + type: array + resourceType: + description: 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. + type: string + s3BucketLogDestination: + description: The Amazon Resource Names (ARNs) of a CloudWatch + Log Group. + type: string + s3BucketLogDestinationRef: + description: S3BucketLogDestinationRef is a reference to a S3 + Bucket to set the S3BucketLogDestination. + properties: + name: + description: Name of the referenced object. + type: string + policy: + description: Policies for referencing. + properties: + resolution: + default: Required + description: Resolution specifies whether resolution of + this reference is required. The default is 'Required', + which means the reconcile will fail if the reference + cannot be resolved. 'Optional' means this reference + will be a no-op if it cannot be resolved. + enum: + - Required + - Optional + type: string + resolve: + description: Resolve specifies when this reference should + be resolved. The default is 'IfNotPresent', which will + attempt to resolve the reference only when the corresponding + field is not present. Use 'Always' to resolve the reference + on every reconcile. + enum: + - Always + - IfNotPresent + type: string + type: object + required: + - name + type: object + s3BucketLogDestinationSelector: + description: S3BucketLogDestinationSelector selects a reference + to a S3 Bucket used to set the S3BucketLogDestination. + properties: + matchControllerRef: + description: MatchControllerRef ensures an object with the + same controller reference as the selecting object is selected. + type: boolean + matchLabels: + additionalProperties: + type: string + description: MatchLabels ensures an object with matching labels + is selected. + type: object + policy: + description: Policies for selection. + properties: + resolution: + default: Required + description: Resolution specifies whether resolution of + this reference is required. The default is 'Required', + which means the reconcile will fail if the reference + cannot be resolved. 'Optional' means this reference + will be a no-op if it cannot be resolved. + enum: + - Required + - Optional + type: string + resolve: + description: Resolve specifies when this reference should + be resolved. The default is 'IfNotPresent', which will + attempt to resolve the reference only when the corresponding + field is not present. Use 'Always' to resolve the reference + on every reconcile. + enum: + - Always + - IfNotPresent + type: string + type: object + type: object + s3BucketSubfolder: + description: 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. + type: string + subnetId: + description: The ID of the one or more Subnets for which you want + to create a flow log. + type: string + subnetIdRef: + description: SubnetIDRefs is a referenc to a SubnetID used to + set the SubnetID. + properties: + name: + description: Name of the referenced object. + type: string + policy: + description: Policies for referencing. + properties: + resolution: + default: Required + description: Resolution specifies whether resolution of + this reference is required. The default is 'Required', + which means the reconcile will fail if the reference + cannot be resolved. 'Optional' means this reference + will be a no-op if it cannot be resolved. + enum: + - Required + - Optional + type: string + resolve: + description: Resolve specifies when this reference should + be resolved. The default is 'IfNotPresent', which will + attempt to resolve the reference only when the corresponding + field is not present. Use 'Always' to resolve the reference + on every reconcile. + enum: + - Always + - IfNotPresent + type: string + type: object + required: + - name + type: object + subnetIdSelector: + description: SubnetIDSelector selects reference to a SubnetID + used to set the SubnetID. + properties: + matchControllerRef: + description: MatchControllerRef ensures an object with the + same controller reference as the selecting object is selected. + type: boolean + matchLabels: + additionalProperties: + type: string + description: MatchLabels ensures an object with matching labels + is selected. + type: object + policy: + description: Policies for selection. + properties: + resolution: + default: Required + description: Resolution specifies whether resolution of + this reference is required. The default is 'Required', + which means the reconcile will fail if the reference + cannot be resolved. 'Optional' means this reference + will be a no-op if it cannot be resolved. + enum: + - Required + - Optional + type: string + resolve: + description: Resolve specifies when this reference should + be resolved. The default is 'IfNotPresent', which will + attempt to resolve the reference only when the corresponding + field is not present. Use 'Always' to resolve the reference + on every reconcile. + enum: + - Always + - IfNotPresent + type: string + type: object + type: object + tags: + description: Metadata tagging key value pairs + items: + properties: + key: + type: string + value: + type: string + type: object + type: array + trafficType: + description: The type of traffic to log. You can log traffic that + the resource accepts or rejects, or all traffic. + type: string + transitGatewayAttachmentId: + description: The ID of the TransitGatewayAttachment for which + you want to create a flow log. + type: string + transitGatewayAttachmentIdRef: + description: TransitGatewayAttachmentIDRef is a reference to an + API used to set the TransitGatewayAttachmentID. + properties: + name: + description: Name of the referenced object. + type: string + policy: + description: Policies for referencing. + properties: + resolution: + default: Required + description: Resolution specifies whether resolution of + this reference is required. The default is 'Required', + which means the reconcile will fail if the reference + cannot be resolved. 'Optional' means this reference + will be a no-op if it cannot be resolved. + enum: + - Required + - Optional + type: string + resolve: + description: Resolve specifies when this reference should + be resolved. The default is 'IfNotPresent', which will + attempt to resolve the reference only when the corresponding + field is not present. Use 'Always' to resolve the reference + on every reconcile. + enum: + - Always + - IfNotPresent + type: string + type: object + required: + - name + type: object + transitGatewayAttachmentIdSelector: + description: TransitGatewayAttachmentIDSelector selects references + to API used to set the TransitGatewayAttachmentID. + properties: + matchControllerRef: + description: MatchControllerRef ensures an object with the + same controller reference as the selecting object is selected. + type: boolean + matchLabels: + additionalProperties: + type: string + description: MatchLabels ensures an object with matching labels + is selected. + type: object + policy: + description: Policies for selection. + properties: + resolution: + default: Required + description: Resolution specifies whether resolution of + this reference is required. The default is 'Required', + which means the reconcile will fail if the reference + cannot be resolved. 'Optional' means this reference + will be a no-op if it cannot be resolved. + enum: + - Required + - Optional + type: string + resolve: + description: Resolve specifies when this reference should + be resolved. The default is 'IfNotPresent', which will + attempt to resolve the reference only when the corresponding + field is not present. Use 'Always' to resolve the reference + on every reconcile. + enum: + - Always + - IfNotPresent + type: string + type: object + type: object + transitGatewayId: + description: The ID of the TransitGateway for which you want to + create a flow log. + type: string + transitGatewayIdRef: + description: TransitGatewayIDRef is a reference to an API used + to set the TransitGatewayID. + properties: + name: + description: Name of the referenced object. + type: string + policy: + description: Policies for referencing. + properties: + resolution: + default: Required + description: Resolution specifies whether resolution of + this reference is required. The default is 'Required', + which means the reconcile will fail if the reference + cannot be resolved. 'Optional' means this reference + will be a no-op if it cannot be resolved. + enum: + - Required + - Optional + type: string + resolve: + description: Resolve specifies when this reference should + be resolved. The default is 'IfNotPresent', which will + attempt to resolve the reference only when the corresponding + field is not present. Use 'Always' to resolve the reference + on every reconcile. + enum: + - Always + - IfNotPresent + type: string + type: object + required: + - name + type: object + transitGatewayIdSelector: + description: TransitGatewayIDSelector selects references to API + used to set the TransitGatewayID. + properties: + matchControllerRef: + description: MatchControllerRef ensures an object with the + same controller reference as the selecting object is selected. + type: boolean + matchLabels: + additionalProperties: + type: string + description: MatchLabels ensures an object with matching labels + is selected. + type: object + policy: + description: Policies for selection. + properties: + resolution: + default: Required + description: Resolution specifies whether resolution of + this reference is required. The default is 'Required', + which means the reconcile will fail if the reference + cannot be resolved. 'Optional' means this reference + will be a no-op if it cannot be resolved. + enum: + - Required + - Optional + type: string + resolve: + description: Resolve specifies when this reference should + be resolved. The default is 'IfNotPresent', which will + attempt to resolve the reference only when the corresponding + field is not present. Use 'Always' to resolve the reference + on every reconcile. + enum: + - Always + - IfNotPresent + type: string + type: object + type: object + vpcId: + description: The ID of the VPC for which you want to create a + flow log. + type: string + vpcIdRef: + description: VPCIDRef is a reference to an API used to set the + VPCID. + properties: + name: + description: Name of the referenced object. + type: string + policy: + description: Policies for referencing. + properties: + resolution: + default: Required + description: Resolution specifies whether resolution of + this reference is required. The default is 'Required', + which means the reconcile will fail if the reference + cannot be resolved. 'Optional' means this reference + will be a no-op if it cannot be resolved. + enum: + - Required + - Optional + type: string + resolve: + description: Resolve specifies when this reference should + be resolved. The default is 'IfNotPresent', which will + attempt to resolve the reference only when the corresponding + field is not present. Use 'Always' to resolve the reference + on every reconcile. + enum: + - Always + - IfNotPresent + type: string + type: object + required: + - name + type: object + vpcIdSelector: + description: VPCIDSelector selects references to API used to set + the VPCID. + properties: + matchControllerRef: + description: MatchControllerRef ensures an object with the + same controller reference as the selecting object is selected. + type: boolean + matchLabels: + additionalProperties: + type: string + description: MatchLabels ensures an object with matching labels + is selected. + type: object + policy: + description: Policies for selection. + properties: + resolution: + default: Required + description: Resolution specifies whether resolution of + this reference is required. The default is 'Required', + which means the reconcile will fail if the reference + cannot be resolved. 'Optional' means this reference + will be a no-op if it cannot be resolved. + enum: + - Required + - Optional + type: string + resolve: + description: Resolve specifies when this reference should + be resolved. The default is 'IfNotPresent', which will + attempt to resolve the reference only when the corresponding + field is not present. Use 'Always' to resolve the reference + on every reconcile. + enum: + - Always + - IfNotPresent + type: string + type: object + type: object + required: + - region + - trafficType + type: object + providerConfigRef: + default: + name: default + description: ProviderConfigReference specifies how the provider that + will be used to create, observe, update, and delete this managed + resource should be configured. + properties: + name: + description: Name of the referenced object. + type: string + policy: + description: Policies for referencing. + properties: + resolution: + default: Required + description: Resolution specifies whether resolution of this + reference is required. The default is 'Required', which + means the reconcile will fail if the reference cannot be + resolved. 'Optional' means this reference will be a no-op + if it cannot be resolved. + enum: + - Required + - Optional + type: string + resolve: + description: Resolve specifies when this reference should + be resolved. The default is 'IfNotPresent', which will attempt + to resolve the reference only when the corresponding field + is not present. Use 'Always' to resolve the reference on + every reconcile. + enum: + - Always + - IfNotPresent + type: string + type: object + required: + - name + type: object + providerRef: + description: 'ProviderReference specifies the provider that will be + used to create, observe, update, and delete this managed resource. + Deprecated: Please use ProviderConfigReference, i.e. `providerConfigRef`' + properties: + name: + description: Name of the referenced object. + type: string + policy: + description: Policies for referencing. + properties: + resolution: + default: Required + description: Resolution specifies whether resolution of this + reference is required. The default is 'Required', which + means the reconcile will fail if the reference cannot be + resolved. 'Optional' means this reference will be a no-op + if it cannot be resolved. + enum: + - Required + - Optional + type: string + resolve: + description: Resolve specifies when this reference should + be resolved. The default is 'IfNotPresent', which will attempt + to resolve the reference only when the corresponding field + is not present. Use 'Always' to resolve the reference on + every reconcile. + enum: + - Always + - IfNotPresent + type: string + type: object + required: + - name + type: object + publishConnectionDetailsTo: + description: PublishConnectionDetailsTo specifies the connection secret + config which contains a name, metadata and a reference to secret + store config to which any connection details for this managed resource + should be written. Connection details frequently include the endpoint, + username, and password required to connect to the managed resource. + properties: + configRef: + default: + name: default + description: SecretStoreConfigRef specifies which secret store + config should be used for this ConnectionSecret. + properties: + name: + description: Name of the referenced object. + type: string + policy: + description: Policies for referencing. + properties: + resolution: + default: Required + description: Resolution specifies whether resolution of + this reference is required. The default is 'Required', + which means the reconcile will fail if the reference + cannot be resolved. 'Optional' means this reference + will be a no-op if it cannot be resolved. + enum: + - Required + - Optional + type: string + resolve: + description: Resolve specifies when this reference should + be resolved. The default is 'IfNotPresent', which will + attempt to resolve the reference only when the corresponding + field is not present. Use 'Always' to resolve the reference + on every reconcile. + enum: + - Always + - IfNotPresent + type: string + type: object + required: + - name + type: object + metadata: + description: Metadata is the metadata for connection secret. + properties: + annotations: + additionalProperties: + type: string + description: Annotations are the annotations to be added to + connection secret. - For Kubernetes secrets, this will be + used as "metadata.annotations". - It is up to Secret Store + implementation for others store types. + type: object + labels: + additionalProperties: + type: string + description: Labels are the labels/tags to be added to connection + secret. - For Kubernetes secrets, this will be used as "metadata.labels". + - It is up to Secret Store implementation for others store + types. + type: object + type: + description: Type is the SecretType for the connection secret. + - Only valid for Kubernetes Secret Stores. + type: string + type: object + name: + description: Name is the name of the connection secret. + type: string + required: + - name + type: object + writeConnectionSecretToRef: + description: WriteConnectionSecretToReference specifies the namespace + and name of a Secret to which any connection details for this managed + resource should be written. Connection details frequently include + the endpoint, username, and password required to connect to the + managed resource. This field is planned to be replaced in a future + release in favor of PublishConnectionDetailsTo. Currently, both + could be set independently and connection details would be published + to both without affecting each other. + properties: + name: + description: Name of the secret. + type: string + namespace: + description: Namespace of the secret. + type: string + required: + - name + - namespace + type: object + required: + - forProvider + type: object + status: + description: FlowLogStatus defines the observed state of FlowLog. + properties: + atProvider: + description: FlowLogObservation defines the observed state of FlowLog + properties: + creationTime: + description: The date and time the flow log was created. + format: date-time + type: string + deliverLogsStatus: + description: The status of the logs delivery (SUCCESS | FAILED). + type: string + flowLogID: + description: The flow log ID. + type: string + flowLogStatus: + description: The status of the flow log (ACTIVE). + type: string + resourceID: + description: The ID of the resource on which the flow log was + created. + type: string + tags: + description: The tags for the flow log. + items: + properties: + key: + type: string + value: + type: string + type: object + type: array + type: object + conditions: + description: Conditions of the resource. + items: + description: A Condition that may apply to a resource. + properties: + lastTransitionTime: + description: LastTransitionTime is the last time this condition + transitioned from one status to another. + format: date-time + type: string + message: + description: A Message containing details about this condition's + last transition from one status to another, if any. + type: string + reason: + description: A Reason for this condition's last transition from + one status to another. + type: string + status: + description: Status of this condition; is it currently True, + False, or Unknown? + type: string + type: + description: Type of this condition. At most one of each condition + type may apply to a resource at any point in time. + type: string + required: + - lastTransitionTime + - reason + - status + - type + type: object + type: array + type: object + required: + - spec + type: object + served: true + storage: true + subresources: + status: {} +status: + acceptedNames: + kind: "" + plural: "" + conditions: [] + storedVersions: [] diff --git a/pkg/clients/ec2/flowlogs.go b/pkg/clients/ec2/flowlogs.go new file mode 100644 index 0000000000..2d29e9c54b --- /dev/null +++ b/pkg/clients/ec2/flowlogs.go @@ -0,0 +1,18 @@ +package ec2 + +import ( + "errors" + + "github.com/aws/smithy-go" +) + +const ( + // FlowLogNotFound is the code that is returned by ec2 when the given FlowLogId is not valid + FlowLogNotFound = "InvalidFlowLogId.NotFound" +) + +// IsFlowLogsNotFoundErr returns true if the error is because the item doesn't exist +func IsFlowLogsNotFoundErr(err error) bool { + var awsErr smithy.APIError + return errors.As(err, &awsErr) && awsErr.ErrorCode() == FlowLogNotFound +} diff --git a/pkg/controller/aws.go b/pkg/controller/aws.go index 49e684af51..2e304a03a7 100644 --- a/pkg/controller/aws.go +++ b/pkg/controller/aws.go @@ -71,6 +71,7 @@ import ( "github.com/crossplane-contrib/provider-aws/pkg/controller/dynamodb/globaltable" "github.com/crossplane-contrib/provider-aws/pkg/controller/dynamodb/table" "github.com/crossplane-contrib/provider-aws/pkg/controller/ec2/address" + "github.com/crossplane-contrib/provider-aws/pkg/controller/ec2/flowlog" "github.com/crossplane-contrib/provider-aws/pkg/controller/ec2/instance" "github.com/crossplane-contrib/provider-aws/pkg/controller/ec2/internetgateway" "github.com/crossplane-contrib/provider-aws/pkg/controller/ec2/launchtemplate" @@ -330,6 +331,7 @@ func Setup(mgr ctrl.Manager, o controller.Options) error { restapi.SetupRestAPI, method.SetupMethod, cognitoidentitypool.SetupIdentityPool, + flowlog.SetupFlowLog, } { if err := setup(mgr, o); err != nil { return err diff --git a/pkg/controller/cloudfront/lateinit.go b/pkg/controller/cloudfront/lateinit.go index 9fb687a3cb..39ba83bfa7 100644 --- a/pkg/controller/cloudfront/lateinit.go +++ b/pkg/controller/cloudfront/lateinit.go @@ -38,7 +38,8 @@ type LateInitOption interface { } // lateInitOptions Contains options for late-initialization processing of a managed resource. -// Initialized in a managed resource's setup method to customize late-initialization behavior for the resource. +// +// Initialized in a managed resource's setup method to customize late-initialization behavior for the resource. type lateInitOptions struct { nameMappers mapperArr nameFilters filterArr @@ -52,8 +53,9 @@ func (opts *lateInitOptions) apply(opt ...LateInitOption) { } // nameFilter defines a filter on CR filed names as a `LateInitOption`. -// Fields with matching canonical names will not be processed -// during late-initialization. +// +// Fields with matching canonical names will not be processed +// during late-initialization. type nameFilter func(string) bool // apply Applies the receiver `nameFilter` to the specified `lateInitOptions` @@ -82,7 +84,8 @@ func (fArr filterArr) filter(name string) bool { } // canonicalNameFilter returns a `nameFilter` option that filters all specified canonical CR field names. -// Example: `canonicalNameFilter("a.b.c", "a.b.d", "a.b.e")` +// +// Example: `canonicalNameFilter("a.b.c", "a.b.d", "a.b.e")` func canonicalNameFilter(cNames ...string) nameFilter { return func(name string) bool { for _, n := range cNames { @@ -124,12 +127,13 @@ func (mArr mapperArr) getName(name string) string { } // suffixReplacer returns a `NameMapper` as a `LateInitOption` that -// can be used to replace the specified `suffix` on a CR field name -// with the specified `replace` string to obtain the source -// response field name. -// Example: `suffixReplacer("ID", "Id")` tells -// `lateInitializeFromResponse` to fill a target CR field with name `FieldID` -// from a corresponding response field with name `FieldId`. +// +// can be used to replace the specified `suffix` on a CR field name +// with the specified `replace` string to obtain the source +// response field name. +// Example: `suffixReplacer("ID", "Id")` tells +// `lateInitializeFromResponse` to fill a target CR field with name `FieldID` +// from a corresponding response field with name `FieldId`. func suffixReplacer(suffix, replace string) NameMapper { return func(s string) string { trimmed := strings.TrimSuffix(s, suffix) @@ -143,9 +147,10 @@ func suffixReplacer(suffix, replace string) NameMapper { } // Replacer returns a `NameMapper` as a `LateInitOption` that -// that replaces all occurrences of string `old` to `new` in a -// target CR field name to obtain the corresponding -// source response field name. +// +// that replaces all occurrences of string `old` to `new` in a +// target CR field name to obtain the corresponding +// source response field name. func Replacer(old, new string) NameMapper { return func(s string) string { return strings.ReplaceAll(s, old, new) @@ -153,8 +158,9 @@ func Replacer(old, new string) NameMapper { } // MapReplacer returns a `NameMapper` as a `LateInitOption` that -// uses the specified `map[string]string` to map from -// target CR field names to corresponding source response field names. +// +// uses the specified `map[string]string` to map from +// target CR field names to corresponding source response field names. func MapReplacer(m map[string]string) NameMapper { return func(s string) string { if result, ok := m[s]; ok { @@ -166,9 +172,11 @@ func MapReplacer(m map[string]string) NameMapper { } // LateInitializeFromResponse Copy unset (nil) values from responseObject to crObject -// Both crObject and responseObject must be pointers to structs. -// Otherwise, an error will be returned. Returns `true` if at least one field has been stored -// from source `responseObject` into a corresponding field of target `crObject`. +// +// Both crObject and responseObject must be pointers to structs. +// Otherwise, an error will be returned. Returns `true` if at least one field has been stored +// from source `responseObject` into a corresponding field of target `crObject`. +// // nolint:gocyclo func LateInitializeFromResponse(parentName string, crObject interface{}, responseObject interface{}, opts ...LateInitOption) (bool, error) { diff --git a/pkg/controller/cloudwatchlogs/loggroup/setup.go b/pkg/controller/cloudwatchlogs/loggroup/setup.go index ac41b1e3ee..60ff5c9ac4 100644 --- a/pkg/controller/cloudwatchlogs/loggroup/setup.go +++ b/pkg/controller/cloudwatchlogs/loggroup/setup.go @@ -102,6 +102,7 @@ func postObserve(_ context.Context, cr *svcapitypes.LogGroup, obj *svcsdk.Descri return managed.ExternalObservation{}, err } cr.SetConditions(xpv1.Available()) + cr.Status.AtProvider = generateObservation(obj) return obs, nil } @@ -110,7 +111,7 @@ func preCreate(_ context.Context, cr *svcapitypes.LogGroup, obj *svcsdk.CreateLo return nil } -func postCreate(_ context.Context, cr *svcapitypes.LogGroup, obj *svcsdk.CreateLogGroupOutput, _ managed.ExternalCreation, err error) (managed.ExternalCreation, error) { +func postCreate(ctx context.Context, cr *svcapitypes.LogGroup, obj *svcsdk.CreateLogGroupOutput, _ managed.ExternalCreation, err error) (managed.ExternalCreation, error) { if err != nil { return managed.ExternalCreation{}, err } @@ -195,3 +196,21 @@ func (u *updater) update(ctx context.Context, mg resource.Managed) (managed.Exte return managed.ExternalUpdate{}, nil } + +func generateObservation(obj *svcsdk.DescribeLogGroupsOutput) svcapitypes.LogGroupObservation { + if obj == nil || len(obj.LogGroups) == 0 { + return svcapitypes.LogGroupObservation{} + } + + o := svcapitypes.LogGroupObservation{ + ARN: obj.LogGroups[0].Arn, + CreationTime: obj.LogGroups[0].CreationTime, + KMSKeyID: obj.LogGroups[0].KmsKeyId, + LogGroupName: obj.LogGroups[0].LogGroupName, + MetricFilterCount: obj.LogGroups[0].MetricFilterCount, + RetentionInDays: obj.LogGroups[0].RetentionInDays, + StoredBytes: obj.LogGroups[0].StoredBytes, + } + + return o +} diff --git a/pkg/controller/cloudwatchlogs/loggroup/zz_conversions.go b/pkg/controller/cloudwatchlogs/loggroup/zz_conversions.go index de62202102..f400970ecb 100644 --- a/pkg/controller/cloudwatchlogs/loggroup/zz_conversions.go +++ b/pkg/controller/cloudwatchlogs/loggroup/zz_conversions.go @@ -42,11 +42,36 @@ func GenerateLogGroup(resp *svcsdk.DescribeLogGroupsOutput) *svcapitypes.LogGrou found := false for _, elem := range resp.LogGroups { + if elem.CreationTime != nil { + cr.Status.AtProvider.CreationTime = elem.CreationTime + } else { + cr.Status.AtProvider.CreationTime = nil + } + if elem.KmsKeyId != nil { + cr.Status.AtProvider.KMSKeyID = elem.KmsKeyId + } else { + cr.Status.AtProvider.KMSKeyID = nil + } if elem.LogGroupName != nil { cr.Spec.ForProvider.LogGroupName = elem.LogGroupName } else { cr.Spec.ForProvider.LogGroupName = nil } + if elem.MetricFilterCount != nil { + cr.Status.AtProvider.MetricFilterCount = elem.MetricFilterCount + } else { + cr.Status.AtProvider.MetricFilterCount = nil + } + if elem.RetentionInDays != nil { + cr.Status.AtProvider.RetentionInDays = elem.RetentionInDays + } else { + cr.Status.AtProvider.RetentionInDays = nil + } + if elem.StoredBytes != nil { + cr.Status.AtProvider.StoredBytes = elem.StoredBytes + } else { + cr.Status.AtProvider.StoredBytes = nil + } found = true break } diff --git a/pkg/controller/ec2/flowlog/setup.go b/pkg/controller/ec2/flowlog/setup.go new file mode 100644 index 0000000000..1b692941c3 --- /dev/null +++ b/pkg/controller/ec2/flowlog/setup.go @@ -0,0 +1,317 @@ +package flowlog + +import ( + "context" + + svcsdk "github.com/aws/aws-sdk-go/service/ec2" + "github.com/aws/aws-sdk-go/service/ec2/ec2iface" + + svcapitypes "github.com/crossplane-contrib/provider-aws/apis/ec2/v1alpha1" + + "github.com/crossplane-contrib/provider-aws/apis/v1alpha1" + + aws "github.com/crossplane-contrib/provider-aws/pkg/clients" + awsclient "github.com/crossplane-contrib/provider-aws/pkg/clients" + + "github.com/crossplane-contrib/provider-aws/pkg/features" + + xpv1 "github.com/crossplane/crossplane-runtime/apis/common/v1" + + "github.com/crossplane/crossplane-runtime/pkg/connection" + "github.com/crossplane/crossplane-runtime/pkg/controller" + "github.com/crossplane/crossplane-runtime/pkg/errors" + "github.com/crossplane/crossplane-runtime/pkg/event" + "github.com/crossplane/crossplane-runtime/pkg/meta" + "github.com/crossplane/crossplane-runtime/pkg/reconciler/managed" + "github.com/crossplane/crossplane-runtime/pkg/resource" + + cpresource "github.com/crossplane/crossplane-runtime/pkg/resource" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + ctrl "sigs.k8s.io/controller-runtime" +) + +var ( + _ = &metav1.Time{} +) + +const ( + errUpdateTags = "cannot update tags" + flowLogTagResource = "vpc-flow-log" +) + +type updater struct { + client ec2iface.EC2API +} +type deleter struct { + client ec2iface.EC2API +} + +// SetupFlowLog adds a controller that reconciles FlowLog +func SetupFlowLog(mgr ctrl.Manager, o controller.Options) error { + name := managed.ControllerName(svcapitypes.FlowLogGroupKind) + opts := []option{ + func(e *external) { + e.preCreate = preCreate + e.preObserve = preObserve + e.filterList = filterList + e.postObserve = postObserve + e.postCreate = postCreate + u := &updater{client: e.client} + e.isUpToDate = u.isUpToDate + e.update = u.update + d := &deleter{client: e.client} + e.delete = d.delete + }, + } + + cps := []managed.ConnectionPublisher{managed.NewAPISecretPublisher(mgr.GetClient(), mgr.GetScheme())} + if o.Features.Enabled(features.EnableAlphaExternalSecretStores) { + cps = append(cps, connection.NewDetailsManager(mgr.GetClient(), v1alpha1.StoreConfigGroupVersionKind)) + } + + return ctrl.NewControllerManagedBy(mgr). + Named(name). + WithOptions(o.ForControllerRuntime()). + For(&svcapitypes.FlowLog{}). + Complete(managed.NewReconciler(mgr, + resource.ManagedKind(svcapitypes.FlowLogGroupVersionKind), + managed.WithExternalConnecter(&connector{kube: mgr.GetClient(), opts: opts}), + managed.WithInitializers(), + managed.WithPollInterval(o.PollInterval), + managed.WithLogger(o.Logger.WithValues("controller", name)), + managed.WithRecorder(event.NewAPIRecorder(mgr.GetEventRecorderFor(name))), + managed.WithConnectionPublishers(cps...))) + +} + +func determineResourceIdsAndType(cr *svcapitypes.FlowLog) ([]*string, *string) { + vpcResourceType := svcsdk.FlowLogsResourceTypeVpc + transitGatewayResourceType := "TransitGateway" + transitGatewayAttachmentResourceType := "TransitGatewayAttachment" + subnetResourceType := svcsdk.FlowLogsResourceTypeSubnet + networkInterfaceResourceType := svcsdk.FlowLogsResourceTypeNetworkInterface + if cr.Spec.ForProvider.VPCID != nil { + return []*string{cr.Spec.ForProvider.VPCID}, &vpcResourceType + } + + if cr.Spec.ForProvider.TransitGatewayID != nil { + return []*string{cr.Spec.ForProvider.TransitGatewayID}, &transitGatewayResourceType + } + + if cr.Spec.ForProvider.TransitGatewayAttachmentID != nil { + return []*string{cr.Spec.ForProvider.TransitGatewayAttachmentID}, &transitGatewayAttachmentResourceType + } + + if cr.Spec.ForProvider.SubnetID != nil { + return []*string{cr.Spec.ForProvider.SubnetID}, &subnetResourceType + } + + if cr.Spec.ForProvider.NetworkInterfaceID != nil { + return []*string{cr.Spec.ForProvider.NetworkInterfaceID}, &networkInterfaceResourceType + } + + return nil, nil +} + +func preObserve(ctx context.Context, cr *svcapitypes.FlowLog, obj *svcsdk.DescribeFlowLogsInput) error { + externalName := meta.GetExternalName(cr) + obj.FlowLogIds = []*string{&externalName} + return nil +} + +func filterList(cr *svcapitypes.FlowLog, list *svcsdk.DescribeFlowLogsOutput) *svcsdk.DescribeFlowLogsOutput { + if len(list.FlowLogs) == 0 { + return list + } + flowLogs := []*svcsdk.FlowLog{} + for _, f := range list.FlowLogs { + if aws.StringValue(f.FlowLogId) == meta.GetExternalName(cr) { + flowLogs = append(flowLogs, f) + } + } + list.FlowLogs = flowLogs + return list +} + +func postObserve(ctx context.Context, cr *svcapitypes.FlowLog, obj *svcsdk.DescribeFlowLogsOutput, obs managed.ExternalObservation, err error) (managed.ExternalObservation, error) { + cr.SetConditions(xpv1.Available()) + return obs, err +} + +func preCreate(_ context.Context, cr *svcapitypes.FlowLog, obj *svcsdk.CreateFlowLogsInput) error { + + if cr.Spec.ForProvider.S3BucketLogDestination != nil { + obj.LogDestination = cr.Spec.ForProvider.S3BucketLogDestination + if cr.Spec.ForProvider.S3BucketSubfolder != nil { + // If a subfolder is given, we append it to the ARN managed by crossplane + destination := *obj.LogDestination + "/" + *cr.Spec.ForProvider.S3BucketSubfolder + "/" + obj.LogDestination = &destination + } + } + + if cr.Spec.ForProvider.CloudWatchLogDestination != nil { + obj.LogDestination = cr.Spec.ForProvider.CloudWatchLogDestination + } + + if cr.Spec.ForProvider.Tags != nil { + + obj.SetTagSpecifications(generateTagSpecifications(cr)) + } + + obj.ResourceIds, obj.ResourceType = determineResourceIdsAndType(cr) + + return nil +} + +func generateTagSpecifications(cr *svcapitypes.FlowLog) []*svcsdk.TagSpecification { + tagSpecification := &svcsdk.TagSpecification{} + tagSpecification.SetResourceType(flowLogTagResource) + tags := []*svcsdk.Tag{} + + for _, cTag := range cr.Spec.ForProvider.Tags { + tag := &svcsdk.Tag{} + + if cTag.Key != nil { + tag.SetKey(*cTag.Key) + } + if cTag.Value != nil { + tag.SetValue(*cTag.Value) + } + tags = append(tags, tag) + } + + tagSpecification.SetTags(tags) + tagSpecifications := []*svcsdk.TagSpecification{tagSpecification} + return tagSpecifications +} + +func postCreate(ctx context.Context, cr *svcapitypes.FlowLog, obj *svcsdk.CreateFlowLogsOutput, cre managed.ExternalCreation, err error) (managed.ExternalCreation, error) { + if len(obj.FlowLogIds) > 0 { + meta.SetExternalName(cr, aws.StringValue(obj.FlowLogIds[0])) + } + return cre, nil +} + +func (u *updater) isUpToDate(cr *svcapitypes.FlowLog, obj *svcsdk.DescribeFlowLogsOutput) (bool, error) { + + input := GenerateDescribeFlowLogsInput(cr) + resp, err := u.client.DescribeFlowLogs(input) + if err != nil { + return false, errors.Wrap(err, errDescribe) + } + + resp = filterList(cr, resp) + + if len(resp.FlowLogs) == 0 { + return false, errors.New(errDescribe) + } + + tags := resp.FlowLogs[0].Tags + + add, remove := DiffTags(cr.Spec.ForProvider.Tags, tags) + + return len(add) == 0 && len(remove) == 0, nil +} + +func (u *updater) update(ctx context.Context, mg cpresource.Managed) (managed.ExternalUpdate, error) { + cr, ok := mg.(*svcapitypes.FlowLog) + if !ok { + return managed.ExternalUpdate{}, errors.New(errUnexpectedObject) + } + input := GenerateDescribeFlowLogsInput(cr) + resp, err := u.client.DescribeFlowLogs(input) + if err != nil { + return managed.ExternalUpdate{}, errors.Wrap(err, errDescribe) + } + + resp = filterList(cr, resp) + + if len(resp.FlowLogs) == 0 { + return managed.ExternalUpdate{}, errors.New(errDescribe) + } + + tags := resp.FlowLogs[0].Tags + + add, remove := DiffTags(cr.Spec.ForProvider.Tags, tags) + err = u.updateTags(ctx, cr, add, remove) + if err != nil { + return managed.ExternalUpdate{}, err + } + + return managed.ExternalUpdate{}, nil +} + +// DiffTags returns tags that should be added or removed. +func DiffTags(spec []svcapitypes.Tag, current []*svcsdk.Tag) (addTags []*svcsdk.Tag, remove []*svcsdk.Tag) { + addMap := make(map[string]string, len(spec)) + for _, t := range spec { + addMap[aws.StringValue(t.Key)] = aws.StringValue(t.Value) + } + removeMap := make(map[string]string, len(spec)) + for _, t := range current { + if addMap[aws.StringValue(t.Key)] == aws.StringValue(t.Value) { + delete(addMap, aws.StringValue(t.Key)) + continue + } + removeMap[aws.StringValue(t.Key)] = aws.StringValue(t.Value) + } + for k, v := range addMap { + addTags = append(addTags, &svcsdk.Tag{Key: aws.String(k), Value: aws.String(v)}) + } + for k, v := range removeMap { + remove = append(remove, &svcsdk.Tag{Key: aws.String(k), Value: aws.String(v)}) + } + return +} + +func (u *updater) updateTags(ctx context.Context, cr *svcapitypes.FlowLog, addTags []*svcsdk.Tag, removeTags []*svcsdk.Tag) error { + + if len(removeTags) > 0 { + inputR := &svcsdk.DeleteTagsInput{ + Resources: aws.StringSliceToPtr([]string{meta.GetExternalName(cr)}), + Tags: removeTags, + } + + _, err := u.client.DeleteTagsWithContext(ctx, inputR) + if err != nil { + return errors.New(errUpdateTags) + } + } + if len(addTags) > 0 { + inputC := &svcsdk.CreateTagsInput{ + Resources: aws.StringSliceToPtr([]string{meta.GetExternalName(cr)}), + Tags: addTags, + } + + _, err := u.client.CreateTagsWithContext(ctx, inputC) + if err != nil { + return errors.New(errUpdateTags) + } + + } + return nil + +} + +// GenerateDeleteFlowLogsInput returns a deletion input. +func GenerateDeleteFlowLogsInput(cr *svcapitypes.FlowLog) *svcsdk.DeleteFlowLogsInput { + res := &svcsdk.DeleteFlowLogsInput{} + + externalName := meta.GetExternalName(cr) + res.SetFlowLogIds([]*string{&externalName}) + return res +} + +func (d *deleter) delete(ctx context.Context, mg cpresource.Managed) error { + cr, ok := mg.(*svcapitypes.FlowLog) + if !ok { + return errors.New(errUnexpectedObject) + } + cr.Status.SetConditions(xpv1.Deleting()) + if meta.GetExternalName(cr) == "" { + return nil + } + input := GenerateDeleteFlowLogsInput(cr) + _, err := d.client.DeleteFlowLogsWithContext(ctx, input) + return awsclient.Wrap(cpresource.Ignore(IsNotFound, err), errDelete) +} diff --git a/pkg/controller/ec2/flowlog/zz_controller.go b/pkg/controller/ec2/flowlog/zz_controller.go new file mode 100644 index 0000000000..b94df7fe50 --- /dev/null +++ b/pkg/controller/ec2/flowlog/zz_controller.go @@ -0,0 +1,209 @@ +/* +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. +*/ + +// Code generated by ack-generate. DO NOT EDIT. + +package flowlog + +import ( + "context" + + svcapi "github.com/aws/aws-sdk-go/service/ec2" + svcsdk "github.com/aws/aws-sdk-go/service/ec2" + svcsdkapi "github.com/aws/aws-sdk-go/service/ec2/ec2iface" + "github.com/google/go-cmp/cmp" + "github.com/pkg/errors" + "sigs.k8s.io/controller-runtime/pkg/client" + + xpv1 "github.com/crossplane/crossplane-runtime/apis/common/v1" + "github.com/crossplane/crossplane-runtime/pkg/meta" + "github.com/crossplane/crossplane-runtime/pkg/reconciler/managed" + cpresource "github.com/crossplane/crossplane-runtime/pkg/resource" + + svcapitypes "github.com/crossplane-contrib/provider-aws/apis/ec2/v1alpha1" + awsclient "github.com/crossplane-contrib/provider-aws/pkg/clients" +) + +const ( + errUnexpectedObject = "managed resource is not an FlowLog resource" + + errCreateSession = "cannot create a new session" + errCreate = "cannot create FlowLog in AWS" + errUpdate = "cannot update FlowLog in AWS" + errDescribe = "failed to describe FlowLog" + errDelete = "failed to delete FlowLog" +) + +type connector struct { + kube client.Client + opts []option +} + +func (c *connector) Connect(ctx context.Context, mg cpresource.Managed) (managed.ExternalClient, error) { + cr, ok := mg.(*svcapitypes.FlowLog) + if !ok { + return nil, errors.New(errUnexpectedObject) + } + sess, err := awsclient.GetConfigV1(ctx, c.kube, mg, cr.Spec.ForProvider.Region) + if err != nil { + return nil, errors.Wrap(err, errCreateSession) + } + return newExternal(c.kube, svcapi.New(sess), c.opts), nil +} + +func (e *external) Observe(ctx context.Context, mg cpresource.Managed) (managed.ExternalObservation, error) { + cr, ok := mg.(*svcapitypes.FlowLog) + if !ok { + return managed.ExternalObservation{}, errors.New(errUnexpectedObject) + } + if meta.GetExternalName(cr) == "" { + return managed.ExternalObservation{ + ResourceExists: false, + }, nil + } + input := GenerateDescribeFlowLogsInput(cr) + if err := e.preObserve(ctx, cr, input); err != nil { + return managed.ExternalObservation{}, errors.Wrap(err, "pre-observe failed") + } + resp, err := e.client.DescribeFlowLogsWithContext(ctx, input) + if err != nil { + return managed.ExternalObservation{ResourceExists: false}, awsclient.Wrap(cpresource.Ignore(IsNotFound, err), errDescribe) + } + resp = e.filterList(cr, resp) + if len(resp.FlowLogs) == 0 { + return managed.ExternalObservation{ResourceExists: false}, nil + } + currentSpec := cr.Spec.ForProvider.DeepCopy() + if err := e.lateInitialize(&cr.Spec.ForProvider, resp); err != nil { + return managed.ExternalObservation{}, errors.Wrap(err, "late-init failed") + } + GenerateFlowLog(resp).Status.AtProvider.DeepCopyInto(&cr.Status.AtProvider) + + upToDate, err := e.isUpToDate(cr, resp) + if err != nil { + return managed.ExternalObservation{}, errors.Wrap(err, "isUpToDate check failed") + } + return e.postObserve(ctx, cr, resp, managed.ExternalObservation{ + ResourceExists: true, + ResourceUpToDate: upToDate, + ResourceLateInitialized: !cmp.Equal(&cr.Spec.ForProvider, currentSpec), + }, nil) +} + +func (e *external) Create(ctx context.Context, mg cpresource.Managed) (managed.ExternalCreation, error) { + cr, ok := mg.(*svcapitypes.FlowLog) + if !ok { + return managed.ExternalCreation{}, errors.New(errUnexpectedObject) + } + cr.Status.SetConditions(xpv1.Creating()) + input := GenerateCreateFlowLogsInput(cr) + if err := e.preCreate(ctx, cr, input); err != nil { + return managed.ExternalCreation{}, errors.Wrap(err, "pre-create failed") + } + resp, err := e.client.CreateFlowLogsWithContext(ctx, input) + if err != nil { + return managed.ExternalCreation{}, awsclient.Wrap(err, errCreate) + } + + if resp.ClientToken != nil { + cr.Spec.ForProvider.ClientToken = resp.ClientToken + } else { + cr.Spec.ForProvider.ClientToken = nil + } + + return e.postCreate(ctx, cr, resp, managed.ExternalCreation{}, err) +} + +func (e *external) Update(ctx context.Context, mg cpresource.Managed) (managed.ExternalUpdate, error) { + return e.update(ctx, mg) + +} + +func (e *external) Delete(ctx context.Context, mg cpresource.Managed) error { + cr, ok := mg.(*svcapitypes.FlowLog) + if !ok { + return errors.New(errUnexpectedObject) + } + cr.Status.SetConditions(xpv1.Deleting()) + return e.delete(ctx, mg) + +} + +type option func(*external) + +func newExternal(kube client.Client, client svcsdkapi.EC2API, opts []option) *external { + e := &external{ + kube: kube, + client: client, + preObserve: nopPreObserve, + postObserve: nopPostObserve, + lateInitialize: nopLateInitialize, + isUpToDate: alwaysUpToDate, + filterList: nopFilterList, + preCreate: nopPreCreate, + postCreate: nopPostCreate, + delete: nopDelete, + update: nopUpdate, + } + for _, f := range opts { + f(e) + } + return e +} + +type external struct { + kube client.Client + client svcsdkapi.EC2API + preObserve func(context.Context, *svcapitypes.FlowLog, *svcsdk.DescribeFlowLogsInput) error + postObserve func(context.Context, *svcapitypes.FlowLog, *svcsdk.DescribeFlowLogsOutput, managed.ExternalObservation, error) (managed.ExternalObservation, error) + filterList func(*svcapitypes.FlowLog, *svcsdk.DescribeFlowLogsOutput) *svcsdk.DescribeFlowLogsOutput + lateInitialize func(*svcapitypes.FlowLogParameters, *svcsdk.DescribeFlowLogsOutput) error + isUpToDate func(*svcapitypes.FlowLog, *svcsdk.DescribeFlowLogsOutput) (bool, error) + preCreate func(context.Context, *svcapitypes.FlowLog, *svcsdk.CreateFlowLogsInput) error + postCreate func(context.Context, *svcapitypes.FlowLog, *svcsdk.CreateFlowLogsOutput, managed.ExternalCreation, error) (managed.ExternalCreation, error) + delete func(context.Context, cpresource.Managed) error + update func(context.Context, cpresource.Managed) (managed.ExternalUpdate, error) +} + +func nopPreObserve(context.Context, *svcapitypes.FlowLog, *svcsdk.DescribeFlowLogsInput) error { + return nil +} +func nopPostObserve(_ context.Context, _ *svcapitypes.FlowLog, _ *svcsdk.DescribeFlowLogsOutput, obs managed.ExternalObservation, err error) (managed.ExternalObservation, error) { + return obs, err +} +func nopFilterList(_ *svcapitypes.FlowLog, list *svcsdk.DescribeFlowLogsOutput) *svcsdk.DescribeFlowLogsOutput { + return list +} + +func nopLateInitialize(*svcapitypes.FlowLogParameters, *svcsdk.DescribeFlowLogsOutput) error { + return nil +} +func alwaysUpToDate(*svcapitypes.FlowLog, *svcsdk.DescribeFlowLogsOutput) (bool, error) { + return true, nil +} + +func nopPreCreate(context.Context, *svcapitypes.FlowLog, *svcsdk.CreateFlowLogsInput) error { + return nil +} +func nopPostCreate(_ context.Context, _ *svcapitypes.FlowLog, _ *svcsdk.CreateFlowLogsOutput, cre managed.ExternalCreation, err error) (managed.ExternalCreation, error) { + return cre, err +} +func nopDelete(context.Context, cpresource.Managed) error { + return nil +} +func nopUpdate(context.Context, cpresource.Managed) (managed.ExternalUpdate, error) { + return managed.ExternalUpdate{}, nil +} diff --git a/pkg/controller/ec2/flowlog/zz_conversions.go b/pkg/controller/ec2/flowlog/zz_conversions.go new file mode 100644 index 0000000000..3b8721be75 --- /dev/null +++ b/pkg/controller/ec2/flowlog/zz_conversions.go @@ -0,0 +1,196 @@ +/* +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. +*/ + +// Code generated by ack-generate. DO NOT EDIT. + +package flowlog + +import ( + "github.com/aws/aws-sdk-go/aws/awserr" + svcsdk "github.com/aws/aws-sdk-go/service/ec2" + metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" + + svcapitypes "github.com/crossplane-contrib/provider-aws/apis/ec2/v1alpha1" +) + +// NOTE(muvaf): We return pointers in case the function needs to start with an +// empty object, hence need to return a new pointer. + +// GenerateDescribeFlowLogsInput returns input for read +// operation. +func GenerateDescribeFlowLogsInput(cr *svcapitypes.FlowLog) *svcsdk.DescribeFlowLogsInput { + res := &svcsdk.DescribeFlowLogsInput{} + + return res +} + +// GenerateFlowLog returns the current state in the form of *svcapitypes.FlowLog. +func GenerateFlowLog(resp *svcsdk.DescribeFlowLogsOutput) *svcapitypes.FlowLog { + cr := &svcapitypes.FlowLog{} + + found := false + for _, elem := range resp.FlowLogs { + if elem.CreationTime != nil { + cr.Status.AtProvider.CreationTime = &metav1.Time{*elem.CreationTime} + } else { + cr.Status.AtProvider.CreationTime = nil + } + if elem.DeliverLogsPermissionArn != nil { + cr.Spec.ForProvider.DeliverLogsPermissionARN = elem.DeliverLogsPermissionArn + } else { + cr.Spec.ForProvider.DeliverLogsPermissionARN = nil + } + if elem.DeliverLogsStatus != nil { + cr.Status.AtProvider.DeliverLogsStatus = elem.DeliverLogsStatus + } else { + cr.Status.AtProvider.DeliverLogsStatus = nil + } + if elem.DestinationOptions != nil { + f4 := &svcapitypes.DestinationOptionsRequest{} + if elem.DestinationOptions.FileFormat != nil { + f4.FileFormat = elem.DestinationOptions.FileFormat + } + if elem.DestinationOptions.HiveCompatiblePartitions != nil { + f4.HiveCompatiblePartitions = elem.DestinationOptions.HiveCompatiblePartitions + } + if elem.DestinationOptions.PerHourPartition != nil { + f4.PerHourPartition = elem.DestinationOptions.PerHourPartition + } + cr.Spec.ForProvider.DestinationOptions = f4 + } else { + cr.Spec.ForProvider.DestinationOptions = nil + } + if elem.FlowLogId != nil { + cr.Status.AtProvider.FlowLogID = elem.FlowLogId + } else { + cr.Status.AtProvider.FlowLogID = nil + } + if elem.FlowLogStatus != nil { + cr.Status.AtProvider.FlowLogStatus = elem.FlowLogStatus + } else { + cr.Status.AtProvider.FlowLogStatus = nil + } + if elem.LogDestination != nil { + cr.Spec.ForProvider.LogDestination = elem.LogDestination + } else { + cr.Spec.ForProvider.LogDestination = nil + } + if elem.LogDestinationType != nil { + cr.Spec.ForProvider.LogDestinationType = elem.LogDestinationType + } else { + cr.Spec.ForProvider.LogDestinationType = nil + } + if elem.LogFormat != nil { + cr.Spec.ForProvider.LogFormat = elem.LogFormat + } else { + cr.Spec.ForProvider.LogFormat = nil + } + if elem.LogGroupName != nil { + cr.Spec.ForProvider.LogGroupName = elem.LogGroupName + } else { + cr.Spec.ForProvider.LogGroupName = nil + } + if elem.MaxAggregationInterval != nil { + cr.Spec.ForProvider.MaxAggregationInterval = elem.MaxAggregationInterval + } else { + cr.Spec.ForProvider.MaxAggregationInterval = nil + } + if elem.ResourceId != nil { + cr.Status.AtProvider.ResourceID = elem.ResourceId + } else { + cr.Status.AtProvider.ResourceID = nil + } + if elem.Tags != nil { + f13 := []*svcapitypes.Tag{} + for _, f13iter := range elem.Tags { + f13elem := &svcapitypes.Tag{} + if f13iter.Key != nil { + f13elem.Key = f13iter.Key + } + if f13iter.Value != nil { + f13elem.Value = f13iter.Value + } + f13 = append(f13, f13elem) + } + cr.Status.AtProvider.Tags = f13 + } else { + cr.Status.AtProvider.Tags = nil + } + if elem.TrafficType != nil { + cr.Spec.ForProvider.TrafficType = elem.TrafficType + } else { + cr.Spec.ForProvider.TrafficType = nil + } + found = true + break + } + if !found { + return cr + } + + return cr +} + +// GenerateCreateFlowLogsInput returns a create input. +func GenerateCreateFlowLogsInput(cr *svcapitypes.FlowLog) *svcsdk.CreateFlowLogsInput { + res := &svcsdk.CreateFlowLogsInput{} + + if cr.Spec.ForProvider.ClientToken != nil { + res.SetClientToken(*cr.Spec.ForProvider.ClientToken) + } + if cr.Spec.ForProvider.DeliverLogsPermissionARN != nil { + res.SetDeliverLogsPermissionArn(*cr.Spec.ForProvider.DeliverLogsPermissionARN) + } + if cr.Spec.ForProvider.DestinationOptions != nil { + f2 := &svcsdk.DestinationOptionsRequest{} + if cr.Spec.ForProvider.DestinationOptions.FileFormat != nil { + f2.SetFileFormat(*cr.Spec.ForProvider.DestinationOptions.FileFormat) + } + if cr.Spec.ForProvider.DestinationOptions.HiveCompatiblePartitions != nil { + f2.SetHiveCompatiblePartitions(*cr.Spec.ForProvider.DestinationOptions.HiveCompatiblePartitions) + } + if cr.Spec.ForProvider.DestinationOptions.PerHourPartition != nil { + f2.SetPerHourPartition(*cr.Spec.ForProvider.DestinationOptions.PerHourPartition) + } + res.SetDestinationOptions(f2) + } + if cr.Spec.ForProvider.LogDestination != nil { + res.SetLogDestination(*cr.Spec.ForProvider.LogDestination) + } + if cr.Spec.ForProvider.LogDestinationType != nil { + res.SetLogDestinationType(*cr.Spec.ForProvider.LogDestinationType) + } + if cr.Spec.ForProvider.LogFormat != nil { + res.SetLogFormat(*cr.Spec.ForProvider.LogFormat) + } + if cr.Spec.ForProvider.LogGroupName != nil { + res.SetLogGroupName(*cr.Spec.ForProvider.LogGroupName) + } + if cr.Spec.ForProvider.MaxAggregationInterval != nil { + res.SetMaxAggregationInterval(*cr.Spec.ForProvider.MaxAggregationInterval) + } + if cr.Spec.ForProvider.TrafficType != nil { + res.SetTrafficType(*cr.Spec.ForProvider.TrafficType) + } + + return res +} + +// IsNotFound returns whether the given error is of type NotFound or not. +func IsNotFound(err error) bool { + awsErr, ok := err.(awserr.Error) + return ok && awsErr.Code() == "UNKNOWN" +} diff --git a/pkg/controller/ec2/vpcendpoint/setup.go b/pkg/controller/ec2/vpcendpoint/setup.go index c4ea093a43..a352806be3 100644 --- a/pkg/controller/ec2/vpcendpoint/setup.go +++ b/pkg/controller/ec2/vpcendpoint/setup.go @@ -299,10 +299,11 @@ func formatModifyVpcEndpointInput(obj *svcsdk.ModifyVpcEndpointInput) { // ([]*string) "base", "subtract", and returns a "result" list // of string pointers where "result" = "base" - "subtract". // Comparisons of the underlying string is done -// Example: -// "base": ["a", "b", "g", "x"] -// "subtract": ["b", "x", "y"] -// "result": ["a", "g"] +// +// Example: +// "base": ["a", "b", "g", "x"] +// "subtract": ["b", "x", "y"] +// "result": ["a", "g"] func listSubtractFromStringPtr(base, subtract []*string) []*string { result := []*string{}