-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(msk): MSK serverless and provisioned construct (#571)
Add support to create MSK serverless as well as MSK provisioned. Users can also manage topics and ACLs for the created cluster through this construct.
- Loading branch information
Showing
40 changed files
with
9,692 additions
and
3,679 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
framework/src/streaming/examples/msk-provisioned-bring-vpc.lit.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import * as cdk from 'aws-cdk-lib'; | ||
import { MskProvisioned } from '../lib/msk'; | ||
import { Vpc } from 'aws-cdk-lib/aws-ec2'; | ||
|
||
|
||
const app = new cdk.App(); | ||
|
||
const stack = new cdk.Stack(app, 'DsfTestMskServerless'); | ||
|
||
stack.node.setContext('@data-solutions-framework-on-aws/removeDataOnDestroy', true); | ||
|
||
/// !show | ||
let vpc = Vpc.fromVpcAttributes(stack, 'vpc', { | ||
vpcId: 'vpc-1111111111', | ||
vpcCidrBlock: '10.0.0.0/16', | ||
availabilityZones: ['eu-west-1a', 'eu-west-1b'], | ||
publicSubnetIds: ['subnet-111111111', 'subnet-11111111'], | ||
privateSubnetIds: ['subnet-11111111', 'subnet-1111111'], | ||
}); | ||
|
||
const msk = new MskProvisioned(stack, 'cluster', { | ||
vpc: vpc, | ||
clusterName: 'my-cluster', | ||
subnets: vpc.selectSubnets(), | ||
}); | ||
/// !hide | ||
|
||
new cdk.CfnOutput(stack, 'mskArn', { | ||
value: msk.cluster.attrArn, | ||
}); |
36 changes: 36 additions & 0 deletions
36
framework/src/streaming/examples/msk-provisioned-create-cluster-mtls.lit.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import * as cdk from 'aws-cdk-lib'; | ||
import { Authentication, ClientAuthentication, MskProvisioned } from '../lib/msk'; | ||
import { CertificateAuthority } from 'aws-cdk-lib/aws-acmpca'; | ||
import { Secret } from 'aws-cdk-lib/aws-secretsmanager'; | ||
|
||
|
||
const app = new cdk.App(); | ||
|
||
const stack = new cdk.Stack(app, 'MskProvisionedDsf'); | ||
|
||
stack.node.setContext('@data-solutions-framework-on-aws/removeDataOnDestroy', true); | ||
|
||
/// !show | ||
let certificateAuthority = CertificateAuthority.fromCertificateAuthorityArn( | ||
stack, 'certificateAuthority', | ||
'arn:aws:acm-pca:eu-west-1:123456789012:certificate-authority/aaaaaaaa-bbbb-454a-cccc-b454877f0d1b'); | ||
|
||
const msk = new MskProvisioned(stack, 'cluster', { | ||
clientAuthentication: ClientAuthentication.saslTls( | ||
{ | ||
iam: true, | ||
certificateAuthorities: [certificateAuthority], | ||
}, | ||
), | ||
certificateDefinition: { | ||
adminPrincipal: 'User:CN=Admin', | ||
aclAdminPrincipal: 'User:CN=aclAdmin', | ||
secretCertificate: Secret.fromSecretCompleteArn(stack, 'secret', 'arn:aws:secretsmanager:eu-west-1:123456789012:secret:dsf/mskCert-3UhUJJ'), | ||
}, | ||
allowEveryoneIfNoAclFound: false, | ||
}); | ||
/// !hide | ||
|
||
msk.grantConsume('consume', 'foo', Authentication.MTLS, 'User:Cn=MyUser'); | ||
|
||
|
26 changes: 26 additions & 0 deletions
26
framework/src/streaming/examples/msk-provisioned-default.lit.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import * as cdk from 'aws-cdk-lib'; | ||
import { AclOperationTypes, AclPermissionTypes, AclResourceTypes,MskProvisioned, ResourcePatternTypes } from '../lib/msk'; | ||
|
||
|
||
const app = new cdk.App(); | ||
|
||
const stack = new cdk.Stack(app, 'MskProvisionedDsf'); | ||
|
||
stack.node.setContext('@data-solutions-framework-on-aws/removeDataOnDestroy', true); | ||
|
||
/// !show | ||
const msk = new MskProvisioned(stack, 'cluster'); | ||
/// !hide | ||
|
||
msk.setAcl('acl', { | ||
resourceType: AclResourceTypes.TOPIC, | ||
resourceName: 'topic-1', | ||
resourcePatternType: ResourcePatternTypes.LITERAL, | ||
principal: 'User:Cn=Toto', | ||
host: '*', | ||
operation: AclOperationTypes.CREATE, | ||
permissionType: AclPermissionTypes.ALLOW, | ||
}, | ||
cdk.RemovalPolicy.DESTROY); | ||
|
||
|
38 changes: 38 additions & 0 deletions
38
framework/src/streaming/examples/msk-provisioned-grant-consume.lit.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import * as cdk from 'aws-cdk-lib'; | ||
import { Authentication, ClientAuthentication, MskProvisioned } from '../lib/msk'; | ||
import { CertificateAuthority } from 'aws-cdk-lib/aws-acmpca'; | ||
import { Secret } from 'aws-cdk-lib/aws-secretsmanager'; | ||
|
||
|
||
const app = new cdk.App(); | ||
|
||
const stack = new cdk.Stack(app, 'MskProvisionedDsf'); | ||
|
||
stack.node.setContext('@data-solutions-framework-on-aws/removeDataOnDestroy', true); | ||
|
||
|
||
let certificateAuthority = CertificateAuthority.fromCertificateAuthorityArn( | ||
stack, 'certificateAuthority', | ||
'arn:aws:acm-pca:eu-west-1:123456789012:certificate-authority/aaaaaaaa-bbbb-454a-cccc-b454877f0d1b'); | ||
|
||
const msk = new MskProvisioned(stack, 'cluster', { | ||
clientAuthentication: ClientAuthentication.saslTls( | ||
{ | ||
iam: true, | ||
certificateAuthorities: [certificateAuthority], | ||
}, | ||
), | ||
certificateDefinition: { | ||
adminPrincipal: 'User:CN=Admin', | ||
aclAdminPrincipal: 'User:CN=aclAdmin', | ||
secretCertificate: Secret.fromSecretCompleteArn(stack, 'secret', 'arn:aws:secretsmanager:eu-west-1:123456789012:secret:dsf/mskCert-3UhUJJ'), | ||
}, | ||
allowEveryoneIfNoAclFound: false, | ||
}); | ||
|
||
/// !show | ||
msk.grantConsume('consume', 'foo', Authentication.MTLS, 'User:Cn=MyUser'); | ||
/// !hide | ||
|
||
|
||
|
38 changes: 38 additions & 0 deletions
38
framework/src/streaming/examples/msk-provisioned-grant-produce.lit.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import * as cdk from 'aws-cdk-lib'; | ||
import { Authentication, ClientAuthentication, MskProvisioned } from '../lib/msk'; | ||
import { CertificateAuthority } from 'aws-cdk-lib/aws-acmpca'; | ||
import { Secret } from 'aws-cdk-lib/aws-secretsmanager'; | ||
|
||
|
||
const app = new cdk.App(); | ||
|
||
const stack = new cdk.Stack(app, 'MskProvisionedDsf'); | ||
|
||
stack.node.setContext('@data-solutions-framework-on-aws/removeDataOnDestroy', true); | ||
|
||
|
||
let certificateAuthority = CertificateAuthority.fromCertificateAuthorityArn( | ||
stack, 'certificateAuthority', | ||
'arn:aws:acm-pca:eu-west-1:123456789012:certificate-authority/aaaaaaaa-bbbb-454a-cccc-b454877f0d1b'); | ||
|
||
const msk = new MskProvisioned(stack, 'cluster', { | ||
clientAuthentication: ClientAuthentication.saslTls( | ||
{ | ||
iam: true, | ||
certificateAuthorities: [certificateAuthority], | ||
}, | ||
), | ||
certificateDefinition: { | ||
adminPrincipal: 'User:CN=Admin', | ||
aclAdminPrincipal: 'User:CN=aclAdmin', | ||
secretCertificate: Secret.fromSecretCompleteArn(stack, 'secret', 'arn:aws:secretsmanager:eu-west-1:123456789012:secret:dsf/mskCert-3UhUJJ'), | ||
}, | ||
allowEveryoneIfNoAclFound: false, | ||
}); | ||
|
||
/// !show | ||
msk.grantProduce('consume', 'foo', Authentication.MTLS, 'User:Cn=MyUser'); | ||
/// !hide | ||
|
||
|
||
|
25 changes: 25 additions & 0 deletions
25
framework/src/streaming/examples/msk-provisioned-set-acl.lit.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
import * as cdk from 'aws-cdk-lib'; | ||
import { AclOperationTypes, AclPermissionTypes, AclResourceTypes, MskProvisioned, ResourcePatternTypes } from '../lib/msk'; | ||
|
||
|
||
const app = new cdk.App(); | ||
|
||
const stack = new cdk.Stack(app, 'MskProvisionedDsf'); | ||
|
||
stack.node.setContext('@data-solutions-framework-on-aws/removeDataOnDestroy', true); | ||
|
||
|
||
const msk = new MskProvisioned(stack, 'cluster'); | ||
|
||
/// !show | ||
msk.setAcl('acl', { | ||
resourceType: AclResourceTypes.TOPIC, | ||
resourceName: 'topic-1', | ||
resourcePatternType: ResourcePatternTypes.LITERAL, | ||
principal: 'User:Cn=Bar', | ||
host: '*', | ||
operation: AclOperationTypes.CREATE, | ||
permissionType: AclPermissionTypes.ALLOW, | ||
}, | ||
cdk.RemovalPolicy.DESTROY); | ||
/// !hide |
Oops, something went wrong.