Skip to content

Commit

Permalink
Add sagemaker role to CI isolation stack
Browse files Browse the repository at this point in the history
  • Loading branch information
kaklakariada committed Aug 16, 2023
1 parent e4a3973 commit e815e2f
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 3 deletions.
2 changes: 1 addition & 1 deletion ci-isolation/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
<dependency>
<groupId>com.exasol</groupId>
<artifactId>ci-isolation-aws</artifactId>
<version>2.0.0</version>
<version>2.0.1</version>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.exasol.ciisolation.aws.PolicyReader;
import com.exasol.ciisolation.aws.ciuser.CiUserStack;
import com.exasol.ciisolation.aws.ciuser.CiUserStack.CiUserStackProps;

import software.amazon.awscdk.App;

Expand All @@ -12,10 +13,12 @@ public class CiIsolationApp {
public static void main(final String[] args) {
final App app = new App();
final PolicyReader policyReader = new PolicyReader();
new CiUserStack(app, CiUserStack.CiUserStackProps.builder().projectName("exasol-sagemaker-extension")
CiUserStackProps props = CiUserStack.CiUserStackProps.builder().projectName("exasol-sagemaker-extension")
.addRequiredPermissions(
policyReader.readPolicyFromResources("s3-access.json"),
policyReader.readPolicyFromResources("sagemaker-access.json")).build());
policyReader.readPolicyFromResources("sagemaker-access.json")).build();
new CiUserStack(app, props);
new SageMakerRoleStack(app, "protected-exasol-sagemaker-extension-role-stack", props);
app.synth();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.exasol.adapter.document.files.ciisolation;

import com.exasol.ciisolation.aws.TaggedStack;
import com.exasol.ciisolation.aws.ciuser.CiUserStack.CiUserStackProps;

import software.amazon.awscdk.services.iam.*;
import software.constructs.Construct;

class SageMakerRoleStack extends TaggedStack {
SageMakerRoleStack(final Construct scope, final String id, final CiUserStackProps props) {
super(scope, id, null, props.projectName());
Role role = Role.Builder.create(this, "Role")
.assumedBy(new CompositePrincipal(new ServicePrincipal("sagemaker.amazonaws.com")))
.description(
"Allows SageMaker notebook instances, training jobs, and models to access S3, ECR, and CloudWatch on your behalf.")
.build();
tagResource(role);
role.addManagedPolicy(ManagedPolicy.fromAwsManagedPolicyName("AmazonSageMakerFullAccess"));
}
}

0 comments on commit e815e2f

Please sign in to comment.