|
| 1 | +import * as cdk from 'aws-cdk-lib'; |
| 2 | +import { Construct } from 'constructs'; |
| 3 | +import * as ara from 'aws-analytics-reference-architecture'; |
| 4 | +import * as iam from 'aws-cdk-lib/aws-iam' ; |
| 5 | + |
| 6 | + |
| 7 | +export class EmrEksAppStack extends cdk.Stack { |
| 8 | + constructor(scope: Construct, id: string, props?: cdk.StackProps) { |
| 9 | + super(scope, id, props); |
| 10 | + |
| 11 | + const emrEks = ara.EmrEksCluster.getOrCreate(this,{ |
| 12 | + eksAdminRoleArn:'', |
| 13 | + eksClusterName:'' |
| 14 | + }); |
| 15 | + |
| 16 | + const virtualCluster = emrEks.addEmrVirtualCluster(this,{ |
| 17 | + name:'my-emr-eks-cluster', |
| 18 | + eksNamespace: 'batchjob', |
| 19 | + createNamespace: true, |
| 20 | + }); |
| 21 | + |
| 22 | + const emrEksPolicy = new iam.ManagedPolicy(this,'managed-policy',{ |
| 23 | + statements: [ |
| 24 | + new iam.PolicyStatement({ |
| 25 | + effect: iam.Effect.ALLOW, |
| 26 | + actions:['s3:PutObject','s3:GetObject','s3:ListBucket'], |
| 27 | + resources:['*'], |
| 28 | + }), |
| 29 | + new iam.PolicyStatement({ |
| 30 | + effect: iam.Effect.ALLOW, actions:['logs:PutLogEvents','logs:CreateLogStream','logs:DescribeLogGroups','logs:DescribeLogStreams'], |
| 31 | + resources:['arn:aws:logs:*:*:*'], |
| 32 | + }), |
| 33 | + ] |
| 34 | + }); |
| 35 | + |
| 36 | + |
| 37 | + const role = emrEks.createExecutionRole(this,'emr-eks-execution-role',emrEksPolicy, 'batchjob','execRoleJob'); |
| 38 | + |
| 39 | + // Virtual cluster Id to reference in jobs |
| 40 | + new cdk.CfnOutput(this, 'VirtualClusterId', { value: virtualCluster.attrId }); |
| 41 | + // Job config for each nodegroup |
| 42 | + new cdk.CfnOutput(this, 'CriticalConfig', { value: emrEks.criticalDefaultConfig }); |
| 43 | + // Execution role arn |
| 44 | + new cdk.CfnOutput(this, 'ExecRoleArn', { value: role.roleArn }); |
| 45 | + |
| 46 | + |
| 47 | + const notebookPlatform = new ara.NotebookPlatform(this, 'platform-notebook', { |
| 48 | + emrEks: emrEks, |
| 49 | + eksNamespace: 'dataanalysis', |
| 50 | + studioName: 'platform', |
| 51 | + studioAuthMode: ara.StudioAuthMode.IAM, |
| 52 | + }); |
| 53 | + |
| 54 | + notebookPlatform.addUser([{ |
| 55 | + identityName:'', |
| 56 | + notebookManagedEndpoints: [{ |
| 57 | + emrOnEksVersion: 'emr-6.8.0-latest', |
| 58 | + executionPolicy: emrEksPolicy, |
| 59 | + managedEndpointName: 'myendpoint' |
| 60 | + }], |
| 61 | + }]); |
| 62 | + |
| 63 | + |
| 64 | + } |
| 65 | +} |
0 commit comments