From affd2a0c65dae2ddc7b2aa22654a0bf052bca2a1 Mon Sep 17 00:00:00 2001
From: Blake R <85771645+blakeromano@users.noreply.github.com>
Date: Thu, 21 Mar 2024 18:30:41 -0700
Subject: [PATCH] Remove ARN Parameter from Firehose Resource

Signed-off-by: Blake R <85771645+blakeromano@users.noreply.github.com>
---
 .../v1beta1/zz_deliverystream_types.go        | 11 ++--------
 .../firehose/v1beta1/zz_generated.deepcopy.go | 10 ---------
 .../v1beta1/zz_generated.resolvers.go         |  4 ++--
 config/firehose/config.go                     | 22 ++++++++++---------
 ...rehose.aws.upbound.io_deliverystreams.yaml |  6 -----
 5 files changed, 16 insertions(+), 37 deletions(-)

diff --git a/apis/firehose/v1beta1/zz_deliverystream_types.go b/apis/firehose/v1beta1/zz_deliverystream_types.go
index 1f64146640..7208866b7b 100755
--- a/apis/firehose/v1beta1/zz_deliverystream_types.go
+++ b/apis/firehose/v1beta1/zz_deliverystream_types.go
@@ -161,9 +161,6 @@ type DataFormatConversionConfigurationParameters struct {
 
 type DeliveryStreamInitParameters struct {
 
-	// The Amazon Resource Name (ARN) specifying the Stream
-	Arn *string `json:"arn,omitempty" tf:"arn,omitempty"`
-
 	// –  This is the destination to where the data is delivered. The only options are s3 (Deprecated, use extended_s3 instead), extended_s3, redshift, elasticsearch, splunk, http_endpoint, opensearch and opensearchserverless.
 	Destination *string `json:"destination,omitempty" tf:"destination,omitempty"`
 
@@ -271,10 +268,6 @@ type DeliveryStreamObservation struct {
 
 type DeliveryStreamParameters struct {
 
-	// The Amazon Resource Name (ARN) specifying the Stream
-	// +kubebuilder:validation:Optional
-	Arn *string `json:"arn,omitempty" tf:"arn,omitempty"`
-
 	// –  This is the destination to where the data is delivered. The only options are s3 (Deprecated, use extended_s3 instead), extended_s3, redshift, elasticsearch, splunk, http_endpoint, opensearch and opensearchserverless.
 	// +kubebuilder:validation:Optional
 	Destination *string `json:"destination,omitempty" tf:"destination,omitempty"`
@@ -3188,7 +3181,7 @@ type RedshiftConfigurationS3BackupConfigurationInitParameters struct {
 
 	// The ARN of the S3 bucket
 	// +crossplane:generate:reference:type=github.com/upbound/provider-aws/apis/s3/v1beta1.Bucket
-	// +crossplane:generate:reference:extractor=github.com/crossplane/upjet/pkg/resource.ExtractParamPath("arn",true)
+	// +crossplane:generate:reference:extractor=github.com/upbound/provider-aws/config/common.ARNExtractor()
 	BucketArn *string `json:"bucketArn,omitempty" tf:"bucket_arn,omitempty"`
 
 	// Reference to a Bucket in s3 to populate bucketArn.
@@ -3270,7 +3263,7 @@ type RedshiftConfigurationS3BackupConfigurationParameters struct {
 
 	// The ARN of the S3 bucket
 	// +crossplane:generate:reference:type=github.com/upbound/provider-aws/apis/s3/v1beta1.Bucket
-	// +crossplane:generate:reference:extractor=github.com/crossplane/upjet/pkg/resource.ExtractParamPath("arn",true)
+	// +crossplane:generate:reference:extractor=github.com/upbound/provider-aws/config/common.ARNExtractor()
 	// +kubebuilder:validation:Optional
 	BucketArn *string `json:"bucketArn,omitempty" tf:"bucket_arn,omitempty"`
 
diff --git a/apis/firehose/v1beta1/zz_generated.deepcopy.go b/apis/firehose/v1beta1/zz_generated.deepcopy.go
index e66b0d2d54..4f029ad4ca 100644
--- a/apis/firehose/v1beta1/zz_generated.deepcopy.go
+++ b/apis/firehose/v1beta1/zz_generated.deepcopy.go
@@ -406,11 +406,6 @@ func (in *DeliveryStream) DeepCopyObject() runtime.Object {
 // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
 func (in *DeliveryStreamInitParameters) DeepCopyInto(out *DeliveryStreamInitParameters) {
 	*out = *in
-	if in.Arn != nil {
-		in, out := &in.Arn, &out.Arn
-		*out = new(string)
-		**out = **in
-	}
 	if in.Destination != nil {
 		in, out := &in.Destination, &out.Destination
 		*out = new(string)
@@ -711,11 +706,6 @@ func (in *DeliveryStreamObservation) DeepCopy() *DeliveryStreamObservation {
 // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil.
 func (in *DeliveryStreamParameters) DeepCopyInto(out *DeliveryStreamParameters) {
 	*out = *in
-	if in.Arn != nil {
-		in, out := &in.Arn, &out.Arn
-		*out = new(string)
-		**out = **in
-	}
 	if in.Destination != nil {
 		in, out := &in.Destination, &out.Destination
 		*out = new(string)
diff --git a/apis/firehose/v1beta1/zz_generated.resolvers.go b/apis/firehose/v1beta1/zz_generated.resolvers.go
index 7b9c18204b..d0d2cc2958 100644
--- a/apis/firehose/v1beta1/zz_generated.resolvers.go
+++ b/apis/firehose/v1beta1/zz_generated.resolvers.go
@@ -526,7 +526,7 @@ func (mg *DeliveryStream) ResolveReferences( // ResolveReferences of this Delive
 				}
 				rsp, err = r.Resolve(ctx, reference.ResolutionRequest{
 					CurrentValue: reference.FromPtrValue(mg.Spec.ForProvider.RedshiftConfiguration[i3].S3BackupConfiguration[i4].BucketArn),
-					Extract:      resource.ExtractParamPath("arn", true),
+					Extract:      common.ARNExtractor(),
 					Reference:    mg.Spec.ForProvider.RedshiftConfiguration[i3].S3BackupConfiguration[i4].BucketArnRef,
 					Selector:     mg.Spec.ForProvider.RedshiftConfiguration[i3].S3BackupConfiguration[i4].BucketArnSelector,
 					To:           reference.To{List: l, Managed: m},
@@ -1154,7 +1154,7 @@ func (mg *DeliveryStream) ResolveReferences( // ResolveReferences of this Delive
 				}
 				rsp, err = r.Resolve(ctx, reference.ResolutionRequest{
 					CurrentValue: reference.FromPtrValue(mg.Spec.InitProvider.RedshiftConfiguration[i3].S3BackupConfiguration[i4].BucketArn),
-					Extract:      resource.ExtractParamPath("arn", true),
+					Extract:      common.ARNExtractor(),
 					Reference:    mg.Spec.InitProvider.RedshiftConfiguration[i3].S3BackupConfiguration[i4].BucketArnRef,
 					Selector:     mg.Spec.InitProvider.RedshiftConfiguration[i3].S3BackupConfiguration[i4].BucketArnSelector,
 					To:           reference.To{List: l, Managed: m},
diff --git a/config/firehose/config.go b/config/firehose/config.go
index af1455a23e..89ff2223cb 100644
--- a/config/firehose/config.go
+++ b/config/firehose/config.go
@@ -17,28 +17,30 @@ func Configure(p *config.Provider) {
 		r.TerraformResource.Schema["splunk_configuration"].Elem.(*schema.Resource).Schema["hec_token"].Sensitive = true
 
 		r.References["extended_s3_configuration.role_arn"] = config.Reference{
-			Type:      "github.com/upbound/provider-aws/apis/iam/v1beta1.Role",
-			Extractor: common.PathARNExtractor,
+			TerraformName: "aws_iam_role",
+			Extractor:     common.PathARNExtractor,
 		}
 		r.References["extended_s3_configuration.bucket_arn"] = config.Reference{
-			Type:      "github.com/upbound/provider-aws/apis/s3/v1beta1.Bucket",
-			Extractor: common.PathARNExtractor,
+			TerraformName: "aws_s3_bucket",
+			Extractor:     common.PathARNExtractor,
 		}
 
 		r.References["s3_configuration.role_arn"] = config.Reference{
-			Type:      "github.com/upbound/provider-aws/apis/iam/v1beta1.Role",
-			Extractor: common.PathARNExtractor,
+			TerraformName: "aws_iam_role",
+			Extractor:     common.PathARNExtractor,
 		}
 		r.References["s3_configuration.bucket_arn"] = config.Reference{
-			Type:      "github.com/upbound/provider-aws/apis/s3/v1beta1.Bucket",
-			Extractor: common.PathARNExtractor,
+			TerraformName: "aws_s3_bucket",
+			Extractor:     common.PathARNExtractor,
 		}
 
 		r.References["redshift_configuration.s3_backup_configuration.bucket_arn"] = config.Reference{
-			Type:      "github.com/upbound/provider-aws/apis/s3/v1beta1.Bucket",
-			Extractor: `github.com/crossplane/upjet/pkg/resource.ExtractParamPath("arn",true)`,
+			TerraformName: "aws_s3_bucket",
+			Extractor:     common.PathARNExtractor,
 		}
 
+		config.MoveToStatus(r.TerraformResource, "arn")
+
 		r.LateInitializer = config.LateInitializer{
 			IgnoredFields: []string{
 				"server_side_encryption",
diff --git a/package/crds/firehose.aws.upbound.io_deliverystreams.yaml b/package/crds/firehose.aws.upbound.io_deliverystreams.yaml
index 6fb29e7927..376a1bfffc 100644
--- a/package/crds/firehose.aws.upbound.io_deliverystreams.yaml
+++ b/package/crds/firehose.aws.upbound.io_deliverystreams.yaml
@@ -73,9 +73,6 @@ spec:
                 type: string
               forProvider:
                 properties:
-                  arn:
-                    description: The Amazon Resource Name (ARN) specifying the Stream
-                    type: string
                   destination:
                     description: –  This is the destination to where the data is delivered.
                       The only options are s3 (Deprecated, use extended_s3 instead),
@@ -4158,9 +4155,6 @@ spec:
                   for example because of an external controller is managing them, like an
                   autoscaler.
                 properties:
-                  arn:
-                    description: The Amazon Resource Name (ARN) specifying the Stream
-                    type: string
                   destination:
                     description: –  This is the destination to where the data is delivered.
                       The only options are s3 (Deprecated, use extended_s3 instead),