AWS CodeStar Identity-Based Policy Examples - AWS CodeStar

AWS CodeStar Identity-Based Policy Examples

By default, IAM users and roles don't have permission to create or modify AWS CodeStar resources. They also can't perform tasks using the AWS Management Console, AWS CLI, or AWS API. An IAM administrator must create IAM policies that grant users and roles permission to perform specific API operations on the specified resources they need. The administrator must then attach those policies to the IAM users or groups that require those permissions.

To learn how to create an IAM identity-based policy using these example JSON policy documents, see Creating Policies on the JSON Tab in the IAM User Guide.

Policy Best Practices

Identity-based policies determine whether someone can create, access, or delete AWS CodeStar resources in your account. These actions can incur costs for your AWS account. When you create or edit identity-based policies, follow these guidelines and recommendations:

  • Get started with AWS managed policies and move toward least-privilege permissions – To get started granting permissions to your users and workloads, use the AWS managed policies that grant permissions for many common use cases. They are available in your AWS account. We recommend that you reduce permissions further by defining AWS customer managed policies that are specific to your use cases. For more information, see AWS managed policies or AWS managed policies for job functions in the IAM User Guide.

  • Apply least-privilege permissions – When you set permissions with IAM policies, grant only the permissions required to perform a task. You do this by defining the actions that can be taken on specific resources under specific conditions, also known as least-privilege permissions. For more information about using IAM to apply permissions, see Policies and permissions in IAM in the IAM User Guide.

  • Use conditions in IAM policies to further restrict access – You can add a condition to your policies to limit access to actions and resources. For example, you can write a policy condition to specify that all requests must be sent using SSL. You can also use conditions to grant access to service actions if they are used through a specific AWS service, such as AWS CloudFormation. For more information, see IAM JSON policy elements: Condition in the IAM User Guide.

  • Use IAM Access Analyzer to validate your IAM policies to ensure secure and functional permissions – IAM Access Analyzer validates new and existing policies so that the policies adhere to the IAM policy language (JSON) and IAM best practices. IAM Access Analyzer provides more than 100 policy checks and actionable recommendations to help you author secure and functional policies. For more information, see IAM Access Analyzer policy validation in the IAM User Guide.

  • Require multi-factor authentication (MFA) – If you have a scenario that requires IAM users or root users in your account, turn on MFA for additional security. To require MFA when API operations are called, add MFA conditions to your policies. For more information, see Configuring MFA-protected API access in the IAM User Guide.

For more information about best practices in IAM, see Security best practices in IAM in the IAM User Guide.

AWSCodeStarServiceRole Policy

The aws-codestar-service-role policy is attached to the service role that allows AWS CodeStar to perform actions with other services. The first time you sign in to AWS CodeStar, you create the service role. You only need to create it once. The policy is automatically attached to the service role after you create it.

{ "Version": "2012-10-17", "Statement": [ { "Sid": "ProjectEventRules", "Effect": "Allow", "Action": [ "events:PutTargets", "events:RemoveTargets", "events:PutRule", "events:DeleteRule", "events:DescribeRule" ], "Resource": [ "arn:aws:events:*:*:rule/awscodestar-*" ] }, { "Sid": "ProjectStack", "Effect": "Allow", "Action": [ "cloudformation:*Stack*", "cloudformation:CreateChangeSet", "cloudformation:ExecuteChangeSet", "cloudformation:DeleteChangeSet", "cloudformation:GetTemplate" ], "Resource": [ "arn:aws:cloudformation:*:*:stack/awscodestar-*", "arn:aws:cloudformation:*:*:stack/awseb-*", "arn:aws:cloudformation:*:*:stack/aws-cloud9-*", "arn:aws:cloudformation:*:aws:transform/CodeStar*" ] }, { "Sid": "ProjectStackTemplate", "Effect": "Allow", "Action": [ "cloudformation:GetTemplateSummary", "cloudformation:DescribeChangeSet" ], "Resource": "*" }, { "Sid": "ProjectQuickstarts", "Effect": "Allow", "Action": [ "s3:GetObject" ], "Resource": [ "arn:aws:s3:::awscodestar-*/*" ] }, { "Sid": "ProjectS3Buckets", "Effect": "Allow", "Action": [ "s3:*" ], "Resource": [ "arn:aws:s3:::aws-codestar-*", "arn:aws:s3:::elasticbeanstalk-*" ] }, { "Sid": "ProjectServices", "Effect": "Allow", "Action": [ "codestar:*", "codecommit:*", "codepipeline:*", "codedeploy:*", "codebuild:*", "autoscaling:*", "cloudwatch:Put*", "ec2:*", "elasticbeanstalk:*", "elasticloadbalancing:*", "iam:ListRoles", "logs:*", "sns:*", "cloud9:CreateEnvironmentEC2", "cloud9:DeleteEnvironment", "cloud9:DescribeEnvironment*", "cloud9:ListEnvironments" ], "Resource": "*" }, { "Sid": "ProjectWorkerRoles", "Effect": "Allow", "Action": [ "iam:AttachRolePolicy", "iam:CreateRole", "iam:DeleteRole", "iam:DeleteRolePolicy", "iam:DetachRolePolicy", "iam:GetRole", "iam:PassRole", "iam:GetRolePolicy", "iam:PutRolePolicy", "iam:SetDefaultPolicyVersion", "iam:CreatePolicy", "iam:DeletePolicy", "iam:AddRoleToInstanceProfile", "iam:CreateInstanceProfile", "iam:DeleteInstanceProfile", "iam:RemoveRoleFromInstanceProfile" ], "Resource": [ "arn:aws:iam::*:role/CodeStarWorker*", "arn:aws:iam::*:policy/CodeStarWorker*", "arn:aws:iam::*:instance-profile/awscodestar-*" ] }, { "Sid": "ProjectTeamMembers", "Effect": "Allow", "Action": [ "iam:AttachUserPolicy", "iam:DetachUserPolicy" ], "Resource": "*", "Condition": { "ArnEquals": { "iam:PolicyArn": [ "arn:aws:iam::*:policy/CodeStar_*" ] } } }, { "Sid": "ProjectRoles", "Effect": "Allow", "Action": [ "iam:CreatePolicy", "iam:DeletePolicy", "iam:CreatePolicyVersion", "iam:DeletePolicyVersion", "iam:ListEntitiesForPolicy", "iam:ListPolicyVersions", "iam:GetPolicy", "iam:GetPolicyVersion" ], "Resource": [ "arn:aws:iam::*:policy/CodeStar_*" ] }, { "Sid": "InspectServiceRole", "Effect": "Allow", "Action": [ "iam:ListAttachedRolePolicies" ], "Resource": [ "arn:aws:iam::*:role/aws-codestar-service-role", "arn:aws:iam::*:role/service-role/aws-codestar-service-role" ] }, { "Sid": "IAMLinkRole", "Effect": "Allow", "Action": [ "iam:CreateServiceLinkedRole" ], "Resource": "*", "Condition": { "StringEquals": { "iam:AWSServiceName": "cloud9.amazonaws.com" } } }, { "Sid": "DescribeConfigRuleForARN", "Effect": "Allow", "Action": [ "config:DescribeConfigRules" ], "Resource": [ "*" ] }, { "Sid": "ProjectCodeStarConnections", "Effect": "Allow", "Action": [ "codestar-connections:UseConnection", "codestar-connections:GetConnection" ], "Resource": "*" }, { "Sid": "ProjectCodeStarConnectionsPassConnections", "Effect": "Allow", "Action": "codestar-connections:PassConnection", "Resource": "*", "Condition": { "StringEqualsIfExists": { "codestar-connections:PassedToService": "codepipeline.amazonaws.com" } } } ] }

AWSCodeStarFullAccess Policy

In the Setting Up AWS CodeStar instructions, you attached a policy named AWSCodeStarFullAccess to your IAM user. This policy statement allows the user to perform all available actions in AWS CodeStar with all available AWS CodeStar resources associated with the AWS account. This includes creating and deleting projects. The following example is a snippet of a representative AWSCodeStarFullAccess policy. The actual policy differs depending on the template you select when you start a new AWS CodeStar project.

{ "Version": "2012-10-17", "Statement": [ { "Sid": "CodeStarEC2", "Effect": "Allow", "Action": [ "codestar:*", "ec2:DescribeKeyPairs", "ec2:DescribeVpcs", "ec2:DescribeSubnets" ], "Resource": "*" }, { "Sid": "CodeStarCF", "Effect": "Allow", "Action": [ "cloudformation:DescribeStack*", "cloudformation:GetTemplateSummary" ], "Resource": [ "arn:aws:cloudformation:*:*:stack/awscodestar-*" ] } ] }

You might not want to give all users this much access. Instead, you can add project-level permissions using project roles managed by AWS CodeStar. The roles grant specific levels of access to AWS CodeStar projects and are named as follows:

  • Owner

  • Contributor

  • Viewer

AWS CodeStar Owner Role Policy

The AWS CodeStar owner role policy allows a user to perform all actions in an AWS CodeStar project with no restrictions. AWS CodeStar applies the CodeStar_project-id_Owner policy to project team members with the owner access level..

... { "Effect": "Allow", "Action": [ ... "codestar:*", ... ], "Resource": [ "arn:aws:codestar:us-east-2:111111111111:project/project-id", "arn:aws:iam::account-id:policy/CodeStar_project-id_Owner" ] }, { "Effect": "Allow", "Action": [ "codestar:DescribeUserProfile", "codestar:ListProjects", "codestar:ListUserProfiles", "codestar:VerifyServiceRole", ... ], "Resource": [ "*" ] }, { "Effect": "Allow", "Action": [ "codestar:*UserProfile", ... ], "Resource": [ "arn:aws:iam::account-id:user/user-name" ] } ...

AWS CodeStar Contributor Role Policy

The AWS CodeStar contributor role policy allows a user to contribute to the project and change the project dashboard.AWS CodeStar applies the CodeStar_project-id_Contributor policy to project team members with the contributor access level. Users with contributor access can contribute to the project and change the project dashboard, but cannot add or remove team members.

... { "Effect": "Allow", "Action": [ ... "codestar:Describe*", "codestar:Get*", "codestar:List*", "codestar:PutExtendedAccess", ... ], "Resource": [ "arn:aws:codestar:us-east-2:111111111111:project/project-id", "arn:aws:iam::account-id:policy/CodeStar_project-id_Contributor" ] }, { "Effect": "Allow", "Action": [ "codestar:DescribeUserProfile", "codestar:ListProjects", "codestar:ListUserProfiles", "codestar:VerifyServiceRole", ... ], "Resource": [ "*" ] }, { "Effect": "Allow", "Action": [ "codestar:*UserProfile", ... ], "Resource": [ "arn:aws:iam::account-id:user/user-name" ] } ...

AWS CodeStar Viewer Role Policy

The AWS CodeStar viewer role policy allows a user to view a project in AWS CodeStar. AWS CodeStar applies the CodeStar_project-id_Viewer policy to project team members with the viewer access level. Users with viewer access can view a project in AWS CodeStar, but not change its resources or add or remove team members.

... { "Effect": "Allow", "Action": [ ... "codestar:Describe*", "codestar:Get*", "codestar:List*", ... ], "Resource": [ "arn:aws:codestar:us-east-2:111111111111:project/project-id", "arn:aws:iam::account-id:policy/CodeStar_project-id_Viewer" ] }, { "Effect": "Allow", "Action": [ "codestar:DescribeUserProfile", "codestar:ListProjects", "codestar:ListUserProfiles", "codestar:VerifyServiceRole", ... ], "Resource": [ "*" ] }, { "Effect": "Allow", "Action": [ "codestar:*UserProfile", ... ], "Resource": [ "arn:aws:iam::account-id:user/user-name" ] } ...

AWS CodeStar Toolchain Worker Role Policy (After December 6, 2018 PDT)

For AWS CodeStar projects created after December 6, 2018 PDT, AWS CodeStar creates an inline policy for a worker role that creates resources for your project in other AWS services. The contents of the policy depend on the type of project you are creating. The following policy is an example. For more information, see IAM Policies for Worker Roles.

{ "Statement": [ { "Action": [ "s3:GetObject", "s3:GetObjectVersion", "s3:GetBucketVersioning", "s3:PutObject*", "codecommit:CancelUploadArchive", "codecommit:GetBranch", "codecommit:GetCommit", "codecommit:GetUploadArchiveStatus", "codecommit:GitPull", "codecommit:UploadArchive", "codebuild:StartBuild", "codebuild:BatchGetBuilds", "codebuild:StopBuild", "logs:CreateLogGroup", "logs:CreateLogStream", "logs:PutLogEvents", "cloudformation:DescribeStacks", "cloudformation:DescribeChangeSet", "cloudformation:CreateChangeSet", "cloudformation:DeleteChangeSet", "cloudformation:ExecuteChangeSet", "codepipeline:StartPipelineExecution", "lambda:ListFunctions", "lambda:InvokeFunction", "sns:Publish" ], "Resource": [ "*" ], "Effect": "Allow" }, { "Action": [ "iam:PassRole" ], "Resource": [ "*" ], "Effect": "Allow" }, { "Action": [ "kms:GenerateDataKey*", "kms:Encrypt", "kms:Decrypt" ], "Resource": [ "*" ], "Effect": "Allow" } ] }

AWS CloudFormation Worker Role Policy

For AWS CodeStar projects created after December 6, 2018 PDT, AWS CodeStar creates an inline policy for a worker role that creates AWS CloudFormation resources for your AWS CodeStar project. The contents of the policy depend on the type of resources required for your project. The following policy is an example. For more information, see IAM Policies for Worker Roles.

{ { "Statement": [ { "Action": [ "s3:PutObject", "s3:GetObject", "s3:GetObjectVersion" ], "Resource": [ "arn:aws:s3:::aws-codestar-region-id-account-id-project-id", "arn:aws:s3:::aws-codestar-region-id-account-id-project-id/*" ], "Effect": "Allow" }, { "Action": [ "apigateway:DELETE", "apigateway:GET", "apigateway:PATCH", "apigateway:POST", "apigateway:PUT", "codedeploy:CreateApplication", "codedeploy:CreateDeployment", "codedeploy:CreateDeploymentConfig", "codedeploy:CreateDeploymentGroup", "codedeploy:DeleteApplication", "codedeploy:DeleteDeployment", "codedeploy:DeleteDeploymentConfig", "codedeploy:DeleteDeploymentGroup", "codedeploy:GetDeployment", "codedeploy:GetDeploymentConfig", "codedeploy:GetDeploymentGroup", "codedeploy:RegisterApplicationRevision", "codestar:SyncResources", "config:DeleteConfigRule", "config:DescribeConfigRules", "config:ListTagsForResource", "config:PutConfigRule", "config:TagResource", "config:UntagResource", "dynamodb:CreateTable", "dynamodb:DeleteTable", "dynamodb:DescribeContinuousBackups", "dynamodb:DescribeTable", "dynamodb:DescribeTimeToLive", "dynamodb:ListTagsOfResource", "dynamodb:TagResource", "dynamodb:UntagResource", "dynamodb:UpdateContinuousBackups", "dynamodb:UpdateTable", "dynamodb:UpdateTimeToLive", "ec2:AssociateIamInstanceProfile", "ec2:AttachVolume", "ec2:CreateSecurityGroup", "ec2:createTags", "ec2:DescribeIamInstanceProfileAssociations", "ec2:DescribeInstances", "ec2:DescribeSecurityGroups", "ec2:DescribeSubnets", "ec2:DetachVolume", "ec2:DisassociateIamInstanceProfile", "ec2:ModifyInstanceAttribute", "ec2:ModifyInstanceCreditSpecification", "ec2:ModifyInstancePlacement", "ec2:MonitorInstances", "ec2:ReplaceIamInstanceProfileAssociation", "ec2:RunInstances", "ec2:StartInstances", "ec2:StopInstances", "ec2:TerminateInstances", "events:DeleteRule", "events:DescribeRule", "events:ListTagsForResource", "events:PutRule", "events:PutTargets", "events:RemoveTargets", "events:TagResource", "events:UntagResource", "kinesis:AddTagsToStream", "kinesis:CreateStream", "kinesis:DecreaseStreamRetentionPeriod", "kinesis:DeleteStream", "kinesis:DescribeStream", "kinesis:IncreaseStreamRetentionPeriod", "kinesis:RemoveTagsFromStream", "kinesis:StartStreamEncryption", "kinesis:StopStreamEncryption", "kinesis:UpdateShardCount", "lambda:CreateAlias", "lambda:CreateFunction", "lambda:DeleteAlias", "lambda:DeleteFunction", "lambda:DeleteFunctionConcurrency", "lambda:GetFunction", "lambda:GetFunctionConfiguration", "lambda:ListTags", "lambda:ListVersionsByFunction", "lambda:PublishVersion", "lambda:PutFunctionConcurrency", "lambda:TagResource", "lambda:UntagResource", "lambda:UpdateAlias", "lambda:UpdateFunctionCode", "lambda:UpdateFunctionConfiguration", "s3:CreateBucket", "s3:DeleteBucket", "s3:DeleteBucketWebsite", "s3:PutAccelerateConfiguration", "s3:PutAnalyticsConfiguration", "s3:PutBucketAcl", "s3:PutBucketCORS", "s3:PutBucketLogging", "s3:PutBucketNotification", "s3:PutBucketPublicAccessBlock", "s3:PutBucketVersioning", "s3:PutBucketWebsite", "s3:PutEncryptionConfiguration", "s3:PutInventoryConfiguration", "s3:PutLifecycleConfiguration", "s3:PutMetricsConfiguration", "s3:PutReplicationConfiguration", "sns:CreateTopic", "sns:DeleteTopic", "sns:GetTopicAttributes", "sns:ListSubscriptionsByTopic", "sns:ListTopics", "sns:SetSubscriptionAttributes", "sns:Subscribe", "sns:Unsubscribe", "sqs:CreateQueue", "sqs:DeleteQueue", "sqs:GetQueueAttributes", "sqs:GetQueueUrl", "sqs:ListQueueTags", "sqs:TagQueue", "sqs:UntagQueue" ], "Resource": "*", "Effect": "Allow" }, { "Action": [ "lambda:AddPermission", "lambda:RemovePermission" ], "Resource": [ "arn:aws:lambda:region-id:account-id:function:awscodestar-*" ], "Effect": "Allow" }, { "Action": [ "iam:PassRole" ], "Resource": [ "arn:aws:iam::account-id:role/CodeStar-project-id*" ], "Effect": "Allow" }, { "Condition": { "StringEquals": { "iam:PassedToService": "codedeploy.amazonaws.com" } }, "Action": [ "iam:PassRole" ], "Resource": [ "arn:aws:iam::account-id:role/CodeStarWorker-project-id-CodeDeploy" ], "Effect": "Allow" }, { "Action": [ "cloudformation:CreateChangeSet" ], "Resource": [ "arn:aws:cloudformation:region-id:aws:transform/Serverless-2016-10-31", "arn:aws:cloudformation:region-id:aws:transform/CodeStar" ], "Effect": "Allow" }, { "Action": [ "iam:CreateServiceLinkedRole", "iam:GetRole", "iam:DeleteRole", "iam:DeleteUser" ], "Resource": "*", "Effect": "Allow" }, { "Condition": { "StringEquals": { "iam:PermissionsBoundary": "arn:aws:iam::account-id:policy/CodeStar_project-id_PermissionsBoundary" } }, "Action": [ "iam:AttachRolePolicy", "iam:AttachUserPolicy", "iam:CreateRole", "iam:CreateUser", "iam:DeleteRolePolicy", "iam:DeleteUserPolicy", "iam:DetachUserPolicy", "iam:DetachRolePolicy", "iam:PutUserPermissionsBoundary", "iam:PutRolePermissionsBoundary" ], "Resource": "*", "Effect": "Allow" }, { "Action": [ "kms:CreateKey", "kms:CreateAlias", "kms:DeleteAlias", "kms:DisableKey", "kms:EnableKey", "kms:UpdateAlias", "kms:TagResource", "kms:UntagResource" ], "Resource": "*", "Effect": "Allow" }, { "Condition": { "StringEquals": { "ssm:ResourceTag/awscodestar:projectArn": "arn:aws:codestar:project-id:account-id:project/project-id" } }, "Action": [ "ssm:GetParameter*" ], "Resource": "*", "Effect": "Allow" } ] }

AWS CloudFormation Worker Role Policy (Before December 6, 2018 PDT)

If your AWS CodeStar project was created before December 6, 2018 PDT, AWS CodeStar created an inline policy for an AWS CloudFormation worker role. The following policy statement is an example.

{ "Statement": [ { "Action": [ "s3:PutObject", "s3:GetObject", "s3:GetObjectVersion" ], "Resource": [ "arn:aws:s3:::aws-codestar-us-east-1-account-id-project-id-pipe", "arn:aws:s3:::aws-codestar-us-east-1-account-id-project-id-pipe/*" ], "Effect": "Allow" }, { "Action": [ "codestar:SyncResources", "lambda:CreateFunction", "lambda:DeleteFunction", "lambda:AddPermission", "lambda:UpdateFunction", "lambda:UpdateFunctionCode", "lambda:GetFunction", "lambda:GetFunctionConfiguration", "lambda:UpdateFunctionConfiguration", "lambda:RemovePermission", "lambda:listTags", "lambda:TagResource", "lambda:UntagResource", "apigateway:*", "dynamodb:CreateTable", "dynamodb:DeleteTable", "dynamodb:DescribeTable", "kinesis:CreateStream", "kinesis:DeleteStream", "kinesis:DescribeStream", "sns:CreateTopic", "sns:DeleteTopic", "sns:ListTopics", "sns:GetTopicAttributes", "sns:SetTopicAttributes", "s3:CreateBucket", "s3:DeleteBucket", "config:DescribeConfigRules", "config:PutConfigRule", "config:DeleteConfigRule", "ec2:*", "autoscaling:*", "elasticloadbalancing:*", "elasticbeanstalk:*" ], "Resource": "*", "Effect": "Allow" }, { "Action": [ "iam:PassRole" ], "Resource": [ "arn:aws:iam::account-id:role/CodeStarWorker-project-id-Lambda" ], "Effect": "Allow" }, { "Action": [ "cloudformation:CreateChangeSet" ], "Resource": [ "arn:aws:cloudformation:us-east-1:aws:transform/Serverless-2016-10-31", "arn:aws:cloudformation:us-east-1:aws:transform/CodeStar" ], "Effect": "Allow" } ] }

AWS CodePipeline Worker Role Policy (Before December 6, 2018 PDT)

If your AWS CodeStar project was created before December 6, 2018 PDT, AWS CodeStar created an inline policy for a CodePipeline worker role. The following policy statement is an example.

{ "Statement": [ { "Action": [ "s3:GetObject", "s3:GetObjectVersion", "s3:GetBucketVersioning", "s3:PutObject" ], "Resource": [ "arn:aws:s3:::aws-codestar-us-east-1-account-id-project-id-pipe", "arn:aws:s3:::aws-codestar-us-east-1-account-id-project-id-pipe/*" ], "Effect": "Allow" }, { "Action": [ "codecommit:CancelUploadArchive", "codecommit:GetBranch", "codecommit:GetCommit", "codecommit:GetUploadArchiveStatus", "codecommit:UploadArchive" ], "Resource": [ "arn:aws:codecommit:us-east-1:account-id:project-id" ], "Effect": "Allow" }, { "Action": [ "codebuild:StartBuild", "codebuild:BatchGetBuilds", "codebuild:StopBuild" ], "Resource": [ "arn:aws:codebuild:us-east-1:account-id:project/project-id" ], "Effect": "Allow" }, { "Action": [ "cloudformation:DescribeStacks", "cloudformation:DescribeChangeSet", "cloudformation:CreateChangeSet", "cloudformation:DeleteChangeSet", "cloudformation:ExecuteChangeSet" ], "Resource": [ "arn:aws:cloudformation:us-east-1:account-id:stack/awscodestar-project-id-lambda/*" ], "Effect": "Allow" }, { "Action": [ "iam:PassRole" ], "Resource": [ "arn:aws:iam::account-id:role/CodeStarWorker-project-id-CloudFormation" ], "Effect": "Allow" } ] }

AWS CodeBuild Worker Role Policy (Before December 6, 2018 PDT)

If your AWS CodeStar project was created before December 6, 2018 PDT, AWS CodeStar created an inline policy for an CodeBuild worker role. The following policy statement is an example.

{ "Statement": [ { "Action": [ "logs:CreateLogGroup", "logs:CreateLogStream", "logs:PutLogEvents" ], "Resource": "*", "Effect": "Allow" }, { "Action": [ "s3:PutObject", "s3:GetObject", "s3:GetObjectVersion" ], "Resource": [ "arn:aws:s3:::aws-codestar-us-east-1-account-id-project-id-pipe", "arn:aws:s3:::aws-codestar-us-east-1-account-id-project-id-pipe/*", "arn:aws:s3:::aws-codestar-us-east-1-account-id-project-id-app", "arn:aws:s3:::aws-codestar-us-east-1-account-id-project-id-app/*" ], "Effect": "Allow" }, { "Action": [ "codecommit:GitPull" ], "Resource": [ "arn:aws:codecommit:us-east-1:account-id:project-id" ], "Effect": "Allow" }, { "Action": [ "kms:GenerateDataKey*", "kms:Encrypt", "kms:Decrypt" ], "Resource": [ "arn:aws:kms:us-east-1:account-id:alias/aws/s3" ], "Effect": "Allow" } ] }

Amazon CloudWatch Events Worker Role Policy (Before December 6, 2018 PDT)

If your AWS CodeStar project was created before December 6, 2018 PDT, AWS CodeStar created an inline policy for an CloudWatch Events worker role. The following policy statement is an example.

{ "Statement": [ { "Action": [ "codepipeline:StartPipelineExecution" ], "Resource": [ "arn:aws:codepipeline:us-east-1:account-id:project-id-Pipeline" ], "Effect": "Allow" } ] }

AWS CodeStar Permissions Boundary Policy

If you create an AWS CodeStar project after December 6, 2018 PDT, AWS CodeStar creates a permissions boundary policy for your project. This policy prevents the escalation of privileges to resources outside the project. It is a dynamic policy that updates as the project evolves. The contents of the policy depend on the type of project you are creating. The following policy is an example. For more information, see IAM Permissions Boundary.

{ "Version": "2012-10-17", "Statement": [ { "Sid": "1", "Effect": "Allow", "Action": [ "s3:GetObject" ], "Resource": [ "arn:aws:s3:::*/AWSLogs/*/Config/*" ] }, { "Sid": "2", "Effect": "Allow", "Action": [ "*" ], "Resource": [ "arn:aws:codestar:us-east-1:account-id:project/project-id", "arn:aws:cloudformation:us-east-1:account-id:stack/awscodestar-project-id-lambda/eefbbf20-c1d9-11e8-8a3a-500c28b4e461", "arn:aws:cloudformation:us-east-1:account-id:stack/awscodestar-project-id/4b80b3f0-c1d9-11e8-8517-500c28b236fd", "arn:aws:codebuild:us-east-1:account-id:project/project-id", "arn:aws:codecommit:us-east-1:account-id:project-id", "arn:aws:codepipeline:us-east-1:account-id:project-id-Pipeline", "arn:aws:execute-api:us-east-1:account-id:7rlst5mrgi", "arn:aws:iam::account-id:role/CodeStarWorker-project-id-CloudFormation", "arn:aws:iam::account-id:role/CodeStarWorker-project-id-CloudWatchEventRule", "arn:aws:iam::account-id:role/CodeStarWorker-project-id-CodeBuild", "arn:aws:iam::account-id:role/CodeStarWorker-project-id-CodePipeline", "arn:aws:iam::account-id:role/CodeStarWorker-project-id-Lambda", "arn:aws:lambda:us-east-1:account-id:function:awscodestar-project-id-lambda-GetHelloWorld-KFKTXYNH9573", "arn:aws:s3:::aws-codestar-us-east-1-account-id-project-id-app", "arn:aws:s3:::aws-codestar-us-east-1-account-id-project-id-pipe" ] }, { "Sid": "3", "Effect": "Allow", "Action": [ "apigateway:GET", "config:Describe*", "config:Get*", "config:List*", "config:Put*", "logs:CreateLogGroup", "logs:CreateLogStream", "logs:DescribeLogGroups", "logs:PutLogEvents" ], "Resource": [ "*" ] } ] }

Listing Resources for a Project

In this example, you want to grant a specified IAM user in your AWS account access to list the resources of an AWS CodeStar project.

{ "Version": "2012-10-17", "Statement" : [ { "Effect" : "Allow", "Action" : [ "codestar:ListResources", ], "Resource" : "arn:aws:codestar:us-east-2:project/my-first-projec" } ] }

Using the AWS CodeStar Console

No specific permissions are required to access the AWS CodeStar console, but you can't do anything useful unless you have either the AWSCodeStarFullAccess policy or one of the AWS CodeStar project-level role: Owner, Contributor, or Viewer. For more information on AWSCodeStarFullAccess, see AWSCodeStarFullAccess Policy. For more information on the project-level policies, see IAM Policies for Team Members.

You don't need to allow minimum console permissions for users that are making calls only to the AWS CLI or the AWS API. Instead, allow access to only the actions that match the API operation that you're trying to perform.

Allow Users to View Their Own Permissions

This example shows how you might create a policy that allows IAM users to view the inline and managed policies that are attached to their user identity. This policy includes permissions to complete this action on the console or programmatically using the AWS CLI or AWS API.

{ "Version": "2012-10-17", "Statement": [ { "Sid": "ViewOwnUserInfo", "Effect": "Allow", "Action": [ "iam:GetUserPolicy", "iam:ListGroupsForUser", "iam:ListAttachedUserPolicies", "iam:ListUserPolicies", "iam:GetUser" ], "Resource": ["arn:aws:iam::*:user/${aws:username}"] }, { "Sid": "NavigateInConsole", "Effect": "Allow", "Action": [ "iam:GetGroupPolicy", "iam:GetPolicyVersion", "iam:GetPolicy", "iam:ListAttachedGroupPolicies", "iam:ListGroupPolicies", "iam:ListPolicyVersions", "iam:ListPolicies", "iam:ListUsers" ], "Resource": "*" } ] }

Updating an AWS CodeStar Project

In this example, you want to grant a specified IAM user in your AWS account access to edit the attributes of an AWS CodeStar project, such as its project description.

{ "Version": "2012-10-17", "Statement" : [ { "Effect" : "Allow", "Action" : [ "codestar:UpdateProject" ], "Resource" : "arn:aws:codestar:us-east-2:project/my-first-projec" } ] }

Adding a Team Member to a Project

In this example, you want to grant a specified IAM user the ability to add team members to an AWS CodeStar project with the project ID my-first-projec, but to explicitly deny that user the ability to remove team members:

{ "Version": "2012-10-17", "Statement" : [ { "Effect" : "Allow", "Action" : [ "codestar:AssociateTeamMember", ], "Resource" : "arn:aws:codestar:us-east-2:project/my-first-projec" }, { "Effect" : "Deny", "Action" : [ "codestar:DisassociateTeamMember", ], "Resource" : "arn:aws:codestar:us-east-2:project/my-first-projec" } ] ] }

Listing User Profiles Associated with an AWS Account

In this example, you allow an IAM user who has this policy attached to list all AWS CodeStar user profiles associated with an AWS account:

{ "Version": "2012-10-17", "Statement" : [ { "Effect" : "Allow", "Action" : [ "codestar:ListUserProfiles", ], "Resource" : "*" } ] }

Viewing AWS CodeStar Projects Based on Tags

You can use conditions in your identity-based policy to control access to AWS CodeStar projects based on tags. This example shows how you might create a policy that allows viewing a project. However, permission is granted only if the Project tag Owner has the value of that user's user name. This policy also grants the permissions necessary to complete this action on the console.

{ "Version": "2012-10-17", "Statement": [ { "Sid": "ListProjectsInConsole", "Effect": "Allow", "Action": "codestar:ListProjects", "Resource": "*" }, { "Sid": "ViewProjectIfOwner", "Effect": "Allow", "Action": "codestar:GetProject, "Resource": "arn:aws:codestar:*:*:project/*", "Condition": { "StringEquals": {"codestar:ResourceTag/Owner": "${aws:username}"} } } ] }

You can attach this policy to the IAM users in your account. If a user named richard-roe attempts to view an AWS CodeStar project, the project must be tagged Owner=richard-roe or owner=richard-roe. Otherwise he is denied access. The condition tag key Owner matches both Owner and owner because condition key names are not case-sensitive. For more information, see IAM JSON Policy Elements: Condition in the IAM User Guide.

AWS CodeStarupdates to AWS managed policies

View details about updates to AWS managed policies for AWS CodeStar since this service began tracking these changes. For automatic alerts about changes to this page, subscribe to the RSS feed on the AWS CodeStar Document history page.

Change Description Date

AWSCodeStarServiceRole Policy – Update the AWSCodeStarServiceRole policy

The policy for the AWS CodeStar service role has been updated to correct redundant actions in the policy statement.

The service role policy allows the AWS CodeStar service to perform actions on your behalf.

September 23, 2021

AWS CodeStar started tracking changes

AWS CodeStar started tracking changes for its AWS managed policies.

September 23, 2021