-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
105 additions
and
0 deletions.
There are no files selected for viewing
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
45 changes: 45 additions & 0 deletions
45
framework/src/streaming/examples/msk-serverless-cluster-policy.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,45 @@ | ||
import * as cdk from 'aws-cdk-lib'; | ||
import { AclOperationTypes, AclPermissionTypes, AclResourceTypes,MskProvisioned, ResourcePatternTypes } from '../lib/msk'; | ||
import { Effect, PolicyDocument, PolicyStatement, ServicePrincipal } from 'aws-cdk-lib/aws-iam'; | ||
|
||
|
||
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'); | ||
const cluterPolicy = new PolicyDocument( | ||
{ | ||
statements: [ | ||
new PolicyStatement ({ | ||
actions: [ | ||
'kafka:CreateVpcConnection', | ||
'kafka:GetBootstrapBrokers', | ||
'kafka:DescribeClusterV2', | ||
], | ||
resources: [msk.cluster.attrArn], | ||
effect: Effect.ALLOW, | ||
principals: [new ServicePrincipal('firehose.amazonaws.com')], | ||
}), | ||
], | ||
}, | ||
); | ||
|
||
msk.addClusterPolicy(cluterPolicy, 'cluterPolicy'); | ||
/// !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); | ||
|
||
|
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