Skip to content

Conversation

@Tietew
Copy link
Contributor

@Tietew Tietew commented May 31, 2025

Reopen #33883
The cyclic dependency issue #34592 should be resolved before merging this PR again.

Issue # (if applicable)

Related to #33757.

Reason for this change

FlowLogDestination.toKinesisDataFirehoseDestination() includes the former service name Kinesis and receives the string ARN.

Also, cross-account log delivery needs an IAM role. https://docs.aws.amazon.com/vpc/latest/userguide/firehose-cross-account-delivery.html

Description of changes

  • Added FlowLogDestination.toFirehose() with an optional IAM role.
  • Deprecate toKinesisDataFirehoseDestination()

Note: CDK cannot create the IAM role for cross-account delivery because the VPC ARN is needed but FlowLog construct doesn't know it.

Describe any new or updated permissions being added

N/A - Users must specify IAM roles for cross account delivery.

Description of how you validated changes

Unit tests and integ test.

Checklist


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

…aws#33883)

### Issue # (if applicable)

Related to aws#33757.

### Reason for this change

`FlowLogDestination.toKinesisDataFirehoseDestination()` includes the former service name Kinesis and receives the string ARN.

Also, cross-account log delivery needs an IAM role.
https://docs.aws.amazon.com/vpc/latest/userguide/firehose-cross-account-delivery.html

### Description of changes

- Added `FlowLogDestination.toFirehose()` with an optional IAM role.
- Deprecate `toKinesisDataFirehoseDestination()`

Note: CDK cannot create the IAM role for cross-account delivery because the VPC ARN is needed but FlowLog construct doesn't know it.

### Describe any new or updated permissions being added

N/A - Users must specify IAM roles for cross account delivery.

### Description of how you validated changes

Unit tests and integ test.

### Checklist
- [x] My code adheres to the [CONTRIBUTING GUIDE](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md) and [DESIGN GUIDELINES](https://github.com/aws/aws-cdk/blob/main/docs/DESIGN_GUIDELINES.md)

----

*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 May 31, 2025
@aws-cdk-automation aws-cdk-automation requested a review from a team May 31, 2025 12:14
@github-actions github-actions bot added the distinguished-contributor [Pilot] contributed 50+ PRs to the CDK label May 31, 2025
@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 May 31, 2025
@Tietew
Copy link
Contributor Author

Tietew commented Jun 2, 2025

Clarification Request

Importing ec2.Connections, ec2.IConnectable, and ec2.Peer directly instead of aws-ec2/index.ts should resolve cyclic dependency, I think.
See the dependency diagram below.

But I'm unsure how jsii works on dependency between each submodule in aws-cdk-lib.
Is this a correct solution?

--- a/packages/aws-cdk-lib/aws-kinesisfirehose/lib/delivery-stream.ts
+++ b/packages/aws-cdk-lib/aws-kinesisfirehose/lib/delivery-stream.ts
@@ -5,7 +5,8 @@ import { FirehoseMetrics } from './kinesisfirehose-canned-metrics.generated';
 import { CfnDeliveryStream } from './kinesisfirehose.generated';
 import { ISource } from './source';
 import * as cloudwatch from '../../aws-cloudwatch';
-import * as ec2 from '../../aws-ec2';
+import { Connections, IConnectable } from '../../aws-ec2/lib/connections';
+import { Peer } from '../../aws-ec2/lib/peer';
 import * as iam from '../../aws-iam';
 import * as kms from '../../aws-kms';
 import * as cdk from '../../core';

Before

graph TD;
  A1(aws-ec2)-->A2;
  A2(aws-ec2/lib/vpc-flow-logs.ts)--IDeliveryStream-->B1;
  B1(aws-kinesisfirehose)-->B2;
  B2(aws-kinesisfirehose/lib/delivery-stream.ts)--Connections,Peer,IConnectable-->A1;
Loading

After

graph TD;
  A1(aws-ec2)-->A2 & A3 & A4;
  A2(aws-ec2/lib/vpc-flow-logs.ts)--IDeliveryStream-->B1;
  A3(aws-ec2/lib/connections.ts)--Peer-->A4;
  A4(aws-ec2/lib/peer.ts)--Connections,IConnectable-->A3;
  B1(aws-kinesisfirehose)-->B2;
  B2(aws-kinesisfirehose/lib/delivery-stream.ts)--Connections,IConnectable-->A3;
  B2--Peer-->A4;
Loading

@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 2, 2025
@ozelalisen ozelalisen self-assigned this Jun 5, 2025
Copy link
Member

@ozelalisen ozelalisen left a comment

Choose a reason for hiding this comment

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

I've reviewed the changes in this PR and can confirm that it fixes the cyclic dependency issue. Approving this PR

@mergify
Copy link
Contributor

mergify bot commented Jun 5, 2025

Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@aws-cdk-automation
Copy link
Collaborator

AWS CodeBuild CI Report

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

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

@mergify
Copy link
Contributor

mergify bot commented Jun 5, 2025

Thank you for contributing! Your pull request will be updated from main and then merged automatically (do not update manually, and be sure to allow changes to be pushed to your fork).

@mergify mergify bot merged commit cdfe6e7 into aws:main Jun 5, 2025
16 checks passed
@github-actions
Copy link
Contributor

github-actions bot commented Jun 5, 2025

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 5, 2025
@Tietew Tietew deleted the ec2-flowlog-firehose branch June 5, 2025 22:45
@ozelalisen
Copy link
Member

ozelalisen commented Jun 10, 2025

Need to revert this PR as it created cyclic dependency again

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

distinguished-contributor [Pilot] contributed 50+ PRs to the CDK p2 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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants