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

feat(AWS Kafka): Add support for mTLS access configuration #10273

Merged
merged 6 commits into from
Dec 5, 2021
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions lib/plugins/aws/package/compile/events/kafka.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,16 @@ class AwsCompileKafkaEvents {
minItems: 1,
items: { $ref: '#/definitions/awsSecretsManagerArnString' },
},
clientCertificateTLSAuth: {
mishabruml marked this conversation as resolved.
Show resolved Hide resolved
type: 'array',
minItems: 1,
items: { $ref: '#/definitions/awsSecretsManagerArnString' },
},
serverRootCaCertificate: {
type: 'array',
minItems: 1,
items: { $ref: '#/definitions/awsSecretsManagerArnString' },
},
},
additionalProperties: false,
},
Expand Down Expand Up @@ -167,6 +177,14 @@ class AwsCompileKafkaEvents {
type = 'SASL_SCRAM_512_AUTH';
needsSecretsManagerPermissions = true;
break;
case 'clientCertificateTLSAuth':
type = 'CLIENT_CERTIFICATE_TLS_AUTH';
needsSecretsManagerPermissions = true;
break;
case 'serverRootCaCertificate':
mishabruml marked this conversation as resolved.
Show resolved Hide resolved
type = 'SERVER_ROOT_CA_CERTIFICATE';
needsSecretsManagerPermissions = true;
break;
default:
type = accessConfigurationType;
}
Expand Down
59 changes: 48 additions & 11 deletions test/unit/lib/plugins/aws/package/compile/events/kafka.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,12 @@ chai.use(require('chai-as-promised'));

describe('test/unit/lib/plugins/aws/package/compile/events/kafka.test.js', () => {
const saslScram256AuthArn =
'arn:aws:secretsmanager:us-east-1:01234567890:secret:MyBrokerSecretName';
'arn:aws:secretsmanager:us-east-1:01234567890:secret:SaslScram256Auth';
const clientCertificateTLSAuthArn =
'arn:aws:secretsmanager:us-east-1:01234567890:secret:ClientCertificateTLSAuth';
const serverRootCaCertificateArn =
'arn:aws:secretsmanager:us-east-1:01234567890:secret:ServerRootCaCertificate';

const topic = 'TestingTopic';
const enabled = false;
const startingPosition = 'LATEST';
Expand Down Expand Up @@ -306,14 +311,14 @@ describe('test/unit/lib/plugins/aws/package/compile/events/kafka.test.js', () =>
await runCompileEventSourceMappingTest(eventConfig);
});

it('should correctly compile EventSourceMapping resource properties for SASL_SCRAM_256_AUTH', async () => {
it('should correctly compile EventSourceMapping resource properties for SASL_SCRAM_512_AUTH', async () => {
mishabruml marked this conversation as resolved.
Show resolved Hide resolved
const eventConfig = {
event: {
topic,
bootstrapServers: ['abc.xyz:9092'],
accessConfigurations: {
saslScram256Auth:
'arn:aws:secretsmanager:us-east-1:01234567890:secret:SaslScram256SecretName',
saslScram512Auth:
'arn:aws:secretsmanager:us-east-1:01234567890:secret:SaslScram512SecretName',
},
},
resource: (awsNaming) => {
Expand All @@ -325,8 +330,8 @@ describe('test/unit/lib/plugins/aws/package/compile/events/kafka.test.js', () =>
},
SourceAccessConfigurations: [
{
Type: 'SASL_SCRAM_256_AUTH',
URI: 'arn:aws:secretsmanager:us-east-1:01234567890:secret:SaslScram256SecretName',
Type: 'SASL_SCRAM_512_AUTH',
URI: 'arn:aws:secretsmanager:us-east-1:01234567890:secret:SaslScram512SecretName',
},
],
StartingPosition: 'TRIM_HORIZON',
Expand All @@ -340,14 +345,13 @@ describe('test/unit/lib/plugins/aws/package/compile/events/kafka.test.js', () =>
await runCompileEventSourceMappingTest(eventConfig);
});

it('should correctly compile EventSourceMapping resource properties for SASL_SCRAM_512_AUTH', async () => {
it('should correctly compile EventSourceMapping resource properties for CLIENT_CERTIFICATE_TLS_AUTH', async () => {
mishabruml marked this conversation as resolved.
Show resolved Hide resolved
const eventConfig = {
event: {
topic,
bootstrapServers: ['abc.xyz:9092'],
accessConfigurations: {
saslScram512Auth:
'arn:aws:secretsmanager:us-east-1:01234567890:secret:SaslScram512SecretName',
clientCertificateTLSAuth: clientCertificateTLSAuthArn,
},
},
resource: (awsNaming) => {
Expand All @@ -359,8 +363,41 @@ describe('test/unit/lib/plugins/aws/package/compile/events/kafka.test.js', () =>
},
SourceAccessConfigurations: [
{
Type: 'SASL_SCRAM_512_AUTH',
URI: 'arn:aws:secretsmanager:us-east-1:01234567890:secret:SaslScram512SecretName',
Type: 'CLIENT_CERTIFICATE_TLS_AUTH',
URI: clientCertificateTLSAuthArn,
},
],
StartingPosition: 'TRIM_HORIZON',
Topics: [topic],
FunctionName: {
'Fn::GetAtt': [awsNaming.getLambdaLogicalId('basic'), 'Arn'],
},
};
},
};
await runCompileEventSourceMappingTest(eventConfig);
});

it('should correctly compile EventSourceMapping resource properties for SERVER_ROOT_CA_CERTIFICATE', async () => {
const eventConfig = {
event: {
topic,
bootstrapServers: ['abc.xyz:9092'],
accessConfigurations: {
serverRootCaCertificate: serverRootCaCertificateArn,
},
},
resource: (awsNaming) => {
return {
SelfManagedEventSource: {
Endpoints: {
KafkaBootstrapServers: ['abc.xyz:9092'],
},
},
SourceAccessConfigurations: [
{
Type: 'SERVER_ROOT_CA_CERTIFICATE',
URI: serverRootCaCertificateArn,
},
],
StartingPosition: 'TRIM_HORIZON',
Expand Down