Skip to content

Commit

Permalink
fix(lambda-event-sources): rootCACertificate does not support `ISec…
Browse files Browse the repository at this point in the history
…ret` (aws#21555)

Follow up to aws#21422
Type was missed there.


----

### All Submissions:

* [x] Have you followed the guidelines in our [Contributing guide?](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md)

### Adding new Unconventional Dependencies:

* [ ] This PR adds new unconventional dependencies following the process described [here](https://github.com/aws/aws-cdk/blob/main/CONTRIBUTING.md/#adding-new-unconventional-dependencies)

### New Features

* [ ] Have you added the new feature to an [integration test](https://github.com/aws/aws-cdk/blob/main/INTEGRATION_TESTS.md)?
	* [ ] Did you use `yarn integ` to deploy the infrastructure and generate the snapshot (i.e. `yarn integ` without `--dry-run`)?

*By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
  • Loading branch information
mrgrain authored and josephedward committed Aug 30, 2022
1 parent 5388d04 commit 5aed9a5
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-lambda-event-sources/lib/kafka.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ export interface SelfManagedKafkaEventSourceProps extends KafkaEventSourceProps
*
* @default - none
*/
readonly rootCACertificate?: secretsmanager.Secret;
readonly rootCACertificate?: secretsmanager.ISecret;
}

/**
Expand Down
32 changes: 32 additions & 0 deletions packages/@aws-cdk/aws-lambda-event-sources/test/kafka.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -601,6 +601,38 @@ describe('KafkaEventSource', () => {
});
});

test('rootCACertificate can be ISecret', () => {
// GIVEN
const stack = new cdk.Stack();
const fn = new TestFunction(stack, 'Fn');
const kafkaTopic = 'some-topic';
const mockRootCACertificateSecretArn = 'arn:aws:secretsmanager:us-east-1:012345678901:secret:mock';
const rootCACertificate = Secret.fromSecretPartialArn(stack, 'RootCASecret', mockRootCACertificateSecretArn);
const bootstrapServers = ['kafka-broker:9092'];
const sg = SecurityGroup.fromSecurityGroupId(stack, 'SecurityGroup', 'sg-0123456789');
const vpc = new Vpc(stack, 'Vpc');

// WHEN
fn.addEventSource(new sources.SelfManagedKafkaEventSource(
{
bootstrapServers: bootstrapServers,
topic: kafkaTopic,
startingPosition: lambda.StartingPosition.TRIM_HORIZON,
vpc: vpc,
vpcSubnets: { subnetType: SubnetType.PRIVATE_WITH_NAT },
securityGroup: sg,
rootCACertificate: rootCACertificate,
}));

Template.fromStack(stack).hasResourceProperties('AWS::Lambda::EventSourceMapping', {
SourceAccessConfigurations: Match.arrayWith([
{
Type: 'SERVER_ROOT_CA_CERTIFICATE',
URI: mockRootCACertificateSecretArn,
},
]),
});
});

test('ManagedKafkaEventSource name conforms to construct id rules', () => {
// GIVEN
Expand Down

0 comments on commit 5aed9a5

Please sign in to comment.