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(stepfunctions-tasks): add emr-containers support for calling CreateVirtualCluster, DeleteVirtualCluster, and StartJobRun #15262

Closed
wants to merge 77 commits into from
Closed
Show file tree
Hide file tree
Changes from 67 commits
Commits
Show all changes
77 commits
Select commit Hold shift + click to select a range
d3c1ce0
fix(core): parsing an ARN with a slash after a colon in the resource …
skinny85 Jun 17, 2021
e37d4dc
Merge branch 'master' into fix/arn-parse-slash-after-colon
mergify[bot] Jun 21, 2021
f1ed884
feat(stepfunctions-tasks): Initial commit with base-types definition,…
Jun 22, 2021
6da8b96
Finished comment documentation and changed props
Jun 28, 2021
e4af04c
feat(stepfunctions-tasks): Initial commit with base-types definition,…
Jun 22, 2021
0f2af94
Merge branch 'containers' of https://github.com/matthewsvu/aws-cdk in…
Jun 30, 2021
ed7ec9b
Finished writing unit tests for Create and DeleteVirtualCluster
Jul 2, 2021
478f2c8
Update packages/@aws-cdk/aws-stepfunctions-tasks/lib/emrcontainers/cr…
matthewsvu Jul 4, 2021
e31b783
Update packages/@aws-cdk/aws-stepfunctions-tasks/lib/emrcontainers/cr…
matthewsvu Jul 4, 2021
79efa08
Update packages/@aws-cdk/aws-stepfunctions-tasks/lib/emrcontainers/cr…
matthewsvu Jul 4, 2021
301730f
Update packages/@aws-cdk/aws-stepfunctions-tasks/lib/emrcontainers/cr…
matthewsvu Jul 4, 2021
43786fa
Update packages/@aws-cdk/aws-stepfunctions-tasks/lib/emrcontainers/cr…
matthewsvu Jul 4, 2021
0b76c61
Update packages/@aws-cdk/aws-stepfunctions-tasks/lib/emrcontainers/cr…
matthewsvu Jul 4, 2021
ac9bcfe
Update packages/@aws-cdk/aws-stepfunctions-tasks/lib/emrcontainers/cr…
matthewsvu Jul 4, 2021
2329255
Update packages/@aws-cdk/aws-stepfunctions-tasks/lib/emrcontainers/st…
matthewsvu Jul 4, 2021
7f72556
Update packages/@aws-cdk/aws-stepfunctions-tasks/lib/emrcontainers/ba…
matthewsvu Jul 4, 2021
e60251a
Update packages/@aws-cdk/aws-stepfunctions-tasks/lib/emrcontainers/cr…
matthewsvu Jul 4, 2021
6505acc
Update packages/@aws-cdk/aws-stepfunctions-tasks/lib/emrcontainers/de…
matthewsvu Jul 4, 2021
4da1cf7
Update packages/@aws-cdk/aws-stepfunctions-tasks/lib/emrcontainers/de…
matthewsvu Jul 6, 2021
338078d
Update packages/@aws-cdk/aws-stepfunctions-tasks/lib/emrcontainers/st…
matthewsvu Jul 6, 2021
8685329
StartJobRun and CreateVirtualCluster API changes
Jul 9, 2021
6c4d416
removed modified file from PR
Jul 9, 2021
ebbdc16
removed package-lock.json + package.json from PR
Jul 9, 2021
b907327
More StartJobRun api modification
Jul 10, 2021
01338ce
Added changes to user facing api structure to start-job-run, base-typ…
Jul 28, 2021
d5b4858
Added package dependencies for logs, awscli, and custom-resources
Jul 28, 2021
3593c76
Added README, removed base-types, added error validation
Jul 30, 2021
f2e4897
fix readme
Jul 30, 2021
acbd8e8
README formatting issue correction
Jul 30, 2021
2eb8cd4
Added README, removed base-types, added error validation
Jul 30, 2021
b005182
Merge branch 'containers' of https://github.com/matthewsvu/aws-cdk in…
Jul 30, 2021
37da06d
README linting
Jul 30, 2021
1f5d518
Update packages/@aws-cdk/aws-stepfunctions-tasks/README.md
matthewsvu Jul 31, 2021
97b419a
Update packages/@aws-cdk/aws-stepfunctions-tasks/README.md
matthewsvu Jul 31, 2021
645e54b
Update packages/@aws-cdk/aws-stepfunctions-tasks/README.md
matthewsvu Jul 31, 2021
304a759
Update packages/@aws-cdk/aws-stepfunctions-tasks/README.md
matthewsvu Jul 31, 2021
9045233
Update packages/@aws-cdk/aws-stepfunctions-tasks/lib/emrcontainers/cr…
matthewsvu Jul 31, 2021
cb9c9ab
Update packages/@aws-cdk/aws-stepfunctions-tasks/lib/emrcontainers/cr…
matthewsvu Jul 31, 2021
de896fc
Update packages/@aws-cdk/aws-stepfunctions-tasks/lib/emrcontainers/cr…
matthewsvu Jul 31, 2021
ef6668a
Update packages/@aws-cdk/aws-stepfunctions-tasks/lib/emrcontainers/cr…
matthewsvu Jul 31, 2021
d798fe0
Update packages/@aws-cdk/aws-stepfunctions-tasks/lib/emrcontainers/cr…
matthewsvu Jul 31, 2021
72d2b34
Update packages/@aws-cdk/aws-stepfunctions-tasks/lib/emrcontainers/cr…
matthewsvu Jul 31, 2021
fb85f00
Update packages/@aws-cdk/aws-stepfunctions-tasks/lib/emrcontainers/cr…
matthewsvu Jul 31, 2021
0fa6738
Update packages/@aws-cdk/aws-stepfunctions-tasks/lib/emrcontainers/de…
matthewsvu Jul 31, 2021
e3946bb
Update packages/@aws-cdk/aws-stepfunctions-tasks/lib/emrcontainers/de…
matthewsvu Jul 31, 2021
08ae7e8
Update packages/@aws-cdk/aws-stepfunctions-tasks/lib/emrcontainers/de…
matthewsvu Jul 31, 2021
b162389
Update packages/@aws-cdk/aws-stepfunctions-tasks/lib/emrcontainers/st…
matthewsvu Jul 31, 2021
b3a712b
Update packages/@aws-cdk/aws-stepfunctions-tasks/lib/emrcontainers/st…
matthewsvu Jul 31, 2021
674da28
Apply suggestions from code review
matthewsvu Aug 2, 2021
0af25ae
Merge branch 'containers' of https://github.com/matthewsvu/aws-cdk in…
Aug 3, 2021
bd0e168
Apply suggestions from code review
Aug 3, 2021
deb9a9c
README example changes, execution-role policy changes, lambda changes
Aug 5, 2021
0a26ffb
Fix merge conflicts with remote containers
Aug 5, 2021
223f4de
Apply suggestions from code review
matthewsvu Aug 7, 2021
b5201d4
Update packages/@aws-cdk/aws-stepfunctions-tasks/lib/emrcontainers/st…
matthewsvu Aug 9, 2021
b7b35ec
Added unit tests to start-job-run, adjust iam scope, added to README
Aug 13, 2021
1a74fba
Minor changes to README, Fixed Error validation, completed start-job-…
Aug 17, 2021
50df69b
minor changes to tests
Aug 17, 2021
9d8f64e
Apply suggestions from code review
matthewsvu Aug 17, 2021
7bd82cd
Unit test changes from PR
Aug 18, 2021
1073925
Minor unit test additions
Aug 18, 2021
842fbdc
Merge branch 'master', commit 'e37d4dc63ab4b187cf8d1c7799838efc327cfa…
Aug 18, 2021
6098822
Cleaning up tests
Aug 18, 2021
7eec75c
Apply suggestions from code review
matthewsvu Aug 19, 2021
f14b4ca
Apply suggestions from code review
matthewsvu Aug 19, 2021
1053102
Apply suggestions from code review
matthewsvu Aug 19, 2021
f66dea5
Merge branch 'master' into containers
matthewsvu Aug 19, 2021
b09274d
Merge branch 'master' of https://github.com/matthewsvu/aws-cdk into c…
Aug 19, 2021
fcd20f3
Fix merge conflicts and modified tests
Aug 19, 2021
847dcf8
Unit tests revision, PR comment revisions
Aug 20, 2021
0189281
Merge branch 'containers' of https://github.com/matthewsvu/aws-cdk in…
Aug 20, 2021
55c60ce
Apply suggestions from code review
matthewsvu Aug 20, 2021
38e51e6
Apply suggestions from code review
matthewsvu Aug 20, 2021
a0640ce
Update packages/@aws-cdk/aws-stepfunctions-tasks/lib/emrcontainers/cr…
matthewsvu Aug 20, 2021
ef49003
PR comment changes to tests and Name Parameters
Aug 20, 2021
9a868a1
Merge branch 'containers' of https://github.com/matthewsvu/aws-cdk in…
Aug 20, 2021
a4424a0
Apply suggestions from code review
matthewsvu Oct 20, 2021
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
199 changes: 199 additions & 0 deletions packages/@aws-cdk/aws-stepfunctions-tasks/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ This module is part of the [AWS Cloud Development Kit](https://github.com/aws/aw
- [Cancel Step](#cancel-step)
- [Modify Instance Fleet](#modify-instance-fleet)
- [Modify Instance Group](#modify-instance-group)
- [EMR on EKS](#emr-on-eks)
- [Create Virtual Cluster](#create-virtual-cluster)
- [Delete Virtual Cluster](#delete-virtual-cluster)
- [Start Job Run](#start-job-run)
- [EKS](#eks)
- [Call](#call)
- [EventBridge](#eventbridge)
Expand Down Expand Up @@ -727,6 +731,201 @@ new tasks.EmrModifyInstanceGroupByName(this, 'Task', {
});
```

## EMR on EKS

Step Functions supports Amazon EMR on EKS through the service integration pattern.
The service integration APIs correspond to Amazon EMR on EKS APIs, but differ in the parameters that are used.

[Read more](https://docs.aws.amazon.com/step-functions/latest/dg/connect-emr-eks.html) about the differences when using these service integrations.
matthewsvu marked this conversation as resolved.
Show resolved Hide resolved

[Setting up](https://docs.aws.amazon.com/emr/latest/EMR-on-EKS-DevelopmentGuide/setting-up.html) the EKS cluster is required.

### Create Virtual Cluster

The [CreateVirtualCluster](https://docs.aws.amazon.com/emr-on-eks/latest/APIReference/API_CreateVirtualCluster.html) API creates a single virtual cluster that's mapped to a single Kubernetes namespace.

The EKS cluster containing the Kubernetes namespace where the virtual cluster will be mapped can be passed in from the task input.

```ts
matthewsvu marked this conversation as resolved.
Show resolved Hide resolved
import * as sfn from '@aws-cdk/aws-stepfunctions';
import * as tasks from '@aws-cdk/aws-stepfunctions-tasks';

new tasks.EmrContainersEksCreateVirtualCluster(this, 'Create a Virtual Cluster', {
eksCluster: tasks.EksClusterInput.fromTaskInput(sfn.TaskInput.fromText('clusterId')),
});
```

The EKS cluster can also be passed in directly.

```ts
matthewsvu marked this conversation as resolved.
Show resolved Hide resolved
import * as sfn from '@aws-cdk/aws-stepfunctions';
import * as tasks from '@aws-cdk/aws-stepfunctions-tasks';
import * as eks from '@aws-cdk/aws-eks';

const eksCluster = new eks.Cluster(this, 'EKS cluster', {
version: eks.KubernetesVersion.V1_20,
});

new tasks.EmrContainersEksCreateVirtualCluster(this, 'Create a Virtual Cluster', {
eksCluster: tasks.EksClusterInput.fromCluster(eksCluster),
});
```

By default, the Kubernetes namespace that a virtual cluster maps to is "default", but a specific namespace within an EKS cluster can be selected.

```ts
import * as sfn from '@aws-cdk/aws-stepfunctions';
import * as tasks from '@aws-cdk/aws-stepfunctions-tasks';

new tasks.EmrContainersEksCreateVirtualCluster(this, 'Create a Virtual Cluster', {
eksCluster: tasks.EksClusterInput.fromTaskInput(sfn.TaskInput.fromText('clusterId')),
eksNamespace: 'specified-namespace',
});
```

### Delete Virtual Cluster

The [DeleteVirtualCluster](https://docs.aws.amazon.com/emr-on-eks/latest/APIReference/API_DeleteVirtualCluster.html) API deletes a virtual cluster.

```ts
import * as sfn from '@aws-cdk/aws-stepfunctions';
import * as tasks from '@aws-cdk/aws-stepfunctions-tasks'
matthewsvu marked this conversation as resolved.
Show resolved Hide resolved

new tasks.EmrContainersDeleteVirtualCluster(this, 'Delete a Virtual Cluster', {
virtualClusterId: sfn.TaskInput.fromJsonPathAt('$.VirtualClusterId'),
});
```

### Start Job Run

The [StartJobRun](https://docs.aws.amazon.com/emr-on-eks/latest/APIReference/API_StartJobRun.html) API starts a job run. A job is a unit of work that you submit to Amazon EMR on EKS for execution. The work performed by the job can be defined by a Spark jar, PySpark script, or SparkSQL query. A job run is an execution of the job on the virtual cluster.

Required setup:

- If not done already, follow the EMR on EKS [setting up steps](https://docs.aws.amazon.com/emr/latest/EMR-on-EKS-DevelopmentGuide/setting-up.html) and [create an EKS Cluster](https://docs.aws.amazon.com/cdk/api/latest/docs/aws-eks-readme.html#quick-start).
matthewsvu marked this conversation as resolved.
Show resolved Hide resolved
- Enable [Cluster access](https://docs.aws.amazon.com/emr/latest/EMR-on-EKS-DevelopmentGuide/setting-up-cluster-access.html)
- Enable [IAM Role access](https://docs.aws.amazon.com/emr/latest/EMR-on-EKS-DevelopmentGuide/setting-up-enable-IAM.html)

The following actions must be performed if the virtual cluster ID is supplied from the task input. Otherwise, if it is supplied statically in the state machine definition, these actions will be done automatically.

- Create an [IAM role](https://docs.aws.amazon.com/cdk/api/latest/docs/@aws-cdk_aws-iam.Role.html)
- Update the [Role Trust Policy](https://docs.aws.amazon.com/emr/latest/EMR-on-EKS-DevelopmentGuide/setting-up-trust-policy.html) of the Job Execution Role.

The job can be configured with spark submit parameters such as the instances, memory, and cores in each job.
matthewsvu marked this conversation as resolved.
Show resolved Hide resolved

```ts
matthewsvu marked this conversation as resolved.
Show resolved Hide resolved
import * as iam from '@aws-cdk/aws-iam';
import * as sfn from '@aws-cdk/aws-stepfunctions';
import * as tasks from '@aws-cdk/aws-stepfunctions-tasks';

new tasks.EmrContainersStartJobRun(this, 'EMR Containers Start Job Run', {
virtualClusterId: sfn.TaskInput.fromText('de92jdei2910fwedz'),
releaseLabel: tasks.ReleaseLabel.EMR_6_2_0,
jobDriver: {
sparkSubmitJobDriver: {
entryPoint: sfn.TaskInput.fromText('local:///usr/lib/spark/examples/src/main/python/pi.py'),
sparkSubmitParameters: '--conf spark.executor.instances=2 --conf spark.executor.memory=2G --conf spark.executor.cores=2 --conf spark.driver.cores=1',
},
},
});
```

Configuring the job can also be done via application configuration instead of spark submit parameters.
matthewsvu marked this conversation as resolved.
Show resolved Hide resolved

```ts
import * as iam from '@aws-cdk/aws-iam';
import * as sfn from '@aws-cdk/aws-stepfunctions';
import * as tasks from '@aws-cdk/aws-stepfunctions-tasks';

new tasks.EmrContainersStartJobRun(this, 'EMR Containers Start Job Run', {
virtualClusterId: sfn.TaskInput.fromText('de92jdei2910fwedz'),
releaseLabel: tasks.ReleaseLabel.EMR_6_2_0,
jobName: 'EMR-Containers-Job',
jobDriver: {
sparkSubmitJobDriver: {
entryPoint: sfn.TaskInput.fromText('local:///usr/lib/spark/examples/src/main/python/pi.py'),
},
applicationConfig: [{
classification: tasks.Classification.SPARK_DEFAULTS,
properties: {
'spark.executor.instances': '1',
'spark.executor.memory': '512M',
},
}],
});
```

If needed, monitoring a job can be enabled if `monitoring.logging` is set true. Automatically generates S3 bucket and CloudWatch logs resources.
matthewsvu marked this conversation as resolved.
Show resolved Hide resolved

```ts
import * as iam from '@aws-cdk/aws-iam';
import * as sfn from '@aws-cdk/aws-stepfunctions';
import * as tasks from '@aws-cdk/aws-stepfunctions-tasks';

new tasks.EmrContainersStartJobRun(this, 'EMR Containers Start Job Run', {
virtualClusterId: sfn.TaskInput.fromText('de92jdei2910fwedz'),
releaseLabel: tasks.ReleaseLabel.EMR_6_2_0,
jobDriver: {
sparkSubmitJobDriver: {
entryPoint: sfn.TaskInput.fromText('local:///usr/lib/spark/examples/src/main/python/pi.py'),
sparkSubmitParameters: '--conf spark.executor.instances=2 --conf spark.executor.memory=2G --conf spark.executor.cores=2 --conf spark.driver.cores=1',
matthewsvu marked this conversation as resolved.
Show resolved Hide resolved
},
},
monitoring: {
logging: true,
},
});
```

Otherwise, providing monitoring for jobs with existing log groups and log buckets is also available.

```ts
import * as iam from '@aws-cdk/aws-iam';
import * as sfn from '@aws-cdk/aws-stepfunctions';
import * as logs from '@aws-cdk/aws-logs';
import * as s3 from '@aws-cdk/aws-s3';
import * as tasks from '@aws-cdk/aws-stepfunctions-tasks';

const logGroup = new logs.LogGroup(this, 'Log Group');
const logBucket = new s3.Bucket(this, 'S3 Bucket')

new tasks.EmrContainersStartJobRun(this, 'EMR Containers Start Job Run', {
virtualClusterId: sfn.TaskInput.fromText('de92jdei2910fwedz'),
releaseLabel: tasks.ReleaseLabel.EMR_6_2_0,
jobDriver: {
sparkSubmitJobDriver: {
entryPoint: sfn.TaskInput.fromText('local:///usr/lib/spark/examples/src/main/python/pi.py'),
sparkSubmitParameters: '--conf spark.executor.instances=2 --conf spark.executor.memory=2G --conf spark.executor.cores=2 --conf spark.driver.cores=1',
},
},
monitoring: {
logGroup: this.logGroup,
logBucket: this.logBucket,
},
});
```

Users can provide their own existing Job Execution Role.

```ts
import * as iam from '@aws-cdk/aws-iam';
import * as sfn from '@aws-cdk/aws-stepfunctions';
import * as tasks from '@aws-cdk/aws-stepfunctions-tasks';

new tasks.EmrContainersStartJobRun(this, 'EMR Containers Start Job Run', {
virtualClusterId: sfn.TaskInput.fromJsonPathAt('$.VirtualClusterId'),
releaseLabel: tasks.ReleaseLabel.EMR_6_2_0,
jobName: 'EMR-Containers-Job',
executionRole: iam.Role.fromRoleArn(this, 'Job-Execution-Role', 'arn:aws:iam::xxxxxxxxxxxx:role/JobExecutionRole'),
jobDriver: {
sparkSubmitJobDriver: {
entryPoint: sfn.TaskInput.fromText('local:///usr/lib/spark/examples/src/main/python/pi.py'),
sparkSubmitParameters: '--conf spark.executor.instances=2 --conf spark.executor.memory=2G --conf spark.executor.cores=2 --conf spark.driver.cores=1',
},
},
});
```

## EKS

Step Functions supports Amazon EKS through the service integration pattern.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
import * as eks from '@aws-cdk/aws-eks';
import * as iam from '@aws-cdk/aws-iam';
import * as sfn from '@aws-cdk/aws-stepfunctions';
import * as cdk from '@aws-cdk/core';
import { Construct } from 'constructs';
import { integrationResourceArn, validatePatternSupported } from '../private/task-utils';

/**
* Class for supported types of EMR Containers' Container Providers
*/
enum ContainerProviderTypes {

/**
* Supported container provider type for a EKS Cluster
*
* @returns 'EKS'
*/
EKS = 'EKS'

matthewsvu marked this conversation as resolved.
Show resolved Hide resolved
}

/**
* Class that supports methods which return the EKS cluster name depending on input type.
*/
export class EksClusterInput {

/**
* Use an EKS Cluster for the EKS Cluster name
*
* @param cluster - An EKS cluster
* @returns The name of the EKS Cluster
*/
static fromCluster(cluster: eks.ICluster): EksClusterInput {
return new EksClusterInput(cluster.clusterName);
}

/**
* Use a Task Input for the cluster name.
*
* @param taskInput Task Input object that accepts multiple types of payloads, in this case a literal string.
* @returns The value of a Task Input object, or a literal string.
*/
static fromTaskInput(taskInput: sfn.TaskInput): EksClusterInput {
return new EksClusterInput(taskInput.value);
}

/**
* Initializes the clusterName
*
* @param clusterName The name of the EKS Cluster
*/
private constructor(readonly clusterName: string) { }
}

/**
* Properties to define a EMR Containers CreateVirtualCluster Task on an EKS cluster
*/
export interface EmrContainersEksCreateVirtualClusterProps extends sfn.TaskStateBaseProps {

/**
* EKS Cluster or task input that contains the name of the cluster
*/
readonly eksCluster: EksClusterInput;

/**
* The namespace of an EKS cluster
*
* @default - 'default'
*/
readonly eksNamespace?: string;

/**
* Name of the virtual cluster that will be created.
*
* @default - the id of the state machine execution that runs this task
*/
readonly virtualClusterName?: string;

/**
* The tags assigned to the virtual cluster
*
* @default {}
*/
readonly tags?: { [key: string]: string };
}

/**
* Task that creates an EMR Containers virtual cluster from an EKS cluster
*
* @see https://docs.aws.amazon.com/step-functions/latest/dg/connect-emr-eks.html
*/
export class EmrContainersEksCreateVirtualCluster extends sfn.TaskStateBase {

private static readonly SUPPORTED_INTEGRATION_PATTERNS: sfn.IntegrationPattern[] = [
sfn.IntegrationPattern.REQUEST_RESPONSE,
];

protected readonly taskMetrics?: sfn.TaskMetricsConfig;
matthewsvu marked this conversation as resolved.
Show resolved Hide resolved
protected readonly taskPolicies?: iam.PolicyStatement[];

private readonly integrationPattern: sfn.IntegrationPattern;

constructor(scope: Construct, id: string, private readonly props: EmrContainersEksCreateVirtualClusterProps) {
super(scope, id, props);
this.integrationPattern = props.integrationPattern ?? sfn.IntegrationPattern.REQUEST_RESPONSE;
validatePatternSupported(this.integrationPattern, EmrContainersEksCreateVirtualCluster.SUPPORTED_INTEGRATION_PATTERNS);

this.taskPolicies = this.createPolicyStatements();
}

/**
* @internal
*/
protected _renderTask(): any {
return {
Resource: integrationResourceArn('emr-containers', 'createVirtualCluster', this.integrationPattern),
Parameters: sfn.FieldUtils.renderObject({
Name: this.props.virtualClusterName ?? sfn.JsonPath.stringAt('States.Format(\'{}/{}\', $$.Execution.Name, $$.State.Name'),
ContainerProvider: {
Id: this.props.eksCluster.clusterName,
Info: {
EksInfo: {
Namespace: this.props.eksNamespace ?? 'default',
matthewsvu marked this conversation as resolved.
Show resolved Hide resolved
},
},
Type: ContainerProviderTypes.EKS,
},
Tags: this.renderTags(this.props.tags),
}),
};
};

private renderTags(tags?: { [key: string]: any }): { Key: string, Value: string }[] {
return tags ? Object.entries(tags).map(([key, value]) => ({ Key: key, Value: value })) : [];
}

private createPolicyStatements(): iam.PolicyStatement[] {
return [
new iam.PolicyStatement({
resources: ['*'], // We need * permissions for creating a virtual cluster https://docs.aws.amazon.com/emr/latest/EMR-on-EKS-DevelopmentGuide/setting-up-iam.html
actions: ['emr-containers:CreateVirtualCluster'],
}),
new iam.PolicyStatement({
resources: [
cdk.Stack.of(this).formatArn({
service: 'iam',
region: '',
resource: 'role/aws-service-role/emr-containers.amazonaws.com',
resourceName: 'AWSServiceRoleForAmazonEMRContainers',
}),
],
actions: ['iam:CreateServiceLinkedRole'],
conditions: {
StringLike: { 'iam:AWSServiceName': 'emr-containers.amazonaws.com' },
},
}),
];
}
}
Loading