Skip to content

Too-Wide Permissions for EnvManager Role - best way to scope-down? #5036

Open
@adrianosela

Description

@adrianosela

Background

The copilot env deploy and copilot svc deploy commands under the hood assume a copilot-managed AWS IAM Role (per environment) of the form ${COPILOT_APP_NAME}-${COPILOT_ENV_NAME}-EnvManagerRole

This means I need to give my CI/CD system access to sts:AssumeRole that role if I want to deploy my app with a CI system -- that's all good so far.

The problem is that the ...-EnvManagerRole by default is absurdly permissive and most of the permissions it has are not required to deploy my app...

For example, and of particular concern, the role has:

  • (A) Permission to manage (start, stop) any AWS ECS container in the account
  • (B) Permission to manage (create, delete, etc) any AWS CFN stack in the account
  • (C) Permission to manage (create/delete) any SSM parameter in the account
Click to see (A) portion of policy ``` { "Action": [ "ecs:ListAttributes", "ecs:ListTasks", "ecs:DescribeServices", "ecs:DescribeTaskSets", "ecs:ListContainerInstances", "ecs:DescribeContainerInstances", "ecs:DescribeTasks", "ecs:DescribeClusters", "ecs:UpdateService", "ecs:PutAttributes", "ecs:StartTelemetrySession", "ecs:StartTask", "ecs:StopTask", "ecs:ListServices", "ecs:ListTaskDefinitionFamilies", "ecs:DescribeTaskDefinition", "ecs:ListTaskDefinitions", "ecs:ListClusters", "ecs:RunTask" ], "Resource": "*", "Effect": "Allow", "Sid": "ECS" }, ```
Click to see (B) portion of policy ``` { "Action": [ "cloudformation:CancelUpdateStack", "cloudformation:CreateChangeSet", "cloudformation:CreateStack", "cloudformation:DeleteChangeSet", "cloudformation:DeleteStack", "cloudformation:Describe*", "cloudformation:DetectStackDrift", "cloudformation:DetectStackResourceDrift", "cloudformation:ExecuteChangeSet", "cloudformation:GetTemplate", "cloudformation:GetTemplateSummary", "cloudformation:UpdateStack", "cloudformation:UpdateTerminationProtection" ], "Resource": "*", "Effect": "Allow", "Sid": "CloudFormation" }, ```
Click to see (C) portion of policy ``` { "Action": [ "ssm:DeleteParameter", "ssm:DeleteParameters", "ssm:GetParameter", "ssm:GetParameters", "ssm:GetParametersByPath" ], "Resource": "*", "Effect": "Allow", "Sid": "SSM" }, ```

Question

I believe an IAM permissions boundary (policy) for all copilot-managed roles can be provided during copilot app init with the --permissions-boundary flag; but I already have a copilot app and I am hoping not to need to tear it down to recreate it with the more finer grained IAM perms.

I am wondering what the best way is to scope down this role ** WITH INFRA AS CODE ** e.g. cloudformation such that I can make the changes to the ** EXISTING COPILOT APP ** and if I ever accidentally destroy the app, I can recreate it with the same IAM policy / settings. i.e. I don't want to make the changes manually in the AWS console nor the CLI.

I am thinking of setting the permissions boundary to the roles by explicit role ARN in CFN -- is there a better way? Something perhaps I can add in my copilot manifests (after the app is already created)?

Any help is appreciated <3

Metadata

Metadata

Assignees

No one assigned

    Labels

    area/overrideIssues related to overrides.type/enhancementIssues that are improvements for existing features.type/featureIssues that are new feature requests.type/requestIssues that are created by customers.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions