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): Add Transit Gateway settings to FlowLogResourceType #27262

Closed

Conversation

dyoshikawa
Copy link
Contributor

@dyoshikawa dyoshikawa commented Sep 23, 2023

Closes #27222.

AWS documents:

Other references:


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 the p2 label Sep 23, 2023
@aws-cdk-automation aws-cdk-automation requested a review from a team September 23, 2023 02:28
@github-actions github-actions bot added the beginning-contributor [Pilot] contributed between 0-2 PRs to the CDK label Sep 23, 2023
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.

@github-actions github-actions bot added effort/small Small work item – less than a day of effort p1 feature-request A feature should be added or improved. p2 and removed p2 p1 labels Sep 23, 2023
@dyoshikawa dyoshikawa changed the title feat(ec2): Add Transit Gateway settings feat(ec2): Add Transit Gateway settings to FlowLogResourceType Sep 23, 2023
@aws-cdk-automation aws-cdk-automation dismissed their stale review September 28, 2023 06:35

✅ Updated pull request passes all PRLinter validations. Dismissing previous PRLinter review.

@dyoshikawa dyoshikawa marked this pull request as ready for review September 29, 2023 05:04
@aws-cdk-automation
Copy link
Collaborator

This PR cannot be merged because it has conflicts. Please resolve them. The PR will be considered stale and closed if it remains in an unmergeable state.

@scanlonp scanlonp self-assigned this Oct 2, 2023
Copy link
Contributor

@scanlonp scanlonp left a comment

Choose a reason for hiding this comment

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

The PR looks good! It just needs a couple more steps.

  • First, there are merge conflicts, please resolve these. They look relatively simple
  • Please link documentation you referenced in the process of finding the feature gap and adding the feature. Adding it to the PR description would be appreciated as well!
  • Address the comments on the integ test

I will be ready to approve when you get back with these asks!

resourceType: FlowLogResourceType.fromTransitGatewayId(transitGateway.ref),
flowLogName: 'TransitGatewayFlowLogName',
});
}
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a reason you did not add a fromTransitGatewayAttachmentId resource type FlowLog into the test as well?

Copy link

@cm-dyoshikawa cm-dyoshikawa Oct 6, 2023

Choose a reason for hiding this comment

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

No reasons, so I worked on it!

const featureFlagTest = new FeatureFlagStack(app, 'FlowLogsFeatureFlag');

const integ = new IntegTest(app, 'FlowLogs', {
testCases: [
new TestStack(app, 'FlowLogsTestStack'),
featureFlagTest,
new DependencyTestStack(app, 'DependencyTestStack'),
new TransitGatewayFlowLogStack(app, 'TransitGatewayFlowLogStack'),
],
diffAssets: true,
});
Copy link
Contributor

Choose a reason for hiding this comment

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

Are there assertions you could add here to confirm the FlowLog is created as you intend it to be?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I tried it. But, when I ran integration tests, the following error has occurred. The error message Response object is too is ambiguous, so I cannot proceed.

FlowLogsDefaultTestDeployAssertXXXXXX | 3/5 | 4:31:08 PM |
CREATE_FAILED        | Custom::DeployAssert@SdkCallEC2describeFlowLogs
| FlowLogs/DefaultTest/DeployAssert/AwsApiCallEC2describeFlowLogsXXXXXXXXXXXXX/Default/Default
(AwsApiCallEC2describeFlowLogsXXXXXXXXXXX) Response object is too
long.

Could you help me?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, this is a common problem and not well documented. One solution is to do something along the lines of:

const describe = integ.assertions.awsApiCall(...);
describe.assertAtPath('path.key.in.object', ExpectedResult.stringLikeRegexp('string you expect'));

This will prevent the full response object coming back to cloudformation.

@aws-cdk-automation
Copy link
Collaborator

This PR cannot be merged because it has conflicts. Please resolve them. The PR will be considered stale and closed if it remains in an unmergeable state.

2 similar comments
@aws-cdk-automation
Copy link
Collaborator

This PR cannot be merged because it has conflicts. Please resolve them. The PR will be considered stale and closed if it remains in an unmergeable state.

@aws-cdk-automation
Copy link
Collaborator

This PR cannot be merged because it has conflicts. Please resolve them. The PR will be considered stale and closed if it remains in an unmergeable state.

@cm-dyoshikawa
Copy link

@scanlonp Thank you for your review. I'll check those.

'origin' into transit-gateway-flow-log-resource-type
@scanlonp scanlonp added pr/needs-maintainer-review This PR needs a review from a Core Team Member and removed pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. labels Oct 16, 2023
@aws-cdk-automation aws-cdk-automation added pr/needs-community-review This PR needs a review from a Trusted Community Member or Core Team Member. and removed pr/needs-maintainer-review This PR needs a review from a Core Team Member labels Oct 16, 2023
@cm-dyoshikawa
Copy link

@scanlonp Thank you. I worked on these again. So could you review more once?

this,
'TransitGatewayAttachment',
{
subnetIds: vpc.selectSubnets({
Copy link
Contributor

Choose a reason for hiding this comment

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

This is causing the build to fail since you have not created the vpc. Add the vpc declaration to the example:
declare const vpc: ec2.Vpc;

Choose a reason for hiding this comment

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

Thank you. I worked on it.

@scanlonp
Copy link
Contributor

There is still the task of re-writing the user contract so that resourceType and trafficType are tightly coupled.

@cm-dyoshikawa
Copy link

cm-dyoshikawa commented Nov 1, 2023

@scanlonp I'm sorry to have kept you waiting. Could you review again?

There is still the task of re-writing the user contract so that resourceType and trafficType are tightly coupled.

I worked on it.

Copy link
Contributor

@scanlonp scanlonp left a comment

Choose a reason for hiding this comment

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

Couple more small comments. We should do some validation rather than coercion.

But also, I noticed that trafficType is used in the addFlowLogs() method. Deprecating it leaves no non-deprecated option for that function.

As an end result, we should have trafficType be deprecated when used in our from...() methods, and not deprecated when used in addFlowLogs(). This is a little tricky, but a possible solution is to have an interface extend FlowLogOptions (or have FlowLogOptions extend an interface), and have trafficType be deprecated in one and not in the other. Then give each method its proper interface.

This is a little convoluted, so let me put a little more thought into it. Ideas are welcome, but I will get back to you soon!

Comment on lines +778 to +779
let trafficType: FlowLogTrafficType | undefined = undefined;
if (!['TransitGateway', 'TransitGatewayAttachment'].includes(props.resourceType.resourceType)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

We should not need this now, right? Should be a validation rather than a coercion.

Choose a reason for hiding this comment

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

As to the code, because I had intended behavior that already exists will not changed.

OK, I will change as you say. But I don't know how should I write well so I asked you.

Comment on lines +780 to +781
trafficType = props.trafficType ?? props.resourceType.trafficType ?? FlowLogTrafficType.ALL;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

We should validate that both are not set.

Choose a reason for hiding this comment

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

Ok, but how should it failure? In that case, it should occur throw new Error() ?

@@ -616,6 +644,7 @@ export interface FlowLogOptions {
* The type of traffic to log. You can log traffic that the resource accepts or rejects, or all traffic.
*
* @default ALL
* @deprecated Use `resourceType.trafficType` instead
Copy link
Contributor

Choose a reason for hiding this comment

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

This is used in the addFlowLogs method, which means we would be deprecating traffic type with no alternative there. Probably cannot deprecate this as-is. I overlooked this before.

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe instead of deprecating, we can give a warning if it is set here.

Choose a reason for hiding this comment

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

I see. In that case, can I use this.warn such like the code that already exists?

@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 Nov 7, 2023
Copy link
Contributor

@scanlonp scanlonp left a comment

Choose a reason for hiding this comment

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

Ok, some new thoughts. Instead of deprecating, we give a warning if used in the from... context. This will have similar behavior to the deprecation, but leave it open for the add.. functions.

We can still error if the prop is provided twice.

@@ -616,6 +644,7 @@ export interface FlowLogOptions {
* The type of traffic to log. You can log traffic that the resource accepts or rejects, or all traffic.
*
* @default ALL
* @deprecated Use `resourceType.trafficType` instead
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe instead of deprecating, we can give a warning if it is set here.

@mergify mergify bot dismissed scanlonp’s stale review November 22, 2023 07:48

Pull request has been modified.

@cm-dyoshikawa
Copy link

cm-dyoshikawa commented Nov 22, 2023

@scanlonp
Thank you so much for your comments. I replied those. I'm considering about your instructions.

Also, I'm sorry for so late reaction. I've been busy these days.

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

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

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

@aws-cdk-automation
Copy link
Collaborator

This PR has been in the BUILD FAILING state for 3 weeks, and looks abandoned. To keep this PR from being closed, please continue work on it. If not, it will automatically be closed in a week.

@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 Dec 22, 2023
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 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.

aws-ec2: flow logs for TransitGateway & TransitGatewayAttachment
4 participants