Skip to content

Conversation

@aditya-shrey
Copy link

@aditya-shrey aditya-shrey commented Mar 15, 2025

Issue

Closes #16335.

Reason for this change

Currently, FirewallRuleGroup allows importing an existing rule group by ID using fromFirewallRuleGroupID(), but there is no built-in way to reference an existing rule group by name. Users need to implement their own lookup logic via the AWS SDK. This change provides a direct method to import a firewall rule group by name, simplifying the process.

Description of changes

  • Added FirewallRuleGroup.fromFirewallRuleGroupName(), which allows users to import a firewall rule group using its name instead of just an ID.
  • The method retrieves the rule group ID from the CDK context.
  • If the provided firewall rule group name is not found in the context, it throws a meaningful error.
  • Created unit tests, ensuring correct ID is returned when a valid name mapping is provided in the context and an error is thrown if firewall rule group name is not found in the context.

Describe any new or updated permissions being added

None

Description of how you validated changes

  • Unit Tests: Added tests in firewall-rule-group.test.ts to validate both successful and failing cases.
  • Integration Tests: Updated integration.firewall.js to reflect changes and updated snapshots.

Checklist

Acknowledgements

Thanks to @arvchahal for collaboration on this feature!


By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license

@github-actions github-actions bot added effort/small Small work item – less than a day of effort feature-request A feature should be added or improved. p2 labels Mar 15, 2025
@aws-cdk-automation aws-cdk-automation requested a review from a team March 15, 2025 08:37
@github-actions github-actions bot added the beginning-contributor [Pilot] contributed between 0-2 PRs to the CDK label Mar 15, 2025
@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

  • CodeBuild project: AutoBuildv2Project1C6BFA3F-wQm2hXv2jqQv
  • Commit ID: 2eacc2e
  • Result: SUCCEEDED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@aws-cdk-automation aws-cdk-automation added the pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. label Mar 15, 2025
@Leo10Gama Leo10Gama self-assigned this May 22, 2025
Copy link
Member

@Leo10Gama Leo10Gama left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your contribution and patience! This seems like a great addition to help this alpha module come together. I've left a few outstanding comments of things we should tweak to improve this PR. Happy to approve of these changes once they're addressed!

const firewallRuleGroupId = firewallRuleGroups[firewallRuleGroupName];

if (!firewallRuleGroupId) {
throw new Error(`Firewall Rule Group with name "${firewallRuleGroupName}" not found in context.`);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we make this a ValidationError instead?

Comment on lines +11 to +13
this.node.setContext('firewallRuleGroups', {
TestRuleGroup: 'fwr-12345678',
});
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure I agree with this structure for the integration tests. We typically want these tests to reflect the way people would use the CDK in the wild, so it would probably be better to have the construct declared independently, and then imported using the new method from another stack.

Looking through the repository, it seems like this integ test is checking similar functionality in a cleaner structure. Could we replace this with a similar structure?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's add an assertion to this integ test as well, for good measure. This integ test is a pretty good example of how we might go about doing this, using AWS API to check the values that are deployed when the test is run.

@aws-cdk-automation aws-cdk-automation removed the pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. label May 22, 2025
@Leo10Gama Leo10Gama removed their assignment Jun 11, 2025
@aws-cdk-automation
Copy link
Collaborator

This PR has been in the CHANGES REQUESTED state for 3 weeks, and looks abandoned. Note that PRs with failing linting check or builds are not reviewed, please ensure your build is passing

To prevent automatic closure:

  • Resume work on the PR
  • OR request an exemption by adding a comment containing 'Exemption Request' with justification e.x "Exemption Request: "
  • OR request clarification by adding a comment containing 'Clarification Request' with a question e.x "Clarification Request: "

This PR will automatically close in 14 days if no action is taken.

@aws-cdk-automation
Copy link
Collaborator

This PR has been deemed to be abandoned, and will be automatically closed. Please create a new PR for these changes if you think this decision has been made in error.

@aws-cdk-automation aws-cdk-automation added the closed-for-staleness This issue was automatically closed because it hadn't received any attention in a while. label Jun 27, 2025
@github-actions
Copy link
Contributor

Comments on closed issues and PRs are hard for our team to see.
If you need help, please open a new issue that references this one.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 27, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

beginning-contributor [Pilot] contributed between 0-2 PRs to the CDK closed-for-staleness This issue was automatically closed because it hadn't received any attention in a while. effort/small Small work item – less than a day of effort feature-request A feature should be added or improved. p2

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add FirewallRuleGroup lookup by name

3 participants