Hello, I'm trying to define a cloudwatch alarm and...
# typescript
g
Hello, I'm trying to define a cloudwatch alarm and I'm getting TS error
Copy code
TS2322: Type 'Output<string | undefined>' is not assignable to type 'Input<string>'
Because
dimmensions
is defined as
Copy code
/**
     * The dimensions for this metric.  For the list of available dimensions see the AWS documentation [here](<http://docs.aws.amazon.com/AmazonCloudWatch/latest/DeveloperGuide/CW_Support_For_AWS.html>).
     */
    dimensions?: pulumi.Input<{
        [key: string]: pulumi.Input<string>;
    }>;
Therefore I cannot use like this:
Copy code
new aws.cloudwatch.MetricAlarm(
      this.rcName('CpuHigh'),
      {
       ...
        dimensions: {
          ClusterName: this.cluster.clusterName!,
          ServiceName: this.service.name
        }

      }
    )
I noticed a similar issue here: https://github.com/pulumi/pulumi-aws/pull/414 Is there any workaround for that?
b
What happens if you remove the
!
from the end of
clusterName
?
g
nothing
I found a workaround using
interpolate
but it's not great IMO
w
I believe what you are running into here is the same issue tracked in https://github.com/pulumi/pulumi/issues/6175. Note that this actually works fine in Node.js, just the TypeScript types don't allow it - so you can just cast to
any
and it will work. But there is also an improvement at the TypeScript layer being pursued in https://github.com/pulumi/pulumi/pull/6323 which would make this work without any need for workarounds.
🙌 1