From 0bc8090c23e71d900c5cb644a8656ccc8683c336 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9=20Kesser?= Date: Wed, 17 Aug 2022 08:22:26 +0200 Subject: [PATCH] fix: Fixed generation of flowlog MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: André Kesser (cherry picked from commit ba2dbaeabc3ede0fc93952f16934160d10290f1c) --- apis/ec2/generator-config.yaml | 2 +- apis/ec2/v1alpha1/custom_types.go | 5 ++++- apis/ec2/v1alpha1/zz_flow_log.go | 6 ------ apis/ec2/v1alpha1/zz_generated.deepcopy.go | 5 ----- .../crds/ec2.aws.crossplane.io_flowlogs.yaml | 9 +++------ pkg/controller/ec2/flowlog/setup.go | 4 ++++ pkg/controller/ec2/flowlog/zz_conversions.go | 18 +++++------------- 7 files changed, 17 insertions(+), 32 deletions(-) diff --git a/apis/ec2/generator-config.yaml b/apis/ec2/generator-config.yaml index e2274caa64..a71e5c6081 100644 --- a/apis/ec2/generator-config.yaml +++ b/apis/ec2/generator-config.yaml @@ -123,7 +123,7 @@ ignore: - CreateFlowLogsInput.ResourceIds - CreateFlowLogsInput.ResourceType - CreateFlowLogsInput.TagSpecifications - - CreateFlowLogsInput.DeliverLogsPermissionARN + - CreateFlowLogsInput.DeliverLogsPermissionArn - DescribeFlowLogsInput.FlowLogIds - DescribeFlowLogsInput.DryRun - CreateFlowLogsOutput.FlowLogIds diff --git a/apis/ec2/v1alpha1/custom_types.go b/apis/ec2/v1alpha1/custom_types.go index 31b109a550..f368ea4ba1 100644 --- a/apis/ec2/v1alpha1/custom_types.go +++ b/apis/ec2/v1alpha1/custom_types.go @@ -527,7 +527,10 @@ type CustomFlowLogParameters struct { // +optional NetworkInterfaceID *string `json:"networkInterfaceId"` - // The Amazon Resource Names (ARNs) of an IAM Role. + // 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. // +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"` diff --git a/apis/ec2/v1alpha1/zz_flow_log.go b/apis/ec2/v1alpha1/zz_flow_log.go index 998f5c3177..a26d5ba357 100644 --- a/apis/ec2/v1alpha1/zz_flow_log.go +++ b/apis/ec2/v1alpha1/zz_flow_log.go @@ -32,12 +32,6 @@ type FlowLogParameters struct { // 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 diff --git a/apis/ec2/v1alpha1/zz_generated.deepcopy.go b/apis/ec2/v1alpha1/zz_generated.deepcopy.go index d3105b6b96..c0e9b57b24 100644 --- a/apis/ec2/v1alpha1/zz_generated.deepcopy.go +++ b/apis/ec2/v1alpha1/zz_generated.deepcopy.go @@ -5346,11 +5346,6 @@ func (in *FlowLogParameters) DeepCopyInto(out *FlowLogParameters) { *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) diff --git a/package/crds/ec2.aws.crossplane.io_flowlogs.yaml b/package/crds/ec2.aws.crossplane.io_flowlogs.yaml index c802302fb4..bb6fff050b 100644 --- a/package/crds/ec2.aws.crossplane.io_flowlogs.yaml +++ b/package/crds/ec2.aws.crossplane.io_flowlogs.yaml @@ -145,14 +145,11 @@ spec: type: string type: object type: object - deliverLogsPermissionARN: - description: "The ARN for the IAM role that permits Amazon EC2 + 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. + specify DeliverLogsPermissionArn or LogGroupName. type: string deliverLogsPermissionArnRef: description: DeliverLogsPermissionARNRef is a reference to DeliverLogsPermissionARN diff --git a/pkg/controller/ec2/flowlog/setup.go b/pkg/controller/ec2/flowlog/setup.go index 1b692941c3..4449729934 100644 --- a/pkg/controller/ec2/flowlog/setup.go +++ b/pkg/controller/ec2/flowlog/setup.go @@ -153,6 +153,10 @@ func preCreate(_ context.Context, cr *svcapitypes.FlowLog, obj *svcsdk.CreateFlo obj.LogDestination = cr.Spec.ForProvider.CloudWatchLogDestination } + if cr.Spec.ForProvider.DeliverLogsPermissionARN != nil { + obj.DeliverLogsPermissionArn = cr.Spec.ForProvider.DeliverLogsPermissionARN + } + if cr.Spec.ForProvider.Tags != nil { obj.SetTagSpecifications(generateTagSpecifications(cr)) diff --git a/pkg/controller/ec2/flowlog/zz_conversions.go b/pkg/controller/ec2/flowlog/zz_conversions.go index 3b8721be75..eaf33559b8 100644 --- a/pkg/controller/ec2/flowlog/zz_conversions.go +++ b/pkg/controller/ec2/flowlog/zz_conversions.go @@ -48,11 +48,6 @@ func GenerateFlowLog(resp *svcsdk.DescribeFlowLogsOutput) *svcapitypes.FlowLog { } 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 { @@ -151,21 +146,18 @@ func GenerateCreateFlowLogsInput(cr *svcapitypes.FlowLog) *svcsdk.CreateFlowLogs 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{} + f1 := &svcsdk.DestinationOptionsRequest{} if cr.Spec.ForProvider.DestinationOptions.FileFormat != nil { - f2.SetFileFormat(*cr.Spec.ForProvider.DestinationOptions.FileFormat) + f1.SetFileFormat(*cr.Spec.ForProvider.DestinationOptions.FileFormat) } if cr.Spec.ForProvider.DestinationOptions.HiveCompatiblePartitions != nil { - f2.SetHiveCompatiblePartitions(*cr.Spec.ForProvider.DestinationOptions.HiveCompatiblePartitions) + f1.SetHiveCompatiblePartitions(*cr.Spec.ForProvider.DestinationOptions.HiveCompatiblePartitions) } if cr.Spec.ForProvider.DestinationOptions.PerHourPartition != nil { - f2.SetPerHourPartition(*cr.Spec.ForProvider.DestinationOptions.PerHourPartition) + f1.SetPerHourPartition(*cr.Spec.ForProvider.DestinationOptions.PerHourPartition) } - res.SetDestinationOptions(f2) + res.SetDestinationOptions(f1) } if cr.Spec.ForProvider.LogDestination != nil { res.SetLogDestination(*cr.Spec.ForProvider.LogDestination)