Skip to content

Commit

Permalink
feat(ec2): flow logs from TransitGateway and TransitGatewayAttachment (
Browse files Browse the repository at this point in the history
…#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*
  • Loading branch information
badmintoncryer authored Jan 22, 2024
1 parent b226a8c commit a238590
Show file tree
Hide file tree
Showing 14 changed files with 2,717 additions and 5 deletions.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit a238590

Please sign in to comment.