crossplane-contrib / provider-upjet-aws

Official AWS Provider for Crossplane by Upbound.
https://marketplace.upbound.io/providers/upbound/provider-aws
Apache License 2.0
137 stars 112 forks source link

[Bug]: Firehose provider pod crashing with panic runtime error when missing required configuration, instead of sending an error message #1354

Open talron23 opened 3 weeks ago

talron23 commented 3 weeks ago

Is there an existing issue for this?

Affected Resource(s)

firehose.aws.upbound.io/v1beta1

Resource MRs required to reproduce the bug

Firehose delivery stream YAML:

apiVersion: firehose.aws.upbound.io/v1beta1 kind: DeliveryStream metadata: labels: crossplane-name: kinesis-firehose name: maas-ap-south-1-kinesis-firehose spec: deletionPolicy: Delete forProvider: destination: opensearch name: ap-south-1-maas-sh-kinesis-firehose-es opensearchConfiguration:

Steps to Reproduce

  1. Set provider-aws-firehose to v1.6.0 or any version after v0.47.4. (tested also v1.4.0 and v1.0.0)
  2. Run the firehose mentioned YAML.
  3. Provider pod crashes.

What happened?

When using provider-aws-firehose:v1.6.0, with the mentioned YAML which is missing S3 configuration, the provider pod crashes with the following error: panic: runtime error: index out of range [0] with length 0

I would expect the pod not to crash and deliver an error message as I get with v0.47.4: 'async create failed: failed to create the resource: [{0 creating Kinesis Firehose Delivery Stream (ap-south-1-maas-sh-kinesis-firehose-es): When destination is opensearch, s3_configuration is required []}]'

Relevant Error Output Snippet

warning: Command-line flag "provider-ttl" is deprecated and no longer used. It will be removed in a future release. Please remove it from all of your configurations (ControllerConfigs, etc.).
{"level":"info","ts":"2024-06-10T20:47:41Z","logger":"provider-aws","msg":"Beta feature enabled","flag":"EnableBetaManagementPolicies"}
**panic: runtime error: index out of range [0] with length 0**

goroutine 4090 [running]:
github.com/hashicorp/terraform-provider-aws/internal/service/firehose.expandS3DestinationConfiguration({0x1da43040?, 0xc004e49710?, 0x1227207a?})
        github.com/hashicorp/terraform-provider-aws@v0.0.0-00010101000000-000000000000/internal/service/firehose/delivery_stream.go:1524 +0x69e
github.com/hashicorp/terraform-provider-aws/internal/service/firehose.expandAmazonopensearchserviceDestinationConfiguration(0x147425f8?)
        github.com/hashicorp/terraform-provider-aws@v0.0.0-00010101000000-000000000000/internal/service/firehose/delivery_stream.go:2165 +0x34c
github.com/hashicorp/terraform-provider-aws/internal/service/firehose.resourceDeliveryStreamCreate({0x147425f8?, 0xc004e493e0}, 0x1?, {0x121b7ea0?, 0xc0025e6690})
        github.com/hashicorp/terraform-provider-aws@v0.0.0-00010101000000-000000000000/internal/service/firehose/delivery_stream.go:1222 +0x794
github.com/hashicorp/terraform-provider-aws/internal/provider.New.(*wrappedResource).Create.interceptedHandler[...].func8(0x7fa3ea145ca0?, {0x121b7ea0?, 0xc0025e6690?})
        github.com/hashicorp/terraform-provider-aws@v0.0.0-00010101000000-000000000000/internal/provider/intercept.go:111 +0x283
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).create(0x147426a0?, {0x147426a0?, 0xc00672b0a0?}, 0xd?, {0x121b7ea0?, 0xc0025e6690?})
        github.com/hashicorp/terraform-plugin-sdk/v2@v2.30.0/helper/schema/resource.go:773 +0x7a
github.com/hashicorp/terraform-plugin-sdk/v2/helper/schema.(*Resource).Apply(0xc0017695e0, {0x147426a0, 0xc00672b0a0}, 0x0, 0xc004821c80, {0x121b7ea0, 0xc0025e6690})
        github.com/hashicorp/terraform-plugin-sdk/v2@v2.30.0/helper/schema/resource.go:909 +0xa89
github.com/crossplane/upjet/pkg/controller.(*terraformPluginSDKExternal).Create(0xc005fb4e00, {0x147426a0, 0xc00672b0a0}, {0x147bfbe0?, 0xc003928000})
        github.com/crossplane/upjet@v1.2.0/pkg/controller/external_tfpluginsdk.go:589 +0xe7
github.com/crossplane/upjet/pkg/controller.(*terraformPluginSDKAsyncExternal).Create.func1()
        github.com/crossplane/upjet@v1.2.0/pkg/controller/external_async_tfpluginsdk.go:146 +0x145
created by github.com/crossplane/upjet/pkg/controller.(*terraformPluginSDKAsyncExternal).Create in goroutine 3592
        github.com/crossplane/upjet@v1.2.0/pkg/controller/external_async_tfpluginsdk.go:142 +0x168

Crossplane Version

v1.15.0

Provider Version

v1.6.0

Kubernetes Version

v1.29

Kubernetes Distribution

EKS

Additional Info

No response