Skip to content

Commit

Permalink
fix: set 'mutable' to false when using imported roles
Browse files Browse the repository at this point in the history
  • Loading branch information
RanbirAulakh committed Aug 26, 2024
1 parent c3f2a63 commit 6e71475
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 34 deletions.
5 changes: 4 additions & 1 deletion lib/osml/data_catalog/dc_dataplane.ts
Original file line number Diff line number Diff line change
Expand Up @@ -496,7 +496,10 @@ export class DCDataplane extends Construct {
this.lambdaRole = Role.fromRoleName(
this,
"ImportedDCLambdaRole",
this.config.LAMBDA_ROLE_NAME
this.config.LAMBDA_ROLE_NAME,
{
mutable: false
}
);
} else {
this.lambdaRole = new DCLambdaRole(this, "DCLambdaRole", {
Expand Down
5 changes: 4 additions & 1 deletion lib/osml/data_intake/di_dataplane.ts
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,10 @@ export class DIDataplane extends Construct {
this.lambdaRole = Role.fromRoleName(
this,
"ImportedDILambdaRole",
this.config.LAMBDA_ROLE_NAME
this.config.LAMBDA_ROLE_NAME,
{
mutable: false
}
);
} else {
this.lambdaRole = new DILambdaRole(this, "DILambdaRole", {
Expand Down
5 changes: 4 additions & 1 deletion lib/osml/model_endpoint/me_test_endpoints.ts
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,10 @@ export class METestEndpoints extends Construct {
this.smRole = Role.fromRoleName(
this,
"ImportedMESageMakerRole",
this.config.SM_ROLE_NAME
this.config.SM_ROLE_NAME,
{
mutable: false
}
);
} else if (props.smRole) {
// Check if a SageMaker role was provided via properties
Expand Down
38 changes: 11 additions & 27 deletions lib/osml/model_runner/mr_dataplane.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*/

import { EcsIsoServiceAutoscaler } from "@cdklabs/cdk-enterprise-iac";
import { Duration, region_info, RemovalPolicy } from "aws-cdk-lib";
import { Duration, RemovalPolicy } from "aws-cdk-lib";
import {
BackupPlan,
BackupPlanRule,
Expand All @@ -22,7 +22,7 @@ import {
Protocol,
TaskDefinition
} from "aws-cdk-lib/aws-ecs";
import { Effect, IRole, PolicyStatement, Role } from "aws-cdk-lib/aws-iam";
import { IRole, Role } from "aws-cdk-lib/aws-iam";
import {
CfnStream,
Stream,
Expand Down Expand Up @@ -734,28 +734,6 @@ export class MRDataplane extends Construct {
}
);

if (props.account.isAdc) {
const partition: string = region_info.Fact.find(
props.account.region,
region_info.FactName.PARTITION
)!;

// Add permission to access fluent bit container
this.taskDefinition.addToExecutionRolePolicy(
new PolicyStatement({
effect: Effect.ALLOW,
actions: [
"ecr:BatchCheckLayerAvailability",
"ecr:GetDownloadUrlForLayer",
"ecr:BatchGetImage"
],
resources: [
`arn:${partition}:ecr:${props.account.region}:${props.account.id}:repository/aws-for-fluent-bit`
]
})
);
}

// Setup autoscaling management for model runner
this.buildAutoscaling(props);

Expand Down Expand Up @@ -983,7 +961,10 @@ export class MRDataplane extends Construct {
this.taskRole = Role.fromRoleName(
this,
"ImportedMRECSTaskRole",
this.config.ECS_TASK_ROLE_NAME
this.config.ECS_TASK_ROLE_NAME,
{
mutable: false
}
);
} else {
this.taskRole = new MRTaskRole(this, "MRECSTaskRole", {
Expand All @@ -993,10 +974,13 @@ export class MRDataplane extends Construct {
}

if (this.config.ECS_EXECUTION_ROLE_NAME != undefined) {
this.taskRole = Role.fromRoleName(
this.executionRole = Role.fromRoleName(
this,
"ImportedMRECSExecutionRole",
this.config.ECS_EXECUTION_ROLE_NAME
this.config.ECS_EXECUTION_ROLE_NAME,
{
mutable: false
}
);
} else {
this.executionRole = new MRExecutionRole(this, "MRECSExecutionRole", {
Expand Down
5 changes: 4 additions & 1 deletion lib/osml/osml_vpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,10 @@ export class OSMLVpc extends Construct {
this.flowLogRole = Role.fromRoleName(
this,
"ImportFlowLog",
this.config.IAM_FLOW_LOG_ROLE_NAME
this.config.IAM_FLOW_LOG_ROLE_NAME,
{
mutable: false
}
);
}

Expand Down
15 changes: 12 additions & 3 deletions lib/osml/tile_server/ts_dataplane.ts
Original file line number Diff line number Diff line change
Expand Up @@ -797,7 +797,10 @@ export class TSDataplane extends Construct {
this.taskRole = Role.fromRoleName(
this,
"ImportedTSECSTaskRole",
this.config.ECS_TASK_ROLE_NAME
this.config.ECS_TASK_ROLE_NAME,
{
mutable: false
}
);
} else {
this.taskRole = new TSTaskRole(this, "TSECSTaskRole", {
Expand All @@ -810,7 +813,10 @@ export class TSDataplane extends Construct {
this.lambdaRole = Role.fromRoleName(
this,
"ImportedTSLambdaRole",
this.config.LAMBDA_ROLE_NAME
this.config.LAMBDA_ROLE_NAME,
{
mutable: false
}
);
} else {
this.lambdaRole = new TSLambdaRole(this, "TSLambdaRole", {
Expand All @@ -823,7 +829,10 @@ export class TSDataplane extends Construct {
this.executionRole = Role.fromRoleName(
this,
"ImportedTSECSExecutionRole",
this.config.ECS_EXECUTION_ROLE_NAME
this.config.ECS_EXECUTION_ROLE_NAME,
{
mutable: false
}
);
} else {
this.executionRole = new TSExecutionRole(this, "TSECSExecutionRole", {
Expand Down

0 comments on commit 6e71475

Please sign in to comment.