Skip to content
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

feat(ec2): security group lookup via filters #30625

Open
wants to merge 15 commits into
base: main
Choose a base branch
from

Conversation

jdukewich
Copy link

@jdukewich jdukewich commented Jun 22, 2024

Issue # (if applicable)

Closes #30331.

Reason for this change

This will improve the security group lookup functionality for importing existing security groups into a CDK stack.

Description of changes

I added the ability to lookup existing security groups via more filters. Filters are supported by the DescribeSecurityGroups API, and using these filters can be immensely useful for looking up existing security groups, especially if your account or organization follows predictable rules regarding things like security group tags.

Description of how you validated changes

I added unit tests similar to the ones that test the normal lookup by ID or name.

Checklist


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 p2 beginning-contributor [Pilot] contributed between 0-2 PRs to the CDK labels Jun 22, 2024
@aws-cdk-automation aws-cdk-automation requested a review from a team June 22, 2024 18:18
Copy link
Collaborator

@aws-cdk-automation aws-cdk-automation left a comment

Choose a reason for hiding this comment

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

The pull request linter has failed. See the aws-cdk-automation comment below for failure reasons. If you believe this pull request should receive an exemption, please comment and provide a justification.

A comment requesting an exemption should contain the text Exemption Request. Additionally, if clarification is needed add Clarification Request to a comment.

@aws-cdk-automation aws-cdk-automation added the pr/needs-cli-test-run This PR needs CLI tests run against it. label Jun 22, 2024
@jdukewich jdukewich changed the title feat(ec2): Security Group Lookup via Additional Filters feat(ec2): security group lookup via filters Jun 22, 2024
@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. labels Jun 23, 2024
@jdukewich
Copy link
Author

Clarification Request

Does this feature need a new integration test? If so, I'm struggling to figure out how to write one for a lookup like this.

@aws-cdk-automation aws-cdk-automation added the pr/reviewer-clarification-requested The contributor has requested clarification on feedback, a failing build, or a failing PR Linter run label Jun 23, 2024
@jdukewich
Copy link
Author

Exemption Request

@aws-cdk-automation aws-cdk-automation added the pr-linter/exemption-requested The contributor has requested an exemption to the PR Linter feedback. label Jun 29, 2024
@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 Jul 1, 2024

// THEN
expect(securityGroup.securityGroupId).toEqual('sg-12345678');
expect(securityGroup.allowAllOutbound).toEqual(true);
Copy link
Contributor

Choose a reason for hiding this comment

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

what happens if this matches more than one security group ?

Copy link
Author

Choose a reason for hiding this comment

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

An error gets thrown in aws-cdk/lib/context-providers/security-group.ts for that case (and a test already exists for that case)

@TheRealAmazonKendra
Copy link
Contributor

Hi there, I happened to be looking at this while you merged from main. In general, to do so please use the mergify command instead of using the button. @Mergifyio update

@jdukewich
Copy link
Author

Hi there, I happened to be looking at this while you merged from main. In general, to do so please use the mergify command instead of using the button. @Mergifyio update

@TheRealAmazonKendra Will do. Out of curiosity, why is that preferred?

@jdukewich
Copy link
Author

@Mergifyio update

Copy link
Contributor

mergify bot commented Jul 8, 2024

update

✅ Branch has been successfully updated

@aws-cdk-automation
Copy link
Collaborator

The pull request linter fails with the following errors:

❌ CLI code has changed. A maintainer must run the code through the testing pipeline (git fetch origin pull/30625/head && git push -f origin FETCH_HEAD:test-main-pipeline), then add the 'pr-linter/cli-integ-tested' label when the pipeline succeeds.

PRs must pass status checks before we can provide a meaningful review.

If you would like to request an exemption from the status checks or clarification on feedback, please leave a comment on this PR containing Exemption Request and/or Clarification Request.

✅ A exemption request has been requested. Please wait for a maintainer's review.

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

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

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
beginning-contributor [Pilot] contributed between 0-2 PRs to the CDK effort/small Small work item – less than a day of effort feature-request A feature should be added or improved. p2 pr/needs-cli-test-run This PR needs CLI tests run against it. pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. pr/reviewer-clarification-requested The contributor has requested clarification on feedback, a failing build, or a failing PR Linter run pr-linter/exemption-requested The contributor has requested an exemption to the PR Linter feedback.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

EC2: Security Groups lookup by Owner
4 participants