-
Notifications
You must be signed in to change notification settings - Fork 104
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Deleting or modifying the existing Network ACL Rule #1212
Comments
Hey @VenkatH. It sounds like:
If I understand the problem correctly, then I think you should only declare one resource in your Pulumi program. From the example you gave: import pulumi
import pulumi_aws as aws
# Replace these variables with appropriate values.
acl_id = "acl-abcdefgh" # The ID of the Network ACL
rule_number = 100 # The number of the rule you want to replace
# This is the only NetworkAclRule that you need to declare
existing_rule = aws.ec2.NetworkAclRule("existing-rule",
network_acl_id=acl_id,
rule_number=rule_number,
egress=False,
opts=pulumi.ResourceOptions(delete_before_replace=True, replace_on_changes=["*"]))
Let me know if that helps. |
Thanks for the reply @iwahbe I intend to delete the existing rule and add a new rule, and the snippet below doesn’t achieve it. # Getting the existing network acls id
vpc_network_acl = aws.ec2.get_network_acls(
vpc_id=mws_customer_vpc.vpc_id,
).ids[0]
# Trying to delete the existing egress rule
delete_rule = aws.ec2.NetworkAclRule(
resource_name=pulumi_resource_name,
opts=ResourceOptions(delete_before_replace=True, replace_on_changes=["*"]),
network_acl_id=network_acl_id,
cidr_block="0.0.0.0/0",
egress=True,
protocol="all",
rule_action="allow",
rule_number=100,
)
aws.ec2.NetworkAclRule(
resource_name=pulumi_resource_name,
opts=ResourceOptions(depends_on=[vpc]),
network_acl_id=network_acl_id,
cidr_block="0.0.0.0/0",
egress=True,
from_port=XXX,
to_port=XXX,
protocol="all",
rule_action="allow",
rule_number=99,
) So, I tried to delete the rule alone. I initially tried to avoid passing CIDR and rule_action values, but it’s very strange that it forces us to provide those values even though they are declared by default None in the # Getting the existing network acls id
vpc_network_acl = aws.ec2.get_network_acls(
vpc_id=mws_customer_vpc.vpc_id,
).ids[0]
# Trying to delete the existing egress rule
delete_rule = aws.ec2.NetworkAclRule(
resource_name=pulumi_resource_name,
opts=ResourceOptions(delete_before_replace=True, replace_on_changes=["*"]),
network_acl_id=network_acl_id,
cidr_block="0.0.0.0/0",
egress=True,
protocol="all",
rule_action="allow",
rule_number=100,
)
|
I'm not 100% sure if I understand what your trying to do now, so let me know if what I'm saying doesn't make sense or isn't applicable: Pulumi is declarative. If you just want to delete a rule, you only need to remove the rule declaration from your python code and run If you declare two rules, pulumi will ensure that both of them exist (creating them if they don't). Does that help? |
My bad; I should have been clear in my initial message. I created VPC using awsx, which makes network ACL part of it with default egress and ingress rule allowing all traffic for 0.0.0.0/0. As my deployment doesn’t require all traffic egress rules, I have to remove the default egress rule set as part of VPC creation and add the necessary egress rules for the deployment. @iwahbe, please let me know if it makes sense; if not, I can provide more details. Again thanks for your help. |
Sorry for being slow to reply. This issue fell through the cracks of my GH mailbox. You are trying to move a resource outside of a awsx component? but then you end up creating the ACL twice in your code, which errors with I'm going to move this issue to AWSx, since they might be more familiar with the problem. |
Hi @VenkatH IIUC it sounds like you need to modify the VPC created by awsx to replace the egress rules? You should be able to accomplish that by using transformations | Resource Options | Pulumi Docs on the VPC to modify the egress rule it creates. |
What happened?
I have tried to modify the existing rule of Network ACL. I tried a few options but had no luck. Referred to a code snippet and got
NetworkAclEntryAlreadyExists
errorExample
Output of
pulumi about
Version v3.100.0
Additional context
No response
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).
The text was updated successfully, but these errors were encountered: