Jimmy
10/03/2025, 3:47 PM│ Error: failure to invoke API
│
│ with airbyte_destination_s3.s3_mysql,
│ on main.tf line 54, in resource "airbyte_destination_s3" "s3_mysql":
│ 54: resource "airbyte_destination_s3" "s3_mysql" {
│
│ error serializing request body: json: error calling MarshalJSON for type shared.DestinationS3: json: error calling
│ MarshalJSON for type shared.DestinationS3OutputFormat: could not marshal union type DestinationS3OutputFormat: all
│ fields are null
Here is my code:
# S3 MySQL Destination
resource "airbyte_destination_s3" "s3_mysql" {
name = "S3-mysql"
workspace_id = var.workspace_id
definition_id = "4816b78f-1489-44c1-9060-4b19d5fa9362"
configuration = {
s3_bucket_name = var.s3_bucket_name
s3_bucket_path = var.s3_bucket_path
s3_bucket_region = var.s3_region
access_key_id = var.access_key_id
secret_access_key = var.secret_access_key
# Proper union type usage for Parquet
format = {
parquet_parquet = {
format_type = "Parquet"
page_size_kb = 1024
block_size_mb = 128
compression_codec = "GZIP"
max_padding_size_mb = 8
dictionary_page_size_kb = 1024
}
}
s3_path_format = "raw/mysql/$${NAMESPACE}/$${STREAM_NAME}/load_date=$${YEAR}_$${MONTH}_$${DAY}/$${YEAR}_$${MONTH}_$${DAY}_$${EPOCH}_"
file_name_pattern = "{part_number}"
}
}kapa.ai
10/03/2025, 3:48 PMerror serializing request body: json: error calling MarshalJSON for type shared.DestinationS3: json: error calling MarshalJSON for type shared.DestinationS3OutputFormat: could not marshal union type DestinationS3OutputFormat: all fields are null indicates that the format field in your Terraform configuration is not being set correctly. Specifically, Airbyte expects a union type for the output format, and if all fields are null or not set properly, it cannot determine which format to use. ### What’s likely wrong In your configuration, you have: hcl format = { parquet_parquet = { format_type = "Parquet" page_size_kb = 1024 block_size_mb = 128 compression_codec = "GZIP" max_padding_size_mb = 8 dictionary_page_size_kb = 1024 } } However, based on the Airbyte S3 destination documentation, the output format should be specified as a top-level object with a format_type key, and the additional configuration should be nested under the correct key for the format. The exact structure required by the Terraform provider may differ, but the error suggests that the union type is not being set as expected. Unfortunately, the knowledge sources do not provide a direct example of the correct Terraform syntax for the format field. They do, however, confirm that the S3 destination expects a union type for the output format, and that all required fields must be set for the chosen format. If none are set, you get the "all fields are null" error you’re seeing. ### What you should do - Double-check the expected structure for the format field in the Airbyte Terraform provider documentation (not included in the knowledge sources). - Make sure you are using the correct key for the format. For example, it might be parquet instead of parquet_parquet, or the structure might be different. ### Example from Airbyte docs (not Terraform, but for reference) The Airbyte UI expects something like: json "format": { "format_type": "Parquet", "compression_codec": "GZIP", "block_size_mb": 128, "page_size_kb": 1024, "max_padding_size_mb": 8, "dictionary_page_size_kb": 1024 } ([S3 Parquet Output Format](https://docs.airbyte.com/integrations/destinations/s3#parquet)) ### Recommendation - Try changing your format block to match the expected structure, for example: hcl format = { format_type = "Parquet" compression_codec = "GZIP" block_size_mb = 128 page_size_kb = 1024 max_padding_size_mb = 8 dictionary_page_size_kb = 1024 } If this does not work, consult the [Airbyte S3 destination documentation](https://docs.airbyte.com/integrations/destinations/s3#parquet) and the Terraform provider documentation for the exact expected structure. Summary: The error is due to the format field not being set in the way Airbyte expects for union types. The knowledge sources confirm the need for a properly structured union type, but do not provide the exact Terraform syntax. Please refer to the Terraform provider documentation for the correct structure and ensure all required fields for your chosen format are set. [Reference: S3 Parquet Output Format](https://docs.airbyte.com/integrations/destinations/s3#parquet)