Skip to content

Commit

Permalink
Fixed typo in doc and added test
Browse files Browse the repository at this point in the history
  • Loading branch information
armaseg committed Sep 10, 2024
1 parent 42cd109 commit ea238b8
Show file tree
Hide file tree
Showing 3 changed files with 64 additions and 4 deletions.
4 changes: 2 additions & 2 deletions framework/API.md

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

2 changes: 1 addition & 1 deletion framework/src/streaming/lib/msk/kafka-api-props.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export interface KafkaApiProps {
readonly kafkaClientLogLevel?: KafkaClientLogLevel;

/**
* If you there is an already existing service token deployed for the custom resource
* If there is an already existing service token deployed for the custom resource
* you can reuse it to reduce the number of resource created
* @default WARN
*/
Expand Down
62 changes: 61 additions & 1 deletion framework/test/unit/streaming/kafka-api.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { SecurityGroup, Vpc, Subnet } from 'aws-cdk-lib/aws-ec2';
import { Role } from 'aws-cdk-lib/aws-iam';
import { CfnCluster } from 'aws-cdk-lib/aws-msk';
import { Secret } from 'aws-cdk-lib/aws-secretsmanager';
import { Authentication, ClientAuthentication, KafkaApi, MskClusterType } from '../../../src/streaming';
import { Authentication, ClientAuthentication, KafkaApi, MskClusterType, KafkaClientLogLevel } from '../../../src/streaming';


describe('Using default KafkaApi configuration with MSK provisioned and IAM and mTLS authentication should ', () => {
Expand Down Expand Up @@ -1250,4 +1250,64 @@ describe('Using global removal policy and DELETE construct removal policy ', ()
DeletionPolicy: 'Delete',
});
});
});

describe('Using default KafkaApi configuration with MSK provisioned and IAM and mTLS authentication should ', () => {

const app = new App();
const stack = new Stack(app, 'Stack');

const brokerSecurityGroup = SecurityGroup.fromSecurityGroupId(stack, 'sg', 'sg-1234');
const vpc = Vpc.fromVpcAttributes(stack, 'vpc', {
vpcId: 'XXXXXXXX',
availabilityZones: ['us-east-1a'],
vpcCidrBlock: '10.0.0.0/16',
privateSubnetIds: ['XXXXXXXX'],
});

const cluster = new CfnCluster(stack, 'MyCluster', {
clientAuthentication: {
sasl: {
iam: {
enabled: true,
},
},
},
brokerNodeGroupInfo: {
clientSubnets: vpc.privateSubnets.map(s => s.subnetId),
instanceType: 'kafka.m5large',
securityGroups: [brokerSecurityGroup.securityGroupId],
},
clusterName: 'XXXXXX',
kafkaVersion: '3.5.1',
numberOfBrokerNodes: 3,
});

const kafkaApi = new KafkaApi(stack, 'KafkaApi', {
clusterArn: cluster.attrArn,
clusterType: MskClusterType.PROVISIONED,
brokerSecurityGroup,
vpc,
clientAuthentication: ClientAuthentication.sasl({
iam: true,
}),
kafkaClientLogLevel: KafkaClientLogLevel.DEBUG,
serviceToken: 'arn:aws:lambda::XXXXXX:function:XXXXXX-kafkaApiMskIamProviderCustomResour-XXXXXX',
});

kafkaApi.setTopic('topic1',
Authentication.IAM,
{
topic: 'topic1',
numPartitions: 1,
},
);

const template = Template.fromStack(stack, {});

test('should have a service token to reuse', () => {
template.hasResourceProperties('Custom::MskTopic', {
ServiceToken: 'arn:aws:lambda::XXXXXX:function:XXXXXX-kafkaApiMskIamProviderCustomResour-XXXXXX',
});
});
});

0 comments on commit ea238b8

Please sign in to comment.