pulumi-awsx: Auto-creating security group ingress can be problematic
If I specify a SecurityGroup explicitly for an ALB which already has all the ingress rules specified, the load balancer code then tries to create the same rules, and we get an error.
For example:
import * as awsx from "@pulumi/awsx";
// Create a security group to let traffic flow.
const sg = new awsx.ec2.SecurityGroup("web-sg", {
vpc: awsx.ec2.Vpc.getDefault(),
ingress: [{ protocol: "tcp", fromPort: 80, toPort: 80, cidrBlocks: [ "0.0.0.0/0" ] }],
egress: [{ protocol: "-1", fromPort: 0, toPort: 0, cidrBlocks: [ "0.0.0.0/0" ] }],
});
// Create an ALB associated with the default VPC for this region and listen on port 80.
const nlb = new awsx.elasticloadbalancingv2.ApplicationLoadBalancer("web-traffic",
{ external: true, securityGroups: [ sg ] });
const listener = nlb.createListener("web-listener", { port: 80 });
This yields an error:
error: Plan apply failed: [WARN] A duplicate Security Group rule was found on (sg-0616e60b838abac3a). This may be
a side effect of a now-fixed Terraform issue causing two security groups with
identical attributes but different source_security_group_ids to overwrite each
other in the state. See https://github.com/hashicorp/terraform/pull/2376 for more
information and instructions for recovery. Error message: the specified rule "peer: 0.0.0.0/0, TCP, from port: 80, to port: 80, ALLOW" already exists
I know how to fix this (just remove the explicit ingress rule), but it’s a little unfortunate. For my example, I need to specify the egress otherwise the EC2 instance target fails health checks.
This could just be a wart we need to live with, but I figured I would file an issue so we can have the discussion and searcahability for the problem in case it bites someone else down the road.
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 12
- Comments: 28 (7 by maintainers)
+1 this issue needs to be addressed
@CyrusNajmabadi I just hit this again. I had a security group with ingress open to port 80 already, and then tried to add a load balancer to my program:
The act of creating the listener attempted to create a new security group, which conflicted with my existing security group, leading to the following error:
Should we provide an option for the
createListener
to not create a security group? (For what it’s worth, I’d have assumed that would be the default…)Our solution to this issue was to not use awsx for the listeners and just use the aws package. We then were able to specify the security groups without the listener creating its own ingress rules
I’ve run into this today, and it’s not the first time. I’m going the path of un
awsx
ing all our resource declarations. It’s simply not worth the pain of going through abstractions that make some use cases so painful.Just in case anyone comes looking for a workaround, we ended up commenting out these lines:
https://github.com/pulumi/pulumi-awsx/blob/master/nodejs/awsx/lb/application.ts#L244-L248
directly on the
@pulumi/awsx
installed onnode_modules
, less than ideal solution, but works for now while the Pulumi team gets around to fixing this.This issue is seriously causing problems for my company adopting Pulumi, and it is disheartening seeing this being a problem for over a year with not even a workaround proposed.
The same issue right now, it painful enough…
I really waiting for this. This issue prevent two Load Balancers sharing one SecurityGroup.
There seems to be a deeper issue here, we tried just setting the SecurityGroup for the LoadBalancer (something we have done successfully before) and have two FargateService instances share the LoadBalancer and it failed with the exact same error.
It absolutely is! Thanks much!
just hit the issue today, so keeping it alive guys, still need to be addressed !