pulumi / pulumi-terraform-bridge

A library allowing Terraform providers to be bridged into Pulumi.
Apache License 2.0
192 stars 45 forks source link

Propagate Terraform runtime warnings #1819

Open mikhailshilkov opened 5 months ago

mikhailshilkov commented 5 months ago

Hello!

Issue details

The following TF program

terraform {
 required_providers {
   aws = {
     source  = "hashicorp/aws"
     version = "= 5.27.0"
   }
 }
}

resource "aws_lb_target_group" "praefect_target_group" {
    vpc_id="vpc-4b82e033"
    name_prefix="test-"
    port=1234
    protocol="TCP"
    protocol_version="GRPC"
    health_check {
        enabled=true
        matcher="200"
        path="/"
        port=80
        protocol="HTTP"
    }
    target_type="instance"
}

emits a runtime warning during terraform apply:

 Warning: Invalid Attribute Combination
β”‚ 
β”‚   with aws_lb_target_group.praefect_target_group,
β”‚   on main.tf line 15, in resource "aws_lb_target_group" "praefect_target_group":
β”‚   15:     protocol_version="GRPC"
β”‚ 
β”‚ Attribute "protocol_version" cannot be specified when "protocol" is "TCP".
β”‚ 
β”‚ This will be an error in a future version.

A similar Pulumi program does not:

import pulumi_aws as aws

default_vpc = aws.ec2.DefaultVpc(
    "default",
    tags={
        "Name": "Default VPC",
    },
)

praefect_target_group = aws.lb.TargetGroup(
    "test",
    name_prefix="test-",
    port=1234,
    protocol="HTTP",
    protocol_version="GRPC",
    health_check=aws.lb.TargetGroupHealthCheckArgs(
        enabled=True,
        matcher="200",
        path="/",
        port=80,
        protocol="HTTP",
    ),
    target_type="instance",
    vpc_id=default_vpc.id,
)

Instead, it fails with a server error. A swallowed warning makes it harder to debug.

Affected area/feature

VenelinMartinov commented 5 months ago

We recently had a discussion on the TF behaviour around warnings related to https://github.com/pulumi/pulumi-terraform-bridge/issues/1632 and I thought they don't emit warnings.

Looks like that's not always true, thanks for the repro!