Open rpmccarter opened 3 months ago
Thanks for reaching out @rpmccarter!
You are indeed correct that this is caused by the defaultTargetGroup
that's created here: https://github.com/pulumi/pulumi-awsx/blob/master/awsx/lb/applicationLoadBalancer.ts#L136-L145
The ApplicationLoadBalancer
component always creates a target group, which ends up failing in your case because it cannot infer port or protocol for the targets; because there's no targets.
What you can do as a workaround is defining the port & protocol for the defaultTargetGroup
like so:
new awsx.lb.ApplicationLoadBalancer("alb", {
defaultTargetGroup: {
port: 443,
protocol: "HTTP",
},
listeners: [
{
port: 443,
protocol: 'HTTP',
defaultActions: [{
type: "fixed-response",
fixedResponse: {
contentType: "text/plain",
messageBody: "Hello world",
statusCode: "200",
},
}],
}
]
});
Additionally I checked if this is a regression compared to v2.8.0. Previously you could run pulumi preview
and it wouldn't report any error, but if you tried running pulumi up
it failed. You cannot create a target group of type ip
without a port. So it's not a regression, the issue is rather caught during preview time instead.
This AWS CLI command shows that behavior:
aws elbv2 create-target-group \
--name my-targets \
--protocol HTTP \
--target-type ip \
--vpc-id vpc-3ac0fb5f --region us-west-2 --profile pulumi-dev-sandbox
An error occurred (ValidationError) when calling the CreateTargetGroup operation: A port must be specified
What changed from v2.8.0 to v2.9.0 is that this is now caught during preview instead of only during the apply.
We could add an optional flag to prevent creating the defaultTargetGroup
, but that output is required right now. So this would be a breaking change: https://github.com/pulumi/pulumi-awsx/blob/master/awsx/schema-types.ts#L276
What happened?
When attempting to modify a load balancer, the load balancer started complaining that
Attribute "port" must be specified
, even though it already is.Example
I created a github repo with the repro code: https://github.com/rpmccarter/pulumi-awsx-lb-port-bug-repro
Output of
pulumi about
Additional context
This bug was introduced in v2.9.0 with the bump of the
@pulumi/aws
package - unsure if this is a bug with this package or@pulumi/aws
Edit: After some debugging, I sense that the error is not complaining about my target group, but about the default target group. Supplying
defaultTargetGroupPort
does not fix the issue, but supplyingdefaultTargetGroup
does. I believe these lines are the root of the issue.Contributing
Vote on this issue by adding a 👍 reaction. To contribute a fix for this issue, leave a comment (and link to your pull request, if you've opened one already).