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

aws-ec2: flow logs for TransitGateway & TransitGatewayAttachment #27222

Closed
2 tasks
juweeks opened this issue Sep 20, 2023 · 4 comments · Fixed by #28605
Closed
2 tasks

aws-ec2: flow logs for TransitGateway & TransitGatewayAttachment #27222

juweeks opened this issue Sep 20, 2023 · 4 comments · Fixed by #28605
Labels
@aws-cdk/aws-ec2 Related to Amazon Elastic Compute Cloud effort/small Small work item – less than a day of effort feature-request A feature should be added or improved. good first issue Related to contributions. See CONTRIBUTING.md p2

Comments

@juweeks
Copy link

juweeks commented Sep 20, 2023

Describe the feature

TransitGateway and TransitGatewayAttachment resource types are missing from FlowLogResourceType

Use Case

add flow logs to Transit Gateway resources

Proposed Solution

for FlowLogResourceType, add from_transit_gateway_id and from_transit_gateway_attachement_id methods

Other Information

No response

Acknowledgements

  • I may be able to implement this feature request
  • This feature might incur a breaking change

CDK version used

2.91

Environment details (OS name and version, etc.)

mac ventura 13.5.2

@juweeks juweeks added feature-request A feature should be added or improved. needs-triage This issue or PR still needs to be triaged. labels Sep 20, 2023
@github-actions github-actions bot added the @aws-cdk/aws-ec2 Related to Amazon Elastic Compute Cloud label Sep 20, 2023
@khushail khushail added investigating This issue is being investigated and/or work is in progress to resolve the issue. and removed needs-triage This issue or PR still needs to be triaged. labels Sep 20, 2023
@khushail
Copy link
Contributor

Hi @juweeks , thanks for reaching out. Yes, it would be helpful to have these methods in FlowlogsResourceType

@khushail khushail added p2 effort/small Small work item – less than a day of effort and removed investigating This issue is being investigated and/or work is in progress to resolve the issue. labels Sep 20, 2023
@peterwoodworth peterwoodworth added the good first issue Related to contributions. See CONTRIBUTING.md label Sep 20, 2023
@dyoshikawa
Copy link
Contributor

I'll work on it.

@dyoshikawa
Copy link
Contributor

I've implemented it. Could you review?

@mergify mergify bot closed this as completed in #28605 Jan 22, 2024
mergify bot pushed a commit that referenced this issue Jan 22, 2024
…#28605)

I have enabled the configuration of flow logs for TransitGateway and TransitGatewayAttachment. 

Create flow logs from TransitGateway:
```ts
declare const tgw: ec2.CfnTransitGateway;

new ec2.FlowLog(this, 'TransitGatewayFlowLog', {
  resourceType: ec2.FlowLogResourceType.fromTransitGatewayId(tgw.ref)
})
```

Create flowlogs from TransitGatewayAttachment:
```ts
declare const tgwAttachment: ec2.CfnTransitGatewayAttachment;

new ec2.FlowLog(this, 'TransitGatewayAttachmentFlowLog', {
  resourceType: ec2.FlowLogResourceType.fromTransitGatewayAttachmentId(tgwAttachment.ref)
})
```

Since `trafficType` [cannot be set for flow logs related to TransitGateway resources](https://docs.aws.amazon.com/vpc/latest/tgw/working-with-flow-logs.html#flow-logs-api-cli), I have also added error handling for this.

```ts
if (props.resourceType.resourceType === 'TransitGateway' || props.resourceType.resourceType === 'TransitGatewayAttachment') {
      if (props.trafficType) {
        throw new Error('trafficType is not supported for Transit Gateway and Transit Gateway Attachment');
      }
      ...
    }
```

Closes #27222.

----

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

⚠️COMMENT VISIBILITY WARNING⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
@aws-cdk/aws-ec2 Related to Amazon Elastic Compute Cloud effort/small Small work item – less than a day of effort feature-request A feature should be added or improved. good first issue Related to contributions. See CONTRIBUTING.md p2
Projects
None yet
4 participants