Skip to content

Commit 14e5e50

Browse files
authored
fix(stepfunctions-tasks): missing tags & perms for emr cluster creation (#28327)
Per the [documentation](https://docs.aws.amazon.com/emr/latest/ManagementGuide/emr-managed-iam-policies.html#manually-tagged-resources): * To use managed policies, pass the user tag `for-use-with-amazon-emr-managed-policies = true` when you provision a cluster with the CLI, SDK, or another method. * For resources that are not created by Amazon EMR, you must add tags to those resources. For example, you must tag Amazon EC2 subnets, EC2 security groups (if not created by Amazon EMR), and VPCs (if you want Amazon EMR to create security groups). Also, `AmazonEMRServicePolicy_v2` only has `iam:PassRole` on the default EMR roles and needs this on the cluster role created by the CDK. Running the step function: <img width="221" alt="Screenshot 2023-12-11 at 5 24 09 AM" src="https://github.com/aws/aws-cdk/assets/3310356/3b3b33c1-bcb8-4836-a1c0-123a8e7186ba"> <img width="661" alt="Screenshot 2023-12-11 at 5 24 03 AM" src="https://github.com/aws/aws-cdk/assets/3310356/c7f4fef9-0bce-42b9-a509-935cfe9a121b"> ---- *By submitting this pull request, I confirm that my contribution is made under the terms of the Apache-2.0 license*
1 parent f3dafa4 commit 14e5e50

File tree

36 files changed

+3944
-634
lines changed

36 files changed

+3944
-634
lines changed

packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/emr/integ.emr-create-cluster-with-spot-instance-fleet.js.snapshot/EmrCreateClusterTestDefaultTestDeployAssert697DC891.assets.json

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/emr/integ.emr-create-cluster-with-spot-instance-fleet.js.snapshot/aws-cdk-emr-create-cluster-with-spot-instance-fleet.assets.json

+3-3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/emr/integ.emr-create-cluster-with-spot-instance-fleet.js.snapshot/aws-cdk-emr-create-cluster-with-spot-instance-fleet.template.json

+28-6
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,6 @@
77
"Statement": [
88
{
99
"Action": "sts:AssumeRole",
10-
"Condition": {
11-
"StringEquals": {
12-
"aws:RequestTag/for-use-with-amazon-emr-managed-policies": "true"
13-
}
14-
},
1510
"Effect": "Allow",
1611
"Principal": {
1712
"Service": "elasticmapreduce.amazonaws.com"
@@ -36,6 +31,32 @@
3631
]
3732
}
3833
},
34+
"EmrCreateClusterServiceRoleDefaultPolicyA8B4FA32": {
35+
"Type": "AWS::IAM::Policy",
36+
"Properties": {
37+
"PolicyDocument": {
38+
"Statement": [
39+
{
40+
"Action": "iam:PassRole",
41+
"Effect": "Allow",
42+
"Resource": {
43+
"Fn::GetAtt": [
44+
"EmrCreateClusterInstanceRoleC80466F5",
45+
"Arn"
46+
]
47+
}
48+
}
49+
],
50+
"Version": "2012-10-17"
51+
},
52+
"PolicyName": "EmrCreateClusterServiceRoleDefaultPolicyA8B4FA32",
53+
"Roles": [
54+
{
55+
"Ref": "EmrCreateClusterServiceRole5251910D"
56+
}
57+
]
58+
}
59+
},
3960
"EmrCreateClusterInstanceRoleC80466F5": {
4061
"Type": "AWS::IAM::Role",
4162
"Properties": {
@@ -90,6 +111,7 @@
90111
"Statement": [
91112
{
92113
"Action": [
114+
"elasticmapreduce:AddTags",
93115
"elasticmapreduce:DescribeCluster",
94116
"elasticmapreduce:RunJobFlow",
95117
"elasticmapreduce:TerminateJobFlows"
@@ -197,7 +219,7 @@
197219
{
198220
"Ref": "EmrCreateClusterServiceRole5251910D"
199221
},
200-
"\",\"ReleaseLabel\":\"emr-5.36.1\",\"Tags\":[{\"Key\":\"Key\",\"Value\":\"Value\"}],\"VisibleToAllUsers\":true}}}}"
222+
"\",\"ReleaseLabel\":\"emr-5.36.1\",\"Tags\":[{\"Key\":\"Key\",\"Value\":\"Value\"},{\"Key\":\"for-use-with-amazon-emr-managed-policies\",\"Value\":\"true\"}],\"VisibleToAllUsers\":true}}}}"
201223
]
202224
]
203225
},

packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/emr/integ.emr-create-cluster-with-spot-instance-fleet.js.snapshot/cdk.out

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/emr/integ.emr-create-cluster-with-spot-instance-fleet.js.snapshot/integ.json

+1-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@aws-cdk-testing/framework-integ/test/aws-stepfunctions-tasks/test/emr/integ.emr-create-cluster-with-spot-instance-fleet.js.snapshot/manifest.json

+8-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)