

# Identity and access management for AWS CodeDeploy
<a name="security-iam"></a>

AWS Identity and Access Management (IAM) is an AWS service that helps an administrator securely control access to AWS resources. IAM administrators control who can be *authenticated* (signed in) and *authorized* (have permissions) to use CodeDeploy resources. IAM is an AWS service that you can use with no additional charge.

**Topics**
+ [Audience](#security_iam_audience)
+ [Authenticating with identities](#security_iam_authentication)
+ [Managing access using policies](#security_iam_access-manage)
+ [How AWS CodeDeploy works with IAM](security_iam_service-with-iam.md)
+ [AWS managed (predefined) policies for CodeDeploy](managed-policies.md)
+ [CodeDeploy updates to AWS managed policies](managed-policies-updates.md)
+ [AWS CodeDeploy identity-based policy examples](security_iam_id-based-policy-examples.md)
+ [Troubleshooting AWS CodeDeploy identity and access](security_iam_troubleshoot.md)
+ [CodeDeploy permissions reference](auth-and-access-control-permissions-reference.md)
+ [Cross-service confused deputy prevention](security_confused_deputy.md)

## Audience
<a name="security_iam_audience"></a>

How you use AWS Identity and Access Management (IAM) differs based on your role:
+ **Service user** - request permissions from your administrator if you cannot access features (see [Troubleshooting AWS CodeDeploy identity and access](security_iam_troubleshoot.md))
+ **Service administrator** - determine user access and submit permission requests (see [How AWS CodeDeploy works with IAM](security_iam_service-with-iam.md))
+ **IAM administrator** - write policies to manage access (see [AWS CodeDeploy identity-based policy examples](security_iam_id-based-policy-examples.md))

## Authenticating with identities
<a name="security_iam_authentication"></a>

Authentication is how you sign in to AWS using your identity credentials. You must be authenticated as the AWS account root user, an IAM user, or by assuming an IAM role.

You can sign in as a federated identity using credentials from an identity source like AWS IAM Identity Center (IAM Identity Center), single sign-on authentication, or Google/Facebook credentials. For more information about signing in, see [How to sign in to your AWS account](https://docs.aws.amazon.com/signin/latest/userguide/how-to-sign-in.html) in the *AWS Sign-In User Guide*.

For programmatic access, AWS provides an SDK and CLI to cryptographically sign requests. For more information, see [AWS Signature Version 4 for API requests](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_sigv.html) in the *IAM User Guide*.

### AWS account root user
<a name="security_iam_authentication-rootuser"></a>

 When you create an AWS account, you begin with one sign-in identity called the AWS account *root user* that has complete access to all AWS services and resources. We strongly recommend that you don't use the root user for everyday tasks. For tasks that require root user credentials, see [Tasks that require root user credentials](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_root-user.html#root-user-tasks) in the *IAM User Guide*. 

### Users and groups
<a name="security_iam_authentication-iamuser"></a>

An *[IAM user](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_users.html)* is an identity with specific permissions for a single person or application. We recommend using temporary credentials instead of IAM users with long-term credentials. For more information, see [Require human users to use federation with an identity provider to access AWS using temporary credentials](https://docs.aws.amazon.com/IAM/latest/UserGuide/best-practices.html#bp-users-federation-idp) in the *IAM User Guide*.

An [https://docs.aws.amazon.com/IAM/latest/UserGuide/id_groups.html](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_groups.html) specifies a collection of IAM users and makes permissions easier to manage for large sets of users. For more information, see [Use cases for IAM users](https://docs.aws.amazon.com/IAM/latest/UserGuide/gs-identities-iam-users.html) in the *IAM User Guide*.

### IAM roles
<a name="security_iam_authentication-iamrole"></a>

An *[IAM role](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles.html)* is an identity with specific permissions that provides temporary credentials. You can assume a role by [switching from a user to an IAM role (console)](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_use_switch-role-console.html) or by calling an AWS CLI or AWS API operation. For more information, see [Methods to assume a role](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_manage-assume.html) in the *IAM User Guide*.

IAM roles are useful for federated user access, temporary IAM user permissions, cross-account access, cross-service access, and applications running on Amazon EC2. For more information, see [Cross account resource access in IAM](https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies-cross-account-resource-access.html) in the *IAM User Guide*.

## Managing access using policies
<a name="security_iam_access-manage"></a>

You control access in AWS by creating policies and attaching them to AWS identities or resources. A policy defines permissions when associated with an identity or resource. AWS evaluates these policies when a principal makes a request. Most policies are stored in AWS as JSON documents. For more information about JSON policy documents, see [Overview of JSON policies](https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies.html#access_policies-json) in the *IAM User Guide*.

Using policies, administrators specify who has access to what by defining which **principal** can perform **actions** on what **resources**, and under what **conditions**.

By default, users and roles have no permissions. An IAM administrator creates IAM policies and adds them to roles, which users can then assume. IAM policies define permissions regardless of the method used to perform the operation.

### Identity-based policies
<a name="security_iam_access-manage-id-based-policies"></a>

Identity-based policies are JSON permissions policy documents that you attach to an identity (user, group, or role). These policies control what actions identities can perform, on which resources, and under what conditions. To learn how to create an identity-based policy, see [Define custom IAM permissions with customer managed policies](https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies_create.html) in the *IAM User Guide*.

Identity-based policies can be *inline policies* (embedded directly into a single identity) or *managed policies* (standalone policies attached to multiple identities). To learn how to choose between managed and inline policies, see [Choose between managed policies and inline policies](https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies-choosing-managed-or-inline.html) in the *IAM User Guide*.

### Other policy types
<a name="security_iam_access-manage-other-policies"></a>

AWS supports additional policy types that can set the maximum permissions granted by more common policy types:
+ **Permissions boundaries** – Set the maximum permissions that an identity-based policy can grant to an IAM entity. For more information, see [Permissions boundaries for IAM entities](https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies_boundaries.html) in the *IAM User Guide*.
+ **Service control policies (SCPs)** – Specify the maximum permissions for an organization or organizational unit in AWS Organizations. For more information, see [Service control policies](https://docs.aws.amazon.com/organizations/latest/userguide/orgs_manage_policies_scps.html) in the *AWS Organizations User Guide*.
+ **Resource control policies (RCPs)** – Set the maximum available permissions for resources in your accounts. For more information, see [Resource control policies (RCPs)](https://docs.aws.amazon.com/organizations/latest/userguide/orgs_manage_policies_rcps.html) in the *AWS Organizations User Guide*.
+ **Session policies** – Advanced policies passed as a parameter when creating a temporary session for a role or federated user. For more information, see [Session policies](https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies.html#policies_session) in the *IAM User Guide*.

### Multiple policy types
<a name="security_iam_access-manage-multiple-policies"></a>

When multiple types of policies apply to a request, the resulting permissions are more complicated to understand. To learn how AWS determines whether to allow a request when multiple policy types are involved, see [Policy evaluation logic](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_evaluation-logic.html) in the *IAM User Guide*.

# How AWS CodeDeploy works with IAM
<a name="security_iam_service-with-iam"></a>

Before you use IAM to manage access to CodeDeploy, you should understand which IAM features are available to use with CodeDeploy. For more information, see [AWS services that work with IAM](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_aws-services-that-work-with-iam.html) in the *IAM User Guide*.

**Topics**
+ [CodeDeploy identity-based policies](#security_iam_service-with-iam-id-based-policies)
+ [CodeDeploy resource-based policies](#security_iam_service-with-iam-resource-based-policies)
+ [Authorization based on CodeDeploy tags](#security_iam_service-with-iam-tags)
+ [CodeDeploy IAM roles](#security_iam_service-with-iam-roles)

## CodeDeploy identity-based policies
<a name="security_iam_service-with-iam-id-based-policies"></a>

With IAM identity-based policies, you can specify allowed or denied actions and resources and the conditions under which actions are allowed or denied. CodeDeploy supports actions, resources, and condition keys. For information about the elements that you use in a JSON policy, see [IAM JSON policy elements reference](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_elements.html) in the *IAM User Guide*.

### Actions
<a name="security_iam_service-with-iam-id-based-policies-actions"></a>

Administrators can use AWS JSON policies to specify who has access to what. That is, which **principal** can perform **actions** on what **resources**, and under what **conditions**.

The `Action` element of a JSON policy describes the actions that you can use to allow or deny access in a policy. Include actions in a policy to grant permissions to perform the associated operation.

Policy actions in CodeDeploy use the `codedeploy:` prefix before the action. For example, the `codedeploy:GetApplication` permission grants the user permissions to perform the `GetApplication` operation. Policy statements must include either an `Action` or `NotAction` element. CodeDeploy defines its own set of actions that describe tasks that you can perform with this service.

To specify multiple actions in a single statement, separate them with commas as follows:

```
"Action": [
      "codedeploy:action1",
      "codedeploy:action2"
```

You can specify multiple actions using wildcards (\$1). For example, include the following action to specify all actions that begin with the word `Describe`:

```
"Action": "ec2:Describe*"
```



For a list of CodeDeploy actions, see [Actions Defined by AWS CodeDeploy](https://docs.aws.amazon.com/IAM/latest/UserGuide/list_awscodedeploy.html#awscodedeploy-actions-as-permissions) in the *IAM User Guide*.

For a table that lists all of the CodeDeploy API actions and the resources they apply to, see [CodeDeploy permissions reference](auth-and-access-control-permissions-reference.md).

### Resources
<a name="security_iam_service-with-iam-id-based-policies-resources"></a>

Administrators can use AWS JSON policies to specify who has access to what. That is, which **principal** can perform **actions** on what **resources**, and under what **conditions**.

The `Resource` JSON policy element specifies the object or objects to which the action applies. As a best practice, specify a resource using its [Amazon Resource Name (ARN)](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference-arns.html). For actions that don't support resource-level permissions, use a wildcard (\$1) to indicate that the statement applies to all resources.

```
"Resource": "*"
```



For example, you can indicate a deployment group (*myDeploymentGroup*) in your statement using its ARN as follows:

```
"Resource": "arn:aws:codedeploy:us-west-2:123456789012:deploymentgroup:myApplication/myDeploymentGroup"
```

You can also specify all deployment groups that belong to an account by using the wildcard character (\$1) as follows:

```
"Resource": "arn:aws:codedeploy:us-west-2:123456789012:deploymentgroup:*"
```

To specify all resources, or if an API action does not support ARNs, use the wildcard character (\$1) in the `Resource` element as follows:

```
"Resource": "*"
```

Some CodeDeploy API actions accept multiple resources (for example, `BatchGetDeploymentGroups`). To specify multiple resources in a single statement, separate their ARNs with commas, as follows:

```
"Resource": ["arn1", "arn2"]
```

CodeDeploy provides a set of operations to work with the CodeDeploy resources. For a list of available operations, see [CodeDeploy permissions reference](auth-and-access-control-permissions-reference.md).

For a list of CodeDeploy resource types and their ARNs, see [Resources Defined by AWS CodeDeploy](https://docs.aws.amazon.com/IAM/latest/UserGuide/list_awscodedeploy.html) in the *IAM User Guide*. For information about the actions in which you can specify the ARN of each resource, see [Actions Defined by AWS CodeDeploy](https://docs.aws.amazon.com/IAM/latest/UserGuide/list_awscodedeploy.html#awscodedeploy-actions-as-permissions).

#### CodeDeploy resources and operations
<a name="arn-formats"></a>

In CodeDeploy, the primary resource is a deployment group. In a policy, you use an Amazon Resource Name (ARN) to identify the resource that the policy applies to. CodeDeploy supports other resources that can be used with deployment groups, including applications, deployment configurations, and instances. These are referred to as subresources. These resources and subresources have unique ARNs associated with them. For more information, see [Amazon resource names (ARNs)](https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html) in the *Amazon Web Services General Reference*.


| Resource type | ARN format | 
| --- | --- | 
| Deployment group |  `arn:aws:codedeploy:region:account-id:deploymentgroup:application-name/deployment-group-name`  | 
| Application |  `arn:aws:codedeploy:region:account-id:application:application-name`  | 
| Deployment configuration |  `arn:aws:codedeploy:region:account-id:deploymentconfig:deployment-configuration-name`   | 
| Instance |  `arn:aws:codedeploy:region:account-id:instance/instance-ID`  | 
|  All CodeDeploy resources  |  `arn:aws:codedeploy:*`  | 
|  All CodeDeploy resources owned by the specified account in the specified Region  |  `arn:aws:codedeploy:region:account-id:*`  | 

**Note**  
Most services in AWS treat a colon (:) or a forward slash (/) as the same character in ARNs. However, CodeDeploy uses an exact match in resource patterns and rules. Be sure to use the correct ARN characters when you create event patterns so that they match the ARN syntax in the resource.

### Condition keys
<a name="security_iam_service-with-iam-id-based-policies-conditionkeys"></a>

CodeDeploy does not provide any service-specific condition keys, but it does support the use of some global condition keys. For more information, see [AWS global condition context keys](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_condition-keys.html) in the *IAM User Guide*.



### Examples
<a name="security_iam_service-with-iam-id-based-policies-examples"></a>



To view examples of CodeDeploy identity-based policies, see [AWS CodeDeploy identity-based policy examples](security_iam_id-based-policy-examples.md).

## CodeDeploy resource-based policies
<a name="security_iam_service-with-iam-resource-based-policies"></a>

CodeDeploy does not support resource-based policies. To view an example of a detailed resource-based policy page, see [Using resource-based policies for AWS Lambda](https://docs.aws.amazon.com/lambda/latest/dg/access-control-resource-based.html).

## Authorization based on CodeDeploy tags
<a name="security_iam_service-with-iam-tags"></a>

CodeDeploy does not support tagging resources or controlling access based on tags.

## CodeDeploy IAM roles
<a name="security_iam_service-with-iam-roles"></a>

An [IAM role](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles.html) is an entity in your AWS account that has specific permissions.

### Using temporary credentials with CodeDeploy
<a name="security_iam_service-with-iam-roles-tempcreds"></a>

You can use temporary credentials to sign in with federation, assume an IAM role, or to assume a cross-account role. You obtain temporary security credentials by calling AWS STS API operations such as [AssumeRole](https://docs.aws.amazon.com/STS/latest/APIReference/API_AssumeRole.html) or [GetFederationToken](https://docs.aws.amazon.com/STS/latest/APIReference/API_GetFederationToken.html). 

CodeDeploy supports the use of temporary credentials. 

### Service-linked roles
<a name="security_iam_service-with-iam-roles-service-linked"></a>

CodeDeploy does not support service-linked roles.

### Service roles
<a name="security_iam_service-with-iam-roles-service"></a>

This feature allows a service to assume a [service role](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_terms-and-concepts.html#iam-term-service-role) on your behalf. This role allows the service to access resources in other services to complete an action on your behalf. Service roles appear in your AWS account and are owned by the account. This means that a user can change the permissions for this role. However, doing so might break the functionality of the service.

CodeDeploy supports service roles. 

### Choosing an IAM role in CodeDeploy
<a name="security_iam_service-with-iam-roles-choose"></a>

When you create a deployment group resource in CodeDeploy, you must choose a role to allow CodeDeploy to access Amazon EC2 on your behalf. If you have previously created a service role or service-linked role, CodeDeploy provides you with a list of roles to choose from. It's important to choose a role that allows access to start and stop EC2 instances.

# AWS managed (predefined) policies for CodeDeploy
<a name="managed-policies"></a>

AWS addresses many common use cases by providing standalone IAM policies that are created and administered by AWS. These AWS-managed policies grant permissions for common use cases so you can avoid having to investigate which permissions are required. For more information, see [AWS managed policies](https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies_managed-vs-inline.html#aws-managed-policies) in the *IAM User Guide*.

**Topics**
+ [List of AWS managed policies for CodeDeploy](#managed-policies-list)
+ [CodeDeploy managed policies and notifications](#notifications-permissions)

## List of AWS managed policies for CodeDeploy
<a name="managed-policies-list"></a>

The following AWS managed policies, which you can attach to users in your account, are specific to CodeDeploy:
+ `AWSCodeDeployFullAccess`: Grants full access to CodeDeploy.

   
**Note**  
AWSCodeDeployFullAccess does not provide permissions to operations in other services required to deploy your applications, such as Amazon EC2 and Amazon S3, only to operations specific to CodeDeploy.
+ `AWSCodeDeployDeployerAccess`: Grants permission to register and deploy revisions.

   
+ `AWSCodeDeployReadOnlyAccess`: Grants read-only access to CodeDeploy.

   
+ <a name="ACD-policy"></a>`AWSCodeDeployRole`: Allows CodeDeploy to:
  + read the tags on your instances or identify your Amazon EC2 instances by Amazon EC2 Auto Scaling group names
  + read, create, update, and delete Amazon EC2 Auto Scaling groups, lifecycle hooks, scaling policies, and warm pool features
  + publish information to Amazon SNS topics
  + retrieve information about Amazon CloudWatch alarms
  + read and update resources in the Elastic Load Balancing service

  The policy contains the following code:

------
#### [ JSON ]

****  

  ```
  {
    "Version":"2012-10-17",		 	 	 
    "Statement": [
      {
        "Effect": "Allow",
        "Action": [
          "autoscaling:CompleteLifecycleAction",
          "autoscaling:DeleteLifecycleHook",
          "autoscaling:DescribeAutoScalingGroups",
          "autoscaling:DescribeLifecycleHooks",
          "autoscaling:PutLifecycleHook",
          "autoscaling:RecordLifecycleActionHeartbeat",
          "autoscaling:CreateAutoScalingGroup",
          "autoscaling:CreateOrUpdateTags",
          "autoscaling:UpdateAutoScalingGroup",
          "autoscaling:EnableMetricsCollection",
          "autoscaling:DescribePolicies",
          "autoscaling:DescribeScheduledActions",
          "autoscaling:DescribeNotificationConfigurations",
          "autoscaling:SuspendProcesses",
          "autoscaling:ResumeProcesses",
          "autoscaling:AttachLoadBalancers",
          "autoscaling:AttachLoadBalancerTargetGroups",
          "autoscaling:PutScalingPolicy",
          "autoscaling:PutScheduledUpdateGroupAction",
          "autoscaling:PutNotificationConfiguration",
          "autoscaling:DescribeScalingActivities",
          "autoscaling:DeleteAutoScalingGroup",
          "autoscaling:PutWarmPool",
          "ec2:DescribeInstances",
          "ec2:DescribeInstanceStatus",
          "ec2:TerminateInstances",
          "tag:GetResources",
          "sns:Publish",
          "cloudwatch:DescribeAlarms",
          "cloudwatch:PutMetricAlarm",
          "elasticloadbalancing:DescribeLoadBalancers",
          "elasticloadbalancing:DescribeLoadBalancerAttributes",
          "elasticloadbalancing:DescribeInstanceHealth",
          "elasticloadbalancing:RegisterInstancesWithLoadBalancer",
          "elasticloadbalancing:DeregisterInstancesFromLoadBalancer",
          "elasticloadbalancing:DescribeTargetGroups",
          "elasticloadbalancing:DescribeTargetGroupAttributes",
          "elasticloadbalancing:DescribeTargetHealth",
          "elasticloadbalancing:RegisterTargets",
          "elasticloadbalancing:DeregisterTargets"
        ],
        "Resource": "*"
      }
    ]
  }
  ```

------

   
+ `AWSCodeDeployRoleForLambda`: Grants CodeDeploy permission to access AWS Lambda and any other resource required for a deployment.

   
+  `AWSCodeDeployRoleForECS`: Grants CodeDeploy permission to access Amazon ECS and any other resource required for a deployment. 

   
+  `AWSCodeDeployRoleForECSLimited`: Grants CodeDeploy permission to access Amazon ECS and any other resource required for a deployment with the following exceptions: 
  +  In the `hooks` section of the AppSpec file, only Lambda functions with names that begin with `CodeDeployHook_` can be used. For more information, see [AppSpec 'hooks' section for an Amazon ECS deployment](reference-appspec-file-structure-hooks.md#appspec-hooks-ecs). 
  +  S3 bucket access is limited to S3 buckets with a registration tag, `UseWithCodeDeploy`, that has a value of `true`. For more information, see [Object tagging](https://docs.aws.amazon.com/AmazonS3/latest/userguide/object-tagging.html). 
+ <a name="EC2-policy"></a>`AmazonEC2RoleforAWSCodeDeployLimited`: Grants CodeDeploy permission to get and list objects in a CodeDeploy Amazon S3 bucket. The policy contains the following code:

------
#### [ JSON ]

****  

  ```
  {
      "Version":"2012-10-17",		 	 	 
      "Statement": [
          {
              "Effect": "Allow",
              "Action": [
                  "s3:GetObject",
                  "s3:GetObjectVersion",
                  "s3:ListBucket"
              ],
              "Resource": "arn:aws:s3:::*/CodeDeploy/*"
          },
          {
              "Effect": "Allow",
              "Action": [
                  "s3:GetObject",
                  "s3:GetObjectVersion"
              ],
              "Resource": "*",
              "Condition": {
                  "StringEquals": {
                      "s3:ExistingObjectTag/UseWithCodeDeploy": "true"
                  }
              }
          }
      ]
  }
  ```

------

Permissions for some aspects of the deployment process are granted to two other role types that act on behalf of CodeDeploy:
+ An *IAM instance profile* is an IAM role that you attach to your Amazon EC2 instances. This profile includes the permissions required to access the Amazon S3 buckets or GitHub repositories where the applications are stored. For more information, see [Step 4: Create an IAM instance profile for your Amazon EC2 instances](getting-started-create-iam-instance-profile.md).
+ A *service role* is an IAM role that grants permissions to an AWS service so it can access AWS resources. The policies you attach to the service role determine which AWS resources the service can access and the actions it can perform with those resources. For CodeDeploy, a service role is used for the following:
  + To read either the tags applied to the instances or the Amazon EC2 Auto Scaling group names associated with the instances. This enables CodeDeploy to identify instances to which it can deploy applications.
  + To perform operations on instances, Amazon EC2 Auto Scaling groups, and Elastic Load Balancing load balancers.
  + To publish information to Amazon SNS topics so that notifications can be sent when specified deployment or instance events occur.
  + To retrieve information about CloudWatch alarms to set up alarm monitoring for deployments.

  For more information, see [Step 2: Create a service role for CodeDeploy](getting-started-create-service-role.md).

You can also create custom IAM policies to grant permissions for CodeDeploy actions and resources. You attach these custom policies to IAM roles, and then you assign the roles to users or groups who require the permissions.

## CodeDeploy managed policies and notifications
<a name="notifications-permissions"></a>

CodeDeploy supports notifications to make users aware of important changes to deployments. Managed policies for CodeDeploy include policy statements for notification functionality. For more information, see [What are notifications?](https://docs.aws.amazon.com/codestar-notifications/latest/userguide/welcome.html).

### Permissions for notifications in full access managed policies
<a name="notifications-fullaccess"></a>

The `AWSCodeDeployFullAccess` managed policy includes the following statements to allow full access to notifications. Users with this managed policy applied can also create and manage Amazon SNS topics for notifications, subscribe and unsubscribe users to topics, and list topics to choose as targets for notification rules.

```
    {
        "Sid": "CodeStarNotificationsReadWriteAccess",
        "Effect": "Allow",
        "Action": [
            "codestar-notifications:CreateNotificationRule",
            "codestar-notifications:DescribeNotificationRule",
            "codestar-notifications:UpdateNotificationRule",
            "codestar-notifications:DeleteNotificationRule",
            "codestar-notifications:Subscribe",
            "codestar-notifications:Unsubscribe"
        ],
        "Resource": "*",
        "Condition" : {
            "ArnLike" : {"codestar-notifications:NotificationsForResource" : "arn:aws:codedeploy:*:*:application:*"} 
        }
    },    
    {
        "Sid": "CodeStarNotificationsListAccess",
        "Effect": "Allow",
        "Action": [
            "codestar-notifications:ListNotificationRules",
            "codestar-notifications:ListTargets",
            "codestar-notifications:ListTagsforResource"
        ],
        "Resource": "*"
    },
    {
        "Sid": "CodeStarNotificationsSNSTopicCreateAccess",
        "Effect": "Allow",
        "Action": [
            "sns:CreateTopic",
            "sns:SetTopicAttributes"
        ],
        "Resource": "arn:aws:sns:*:*:codestar-notifications*"
    },
    {
      "Sid" : "CodeStarNotificationsChatbotAccess",
      "Effect" : "Allow",
      "Action" : [
        "chatbot:DescribeSlackChannelConfigurations"
      ],
      "Resource" : "*"
    },
    {
        "Sid": "SNSTopicListAccess",
        "Effect": "Allow",
        "Action": [
            "sns:ListTopics"
        ],
        "Resource": "*"
    }
```

### Permissions for notifications in read-only managed policies
<a name="notifications-readonly"></a>

The `AWSCodeDeployReadOnlyAccess` managed policy includes the following statements to allow read-only access to notifications. Users with this managed policy applied can view notifications for resources, but cannot create, manage, or subscribe to them. 

```
   {
        "Sid": "CodeStarNotificationsPowerUserAccess",
        "Effect": "Allow",
        "Action": [
            "codestar-notifications:DescribeNotificationRule"
        ],
        "Resource": "*",
        "Condition" : {
            "ArnLike" : {"codestar-notifications:NotificationsForResource" : "arn:aws:codedeploy:*:*:application:*"} 
        }
    },    
    {
        "Sid": "CodeStarNotificationsListAccess",
        "Effect": "Allow",
        "Action": [
            "codestar-notifications:ListNotificationRules"
        ],
        "Resource": "*"
    }
```

### Permissions for notifications in other managed policies
<a name="notifications-deployer"></a>

The `AWSCodeDeployDeployerAccess` managed policy includes the following statements to allow users to create, update, subscribe, and view notifications for resources, but cannot delete them. Users with this managed policy applied can also create and manage Amazon SNS topics for notifications.

This policy includes permissions to do the following:
+ `codestar-notifications:CreateNotificationRule` – Allows principals to create notifications.
+ `codestar-notifications:DescribeNotificationRule` – Allows principals to retrieve information about notifications.
+ `codestar-notifications:UpdateNotificationRule` – Allows principals to update notifications.
+ `codestar-notifications:Subscribe` – Allows principals to subscribe to notification updates.
+ `codestar-notifications:Unsubscribe` – Allows principals to unsubscribe to notification updates.
+ `codestar-notifications:ListNotificationRules` – Allows principals to retrieve the list of notification rules.
+ `codestar-notifications:ListTargets` – Allows principals to retrieve the list of targets.
+ `codestar-notifications:ListTagsforResource` – Allows principals to retrieve the list of tags.
+ `codestar-notifications:ListEventTypes` – Allows principals to retrieve the list of event types.
+ `chatbot:DescribeSlackChannelConfiguration` – Allows principals to retrieve information about Slack channel configurations.
+ `sns:ListTopics` – Allows principals to retrieve the list of Amazon SNS topics for notifications.

```
   {
      "Sid" : "CodeStarNotificationsReadWriteAccess",
      "Effect" : "Allow",
      "Action" : [
        "codestar-notifications:CreateNotificationRule",
        "codestar-notifications:DescribeNotificationRule",
        "codestar-notifications:UpdateNotificationRule",
        "codestar-notifications:Subscribe",
        "codestar-notifications:Unsubscribe"
      ],
      "Resource" : "*",
      "Condition" : {
        "ArnLike" : {
          "codestar-notifications:NotificationsForResource" : "arn:aws:codedeploy:*:*:application:*"
        }
      }
    },
    {
      "Sid" : "CodeStarNotificationsListAccess",
      "Effect" : "Allow",
      "Action" : [
        "codestar-notifications:ListNotificationRules",
        "codestar-notifications:ListTargets",
        "codestar-notifications:ListTagsforResource",
        "codestar-notifications:ListEventTypes"
      ],
      "Resource" : "*"
    },
    {
      "Sid" : "CodeStarNotificationsChatbotAccess",
      "Effect" : "Allow",
      "Action" : [
        "chatbot:DescribeSlackChannelConfigurations"
      ],
      "Resource" : "*"
    },
    {
      "Sid" : "SNSTopicListAccess",
      "Effect" : "Allow",
      "Action" : [
        "sns:ListTopics"
      ],
      "Resource" : "*"
    }
```

For more information, see [Identity and access management for AWS CodeStar Notifications](https://docs.aws.amazon.com/codestar-notifications/latest/userguide/security-iam.html).

# CodeDeploy updates to AWS managed policies
<a name="managed-policies-updates"></a>

View details about updates to AWS managed policies for CodeDeploy since this service began tracking these changes. For automatic alerts about changes to this page, subscribe to the RSS feed on the CodeDeploy [Document history](document-history.md). 


| Change | Description | Date | 
| --- | --- | --- | 
|  `AWSCodeDeployDeployerAccess` managed policy – Updates to existing policy  |  Updated the `codestar-notifications:NotificationsForResource` action to support IAM policy validation changes. The original resource `arn:aws:codedeploy:*` has been updated to `arn:aws:codedeploy:*:*:application:*`. For more information on this policy, see [Permissions for notifications in other managed policies](managed-policies.md#notifications-deployer).  |  December 16, 2024  | 
|  `AWSCodeDeployReadOnlyAccess` managed policy – Updates to existing policy  |  Updated the `codestar-notifications:NotificationsForResource` action to support IAM policy validation changes. The original resource `arn:aws:codedeploy:*` has been updated to `arn:aws:codedeploy:*:*:application:*`. For more information on this policy, see [Permissions for notifications in read-only managed policies](managed-policies.md#notifications-readonly).  |  December 16, 2024  | 
|  `AWSCodeDeployFullAccess` managed policy – Updates to existing policy  |  Updated the `codestar-notifications:NotificationsForResource` action to support IAM policy validation changes. The original resource `arn:aws:codedeploy:*` has been updated to `arn:aws:codedeploy:*:*:application:*`. For more information on this policy, see [Permissions for notifications in full access managed policies](managed-policies.md#notifications-fullaccess).  |  December 16, 2024  | 
|  `AWSCodeDeployRole` managed policy – Updates to existing policy  |  Added the `elasticloadbalancing:DescribeLoadBalancerAttributes` and `elasticloadbalancing:DescribeTargetGroupAttributes` actions to the policy statement to support Elastic Load Balancing changes. For more information on this policy, see [AWSCodeDeployRole](managed-policies.md#ACD-policy).  |  August 16, 2023  | 
|  `AWSCodeDeployFullAccess` managed policy – Updates to existing policy  |  Added the `chatbot:ListMicrosoftTeamsChannelConfigurations` action to the policy statement to support notification changes. For more information on this policy, see [AWSCodeDeployRole](managed-policies.md#ACD-policy).  |  May 11, 2023  | 
|  `AWSCodeDeployRole` managed policy – Updates to existing policy  |  Added the ` autoscaling:CreateOrUpdateTags` action to the policy statement to support Amazon EC2 Auto Scaling authorization changes. For more information on this policy, see [AWSCodeDeployRole](managed-policies.md#ACD-policy).  |  February 3, 2023  | 
|  `AmazonEC2RoleforAWSCodeDeployLimited` managed policy – Updates to existing policy  |  Removed the `s3:ListBucket` action from the policy statement that includes the `s3:ExistingObjectTag/UseWithCodeDeploy` condition. For more information on this policy, see [AmazonEC2RoleforAWSCodeDeployLimited](managed-policies.md#EC2-policy).  |  November 22, 2021  | 
|  `AWSCodeDeployRole` managed policy – Updates to existing policy  |  Added the `autoscaling:PutWarmPool` action to support [adding warm pools to Amazon EC2 Auto Scaling groups](https://docs.aws.amazon.com/autoscaling/ec2/userguide/ec2-auto-scaling-warm-pools.html#add-warm-pool-console/ec2/userguide/ec2-auto-scaling-warm-pools.html#add-warm-pool-console) for blue/green deployments. Removed needless duplicate actions.  |  May 18, 2021  | 
|  CodeDeploy started tracking changes  |  CodeDeploy started tracking changes for its AWS managed policies.  |  May 18, 2021  | 

# AWS CodeDeploy identity-based policy examples
<a name="security_iam_id-based-policy-examples"></a>

By default, users don't have permission to create or modify CodeDeploy resources. They also can't perform tasks using the AWS Management Console, AWS CLI, or AWS API. You must create IAM policies that grant IAM roles permission to perform API operations on the specified resources they need. You must then attach those IAM roles to users or groups who 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](https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies_create.html#access_policies_create-json-editor) in the *IAM User Guide*.

In CodeDeploy, identity-based policies are used to manage permissions to the various resources related to the deployment process. You can control access to the following resource types:
+ Applications and application revisions.
+ Deployments.
+ Deployment configurations.
+ Instances and on-premises instances.

The capabilities controlled by resource policies vary depending on the resource type, as outlined in the following table:


****  

|  Resource types  |  Capabilities  | 
| --- | --- | 
|  All  |  View and list details about resources  | 
|  Applications Deployment configurations Deployment groups  |  Create resources Delete resources  | 
|  Deployments  |  Create deployments Stop deployments  | 
|  Application revisions  |  Register application revisions  | 
|  Applications Deployment groups  |  Update resources  | 
|  On-premises instances  |  Add tags to instances Remove tags from instances Register instances Deregister instances  | 

The following example shows a permissions policy that allows a user to delete the deployment group named **WordPress\$1DepGroup** associated with the application named **WordPress\$1App** in the **us-west-2** Region.

------
#### [ JSON ]

****  

```
{
  "Version":"2012-10-17",		 	 	 
  "Statement" : [
    {
      "Effect" : "Allow",
      "Action" : [
        "codedeploy:DeleteDeploymentGroup"
      ],
      "Resource" : [
        "arn:aws:codedeploy:us-west-2:111122223333:deploymentgroup:WordPress_App/WordPress_DepGroup"
      ]
    }
  ]
}
```

------

**Topics**
+ [Customer-managed policy examples](#customer-managed-policies)
+ [Policy best practices](#security_iam_service-with-iam-policy-best-practices)
+ [Using the CodeDeploy console](#security_iam_id-based-policy-examples-console)
+ [Allow users to view their own permissions](#security_iam_id-based-policy-examples-view-own-permissions)

## Customer-managed policy examples
<a name="customer-managed-policies"></a>

In this section, you can find example policies that grant permissions for various CodeDeploy actions. These policies work when you are using the CodeDeploy API, AWS SDKs, or the AWS CLI. You must grant additional permissions for actions you perform in the console. To learn more about granting console permissions, see [Using the CodeDeploy console](#security_iam_id-based-policy-examples-console) .



**Note**  
All examples use the US West (Oregon) Region (`us-west-2`) and contain fictitious account IDs.

 **Examples**
+ [Example 1: Allow permission to perform CodeDeploy operations in a single Region](#identity-based-policies-example-1)
+ [Example 2: Allow permission to register revisions for a single application](#identity-based-policies-example-2)
+ [Example 3: Allow permission to create deployments for a single deployment group](#identity-based-policies-example-3)

### Example 1: Allow permission to perform CodeDeploy operations in a single Region
<a name="identity-based-policies-example-1"></a>

The following example grants permissions to perform CodeDeploy operations in the **us-west-2** Region only:

------
#### [ JSON ]

****  

```
{
  "Version":"2012-10-17",		 	 	 
  "Statement" : [
    {
      "Effect" : "Allow",
      "Action" : [
        "codedeploy:*"
      ],
      "Resource" : [
        "arn:aws:codedeploy:us-west-2:111122223333:*"
      ]
    }
  ]
}
```

------

### Example 2: Allow permission to register revisions for a single application
<a name="identity-based-policies-example-2"></a>

The following example grants permissions to register application revisions for all applications that begin with **Test** in the **us-west-2** Region:

------
#### [ JSON ]

****  

```
{
  "Version":"2012-10-17",		 	 	 
  "Statement" : [
    {
      "Effect" : "Allow",
      "Action" : [
        "codedeploy:RegisterApplicationRevision"
      ],
      "Resource" : [
        "arn:aws:codedeploy:us-west-2:111122223333:application:Test*"
      ]
    }
  ]
}
```

------

### Example 3: Allow permission to create deployments for a single deployment group
<a name="identity-based-policies-example-3"></a>

The following example allows permission to create deployments for the deployment group named **WordPress\$1DepGroup** associated with the application named **WordPress\$1App**, the custom deployment configuration named **ThreeQuartersHealthy**, and any application revisions associated with the application named **WordPress\$1App**. All of these resources are in the **us-west-2** Region.

------
#### [ JSON ]

****  

```
{
  "Version":"2012-10-17",		 	 	 
  "Statement" : [
    {
      "Effect" : "Allow",
      "Action" : [
        "codedeploy:CreateDeployment"
      ],
      "Resource" : [
        "arn:aws:codedeploy:us-west-2:111122223333:deploymentgroup:WordPress_App/WordPress_DepGroup"
      ]
    },
    {
      "Effect" : "Allow",
      "Action" : [
        "codedeploy:GetDeploymentConfig"
      ],
      "Resource" : [
        "arn:aws:codedeploy:us-west-2:111122223333:deploymentconfig:ThreeQuartersHealthy"
      ]
    },
    {
      "Effect" : "Allow",
      "Action" : [
        "codedeploy:GetApplicationRevision"
      ],
      "Resource" : [
        "arn:aws:codedeploy:us-west-2:111122223333:application:WordPress_App"
      ]
    }
  ]
}
```

------

## Policy best practices
<a name="security_iam_service-with-iam-policy-best-practices"></a>

Identity-based policies determine whether someone can create, access, or delete CodeDeploy 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](https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies_managed-vs-inline.html#aws-managed-policies) or [AWS managed policies for job functions](https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies_job-functions.html) 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](https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies.html) 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 CloudFormation. For more information, see [ IAM JSON policy elements: Condition](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_elements_condition.html) 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 [Validate policies with IAM Access Analyzer](https://docs.aws.amazon.com/IAM/latest/UserGuide/access-analyzer-policy-validation.html) in the *IAM User Guide*.
+ **Require multi-factor authentication (MFA)** – If you have a scenario that requires IAM users or a root user in your AWS 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 [ Secure API access with MFA](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_mfa_configure-api-require.html) in the *IAM User Guide*.

For more information about best practices in IAM, see [Security best practices in IAM](https://docs.aws.amazon.com/IAM/latest/UserGuide/best-practices.html) in the *IAM User Guide*.

## Using the CodeDeploy console
<a name="security_iam_id-based-policy-examples-console"></a>

If you use the CodeDeploy console, you must have a minimum set of permissions that allows you to describe other AWS resources for your AWS account. To use CodeDeploy in the CodeDeploy console, you must have permissions from the following services:
+ Amazon EC2 Auto Scaling
+ AWS CodeDeploy
+ Amazon Elastic Compute Cloud
+ Elastic Load Balancing
+ AWS Identity and Access Management
+ Amazon Simple Storage Service
+ Amazon Simple Notification Service
+ Amazon CloudWatch

If you create an IAM policy that is more restrictive than the minimum required permissions, the console won't function as intended for users who have a role with that IAM policy. To ensure that those users can still use the CodeDeploy console, also attach the `AWSCodeDeployReadOnlyAccess` managed policy to the role assigned to the user, as described in [AWS managed (predefined) policies for CodeDeploy](managed-policies.md).

You don't need to allow minimum console permissions for users who are making calls only to the AWS CLI or the CodeDeploy API.

## Allow users to view their own permissions
<a name="security_iam_id-based-policy-examples-view-own-permissions"></a>

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": "*"
        }
    ]
}
```

# Troubleshooting AWS CodeDeploy identity and access
<a name="security_iam_troubleshoot"></a>

Use the following information to help you diagnose and fix common issues that you might encounter when working with CodeDeploy and IAM.

**Topics**
+ [I am not authorized to perform iam:PassRole](#security_iam_troubleshoot-passrole)
+ [I want to allow people outside of my AWS account to access my CodeDeploy resources](#security_iam_troubleshoot-cross-account-access)

## I am not authorized to perform iam:PassRole
<a name="security_iam_troubleshoot-passrole"></a>

If you receive an error that you're not authorized to perform the `iam:PassRole` action, your policies must be updated to allow you to pass a role to CodeDeploy.

Some AWS services allow you to pass an existing role to that service instead of creating a new service role or service-linked role. To do this, you must have permissions to pass the role to the service.

The following example error occurs when an IAM user named `marymajor` tries to use the console to perform an action in CodeDeploy. However, the action requires the service to have permissions that are granted by a service role. Mary does not have permissions to pass the role to the service.

```
User: arn:aws:iam::123456789012:user/marymajor is not authorized to perform: iam:PassRole
```

In this case, Mary's policies must be updated to allow her to perform the `iam:PassRole` action.

If you need help, contact your AWS administrator. Your administrator is the person who provided you with your sign-in credentials.

## I want to allow people outside of my AWS account to access my CodeDeploy resources
<a name="security_iam_troubleshoot-cross-account-access"></a>

You can create a role that users in other accounts or people outside of your organization can use to access your resources. You can specify who is trusted to assume the role. For services that support resource-based policies or access control lists (ACLs), you can use those policies to grant people access to your resources.

To learn more, consult the following:
+ To learn whether CodeDeploy supports these features, see [How AWS CodeDeploy works with IAM](security_iam_service-with-iam.md).
+ To learn how to provide access to your resources across AWS accounts that you own, see [Providing access to an IAM user in another AWS account that you own](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_common-scenarios_aws-accounts.html) in the *IAM User Guide*.
+ To learn how to provide access to your resources to third-party AWS accounts, see [Providing access to AWS accounts owned by third parties](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_common-scenarios_third-party.html) in the *IAM User Guide*.
+ To learn how to provide access through identity federation, see [Providing access to externally authenticated users (identity federation)](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_common-scenarios_federated-users.html) in the *IAM User Guide*.
+ To learn the difference between using roles and resource-based policies for cross-account access, see [Cross account resource access in IAM](https://docs.aws.amazon.com/IAM/latest/UserGuide/access_policies-cross-account-resource-access.html) in the *IAM User Guide*.

# CodeDeploy permissions reference
<a name="auth-and-access-control-permissions-reference"></a>

Use the following table when you are setting up access and writing permissions policies that you can attach to an IAM identity (identity-based policies). The table lists each CodeDeploy API operation, the actions for which you can grant permissions to perform the action, and the format of the resource ARN to use for granting permissions. You specify the actions in the policy's `Action` field. You specify an ARN, with or without a wildcard character (\$1), as the resource value in the policy's `Resource` field.

You can use AWS-wide condition keys in your CodeDeploy policies to express conditions. For a complete list of AWS-wide keys, see [Available keys](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_elements.html#AvailableKeys) in the *IAM User Guide*.

To specify an action, use the `codedeploy:` prefix followed by the API operation name (for example, `codedeploy:GetApplication` and `codedeploy:CreateApplication`). To specify multiple actions in a single statement, separate them with commas (for example, `"Action": ["codedeploy:action1", "codedeploy:action2"]`).

**Using Wildcard Characters**

You can use a wildcard character (\$1) in your ARN to specify multiple actions or resources. For example, `codedeploy:*` specifies all CodeDeploy actions and `codedeploy:Get*` specifies all CodeDeploy actions that begin with the word `Get`. The following example grants access to all deployment groups with names that begin with `West` and are associated with applications that have names beginning with `Test`. 

```
arn:aws:codedeploy:us-west-2:444455556666:deploymentgroup:Test*/West*
```

You can use wildcards with the following resources listed in the table:
+ *application-name*
+ *deployment-group-name*
+ *deployment-configuration-name*
+ *instance-ID*

Wildcards can't be used with *region* or *account-id*. For more information about wildcards, see [IAM identifiers](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_identifiers.html) in *IAM User Guide*. 

**Note**  
 In the ARN for each action, a colon (:) follows the resource. You can also follow the resource with a forward slash (/). For more information, see [CodeDeploy example ARNs](https://docs.aws.amazon.com/general/latest/gr/aws-arns-and-namespaces.html#arn-syntax-codedeploy). 

Use the scroll bars to see the rest of the table.


**CodeDeploy API operations and required permissions for actions**  

| CodeDeploy API operations | Required permissions (API actions) | Resources | 
| --- | --- | --- | 
|  [AddTagsToOnPremisesInstances](https://docs.aws.amazon.com/codedeploy/latest/APIReference/API_AddTagsToOnPremisesInstances.html)  |  `codedeploy:AddTagsToOnPremisesInstances` Required to add tags to one or more on-premises instances.  |  arn:aws:codedeploy:*region*:*account-id*:instance/*instance-ID*  | 
|  [BatchGetApplicationRevisions](https://docs.aws.amazon.com/codedeploy/latest/APIReference/BatchGetApplicationRevisions.html)  |  `codedeploy:BatchGetApplicationRevisions` Required to get information about multiple application revisions associated with the user.  |  arn:aws:codedeploy:*region*:*account-id*:application:*application-name*  | 
|  [BatchGetApplications](https://docs.aws.amazon.com/codedeploy/latest/APIReference/API_BatchGetApplications.html)  |  `codedeploy:BatchGetApplications` Required to get information about multiple applications associated with the user.  |  arn:aws:codedeploy:*region*:*account-id*:application:\$1  | 
| [BatchGetDeploymentGroups](https://docs.aws.amazon.com/codedeploy/latest/APIReference/API_BatchGetDeploymentGroups.html) |  `codedeploy:BatchGetDeploymentGroups` Required to get information about multiple deployment groups associated with the user.  |  arn:aws:codedeploy:*region*:*account-id*:deploymentgroup:*application-name*/*deployment-group-name*  | 
| [BatchGetDeploymentInstances](https://docs.aws.amazon.com/codedeploy/latest/APIReference/API_BatchGetDeploymentInstances.html) | codedeploy:BatchGetDeploymentInstancesRequired to get information about one or more instance in a deployment group. |  arn:aws:codedeploy:*region*:*account-id*:deploymentgroup:*application-name*/*deployment-group-name*  | 
|  [BatchGetDeployments](https://docs.aws.amazon.com/codedeploy/latest/APIReference/API_BatchGetDeployments.html)  |  `codedeploy:BatchGetDeployments` Required to get information about multiple deployments associated with the user.  |  arn:aws:codedeploy:*region*:*account-id*:deploymentgroup:*application-name*/*deployment-group-name*  | 
|  [BatchGetOnPremisesInstances](https://docs.aws.amazon.com/codedeploy/latest/APIReference/API_BatchGetOnPremisesInstances.html)  |  `codedeploy:BatchGetOnPremisesInstances` Required to get information about one or more on-premises instances.  |  arn:aws:codedeploy:*region*:*account-id*:\$1  | 
|  [ContinueDeployment](https://docs.aws.amazon.com/codedeploy/latest/APIReference/API_ContinueDeployment.html)  |  `codedeploy:ContinueDeployment` Required during a blue/green deployment to start the process of registering instances in a replacement environment with an Elastic Load Balancing load balancer.  |  arn:aws:codedeploy:*region*:*account-id*:deploymentgroup:*application-name*/*deployment-group-name*  | 
|  [CreateApplication](https://docs.aws.amazon.com/codedeploy/latest/APIReference/API_CreateApplication.html)  |  `codedeploy:CreateApplication` Required to create an application associated with the user.  |  arn:aws:codedeploy:*region*:*account-id*:application:*application-name*  | 
|  [CreateDeployment](https://docs.aws.amazon.com/codedeploy/latest/APIReference/API_CreateDeployment.html) ¹  |  `codedeploy:CreateDeployment` Required to create a deployment for an application associated with the user.  |  arn:aws:codedeploy:*region*:*account-id*:deploymentgroup:*application-name*/*deployment-group-name*  | 
|  [CreateDeploymentConfig](https://docs.aws.amazon.com/codedeploy/latest/APIReference/API_CreateDeploymentConfig.html)  |  `codedeploy:CreateDeploymentConfig` Required to create a custom deployment configuration associated with the user.  |  arn:aws:codedeploy:*region*:*account-id*:deploymentconfig:*deployment-configuration-name*   | 
|  [CreateDeploymentGroup](https://docs.aws.amazon.com/codedeploy/latest/APIReference/API_CreateDeploymentGroup.html)  |  `codedeploy:CreateDeploymentGroup` Required to create a deployment group for an application associated with the user.  |  arn:aws:codedeploy:*region*:*account-id*:deploymentgroup:*application-name*/*deployment-group-name*  | 
|  [DeleteApplication](https://docs.aws.amazon.com/codedeploy/latest/APIReference/API_DeleteApplication.html)  |  `codedeploy:DeleteApplication` Required to delete an application associated with the user.  |  arn:aws:codedeploy:*region*:*account-id*:application:*application-name*  | 
|  [DeleteDeploymentConfig](https://docs.aws.amazon.com/codedeploy/latest/APIReference/API_DeleteDeploymentConfig.html)  |  `codedeploy:DeleteDeploymentConfig` Required to delete a custom deployment configuration associated with the user.  |  arn:aws:codedeploy:*region*:*account-id*:deploymentconfig:*deployment-configuration-name*   | 
|  [DeleteDeploymentGroup](https://docs.aws.amazon.com/codedeploy/latest/APIReference/API_DeleteDeploymentGroup.html)  |  `codedeploy:DeleteDeploymentGroup` Required to delete a deployment group for an application associated with the user.  |  arn:aws:codedeploy:*region*:*account-id*:deploymentgroup:*application-name*/*deployment-group-name*  | 
|  [DeregisterOnPremisesInstance](https://docs.aws.amazon.com/codedeploy/latest/APIReference/API_DeregisterOnPremisesInstance.html)  |  `codedeploy:DeregisterOnPremisesInstance` Required to deregister an on-premises instance.  |  arn:aws:codedeploy:*region*:*account-id*:instance/*instance-ID*  | 
|  [GetApplication](https://docs.aws.amazon.com/codedeploy/latest/APIReference/API_GetApplication.html)  |  `codedeploy:GetApplication` Required to get information about a single application associated with the user.  |  arn:aws:codedeploy:*region*:*account-id*:application:*application-name*  | 
|  [GetApplicationRevision](https://docs.aws.amazon.com/codedeploy/latest/APIReference/API_GetApplicationRevision.html)  |  `codedeploy:GetApplicationRevision` Required to get information about a single application revision for an application associated with the user.  |  arn:aws:codedeploy:*region*:*account-id*:application:*application-name*  | 
|  [GetDeployment](https://docs.aws.amazon.com/codedeploy/latest/APIReference/API_GetDeployment.html)  |  `codedeploy:GetDeployment` Required to get information about a single deployment to a deployment group for an application associated with the user.  |  arn:aws:codedeploy:*region*:*account-id*:deploymentgroup:*application-name*/*deployment-group-name*  | 
|  [GetDeploymentConfig](https://docs.aws.amazon.com/codedeploy/latest/APIReference/API_GetDeploymentConfig.html)  |  `codedeploy:GetDeploymentConfig` Required to get information about a single deployment configuration associated with the user.  |  arn:aws:codedeploy:*region*:*account-id*:deploymentconfig:*deployment-configuration-name*   | 
|  [GetDeploymentGroup](https://docs.aws.amazon.com/codedeploy/latest/APIReference/API_GetDeploymentGroup.html)  |  `codedeploy:GetDeploymentGroup` Required to get information about a single deployment group for an application associated with the user.  |  arn:aws:codedeploy:*region*:*account-id*:deploymentgroup:*application-name*/*deployment-group-name*  | 
|  [GetDeploymentInstance](https://docs.aws.amazon.com/codedeploy/latest/APIReference/API_GetDeploymentInstance.html)  |  `codedeploy:GetDeploymentInstance` Required to get information about a single instance in a deployment associated with the user.  |  arn:aws:codedeploy:*region*:*account-id*:deploymentgroup:*application-name*/*deployment-group-name*  | 
|  [GetDeploymentTarget](https://docs.aws.amazon.com/codedeploy/latest/APIReference/API_GetDeploymentTarget.html)  |  `codedeploy:GetDeploymentTarget` Required to get information about a target in a deployment associated with the user.  |  arn:aws:codedeploy:*region*:*account-id*:deploymentgroup:*application-name*/*deployment-group-name*  | 
|  [GetOnPremisesInstance](https://docs.aws.amazon.com/codedeploy/latest/APIReference/API_GetOnPremisesInstance.html)  |  `codedeploy:GetOnPremisesInstance` Required to get information about a single on-premises instance.  |  arn:aws:codedeploy:*region*:*account-id*:instance/*instance-ID*  | 
|  [ListApplicationRevisions](https://docs.aws.amazon.com/codedeploy/latest/APIReference/API_ListApplicationRevisions.html)  |  `codedeploy:ListApplicationRevisions` Required to get information about all application revisions for an application associated with the user.  |  arn:aws:codedeploy:*region*:*account-id*:application:\$1  | 
|  [ListApplications](https://docs.aws.amazon.com/codedeploy/latest/APIReference/API_ListApplications.html)  |  `codedeploy:ListApplications` Required to get information about all applications associated with the user.  |  arn:aws:codedeploy:*region*:*account-id*:application:\$1  | 
|  [ListDeploymentConfigs](https://docs.aws.amazon.com/codedeploy/latest/APIReference/API_ListDeploymentConfigs.html)  |  `codedeploy:ListDeploymentConfigs` Required to get information about all deployment configurations associated with the user.  |  arn:aws:codedeploy:*region*:*account-id*:deploymentconfig:\$1  | 
|  [ListDeploymentGroups](https://docs.aws.amazon.com/codedeploy/latest/APIReference/API_ListDeploymentGroups.html)  |  `codedeploy:ListDeploymentGroups` Required to get information about all deployment groups for an application associated with the user.  |  arn:aws:codedeploy:*region*:*account-id*:deploymentgroup:*application-name*/\$1  | 
|  [ListDeploymentInstances](https://docs.aws.amazon.com/codedeploy/latest/APIReference/API_ListDeploymentInstances.html)  |  `codedeploy:ListDeploymentInstances` Required to get information about all instances in a deployment associated with the user or AWS account.  |  arn:aws:codedeploy:*region*:*account-id*:deploymentgroup:*application-name*/*deployment-group-name*  | 
|  [ListDeployments](https://docs.aws.amazon.com/codedeploy/latest/APIReference/API_ListDeployments.html)  |  `codedeploy:ListDeployments` Required to get information about all deployments to a deployment group associated with the user, or to get all deployments associated with the user.  |  arn:aws:codedeploy:*region*:*account-id*:deploymentgroup:*application-name*/*deployment-group-name*  | 
|  [ListDeploymentTargets](https://docs.aws.amazon.com/codedeploy/latest/APIReference/API_ListDeploymentTargets.html)  |  `codedeploy:ListDeploymentTargets` Required to get information about all targets in a deployment associated with the user.  |  arn:aws:codedeploy:*region*:*account-id*:deploymentgroup:*application-name*/*deployment-group-name*  | 
|  [ListGitHubAccountTokenNames](https://docs.aws.amazon.com/codedeploy/latest/APIReference/API_ListGitHubAccountTokenNames.html)  |  `codedeploy:ListGitHubAccountTokenNames` Required to get a list of the names of stored connections to GitHub accounts.   |  arn:aws:codedeploy:*region*:*account-id*:\$1  | 
|  [ListOnPremisesInstances](https://docs.aws.amazon.com/codedeploy/latest/APIReference/API_ListOnPremisesInstances.html)  |  `codedeploy:ListOnPremisesInstances` Required to get a list of one or more on-premises instance names.  |  arn:aws:codedeploy:*region*:*account-id*:\$1  | 
|  PutLifecycleEventHookExecutionStatus  |  `codedeploy:PutLifecycleEventHookExecutionStatus` Required to provide notification of the status of the execution of a lifecycle hook event.  |  arn:aws:codedeploy:*region*:*account-id*:deploymentgroup:*application-name*/*deployment-group-name*  | 
|  [RegisterApplicationRevision](https://docs.aws.amazon.com/codedeploy/latest/APIReference/API_RegisterApplicationRevision.html)  |  `codedeploy:RegisterApplicationRevision` Required to register information about an application revision for an application associated with the user.  |  arn:aws:codedeploy:*region*:*account-id*:application:*application-name*  | 
|  [RegisterOnPremisesInstance](https://docs.aws.amazon.com/codedeploy/latest/APIReference/API_RegisterOnPremisesInstance.html)  |  `codedeploy:RegisterOnPremisesInstance` Required to register an on-premises instance with CodeDeploy.  |  arn:aws:codedeploy:*region*:*account-id*:instance/*instance-ID*  | 
|  [RemoveTagsFromOnPremisesInstances](https://docs.aws.amazon.com/codedeploy/latest/APIReference/API_RemoveTagsFromOnPremisesInstances.html)  |  `codedeploy:RemoveTagsFromOnPremisesInstances` Required to remove tags from one or more on-premises instances.  |  arn:aws:codedeploy:*region*:*account-id*:instance/*instance-ID*  | 
|  [SkipWaitTimeForInstanceTermination](https://docs.aws.amazon.com/codedeploy/latest/APIReference/API_SkipWaitTimeForInstanceTermination.html)  |  `codedeploy:SkipWaitTimeForInstanceTermination` Required in a blue/green deployment to override a specified wait time and start terminating instances in the original environment immediately.  |  arn:aws:codedeploy:*region*:*account-id*:instance/*instance-ID*  | 
|  [StopDeployment](https://docs.aws.amazon.com/codedeploy/latest/APIReference/API_StopDeployment.html)  |  `codedeploy:StopDeployment` Required to stop an in-progress deployment to a deployment group for an application associated with the user.  |  arn:aws:codedeploy:*region*:*account-id*:deploymentgroup:*application-name*/*deployment-group-name*  | 
|  [UpdateApplication](https://docs.aws.amazon.com/codedeploy/latest/APIReference/API_UpdateApplication.html) ³  |  `codedeploy:UpdateApplication` Required to change information about an application associated with the user.  |  arn:aws:codedeploy:*region*:*account-id*:application:*application-name*  | 
|  [UpdateDeploymentGroup](https://docs.aws.amazon.com/codedeploy/latest/APIReference/API_UpdateDeploymentGroup.html) ³  |  `codedeploy:UpdateDeploymentGroup` Required to change information about a single deployment group for an application associated with the user.  |  arn:aws:codedeploy:*region*:*account-id*:deploymentgroup:*application-name*/*deployment-group-name*  | 
|  ¹ When you specify `CreateDeployment` permissions, you must also specify `GetDeploymentConfig` permissions for the deployment configuration and `GetApplicationRevision` or `RegisterApplicationRevision` permissions for the application revision. Additionally, if you include the `overrideAlarmConfiguration` parameter in your `CreateDeployment` API call, you must specify the `UpdateDeploymentGroup` permission. ² Valid for `ListDeployments` when providing a specific deployment group, but not when listing all of the deployments associated with the user. ³ For `UpdateApplication`, you must have `UpdateApplication` permissions for both the old and new application names. For `UpdateDeploymentGroup` actions that involve changing a deployment group's name, you must have `UpdateDeploymentGroup` permissions for both the old and new deployment group names.   | 

# Cross-service confused deputy prevention
<a name="security_confused_deputy"></a>

The confused deputy problem is a security issue where an entity that doesn't have permission to perform an action can coerce a more-privileged entity to perform the action. In AWS, cross-service impersonation can result in the confused deputy problem. Cross-service impersonation can occur when one service (the calling service) calls another service (the called service). The calling service can be manipulated to use its permissions to act on another customer's resources in a way it should not otherwise have permission to access. To prevent this, AWS provides tools that help you protect your data for all services with service principals that have been given access to resources in your account. 

We recommend using the [aws:SourceArn](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_condition-keys.html#condition-keys-sourcearn) and [aws:SourceAccount](https://docs.aws.amazon.com/IAM/latest/UserGuide/reference_policies_condition-keys.html#condition-keys-sourceaccount) global condition context keys in resource policies to limit the permissions that CodeDeploy gives another service to the resource. If you use both global condition context keys and the `aws:SourceArn` value contains the account ID, the `aws:SourceAccount` value and the account in the `aws:SourceArn` value must use the same account ID when used in the same policy statement. Use `aws:SourceArn` if you want only one resource to be associated with the cross-service access. Use `aws:SourceAccount` if you want any resource in that account to be associated with the cross-service use.

For EC2/On-Premises, AWS Lambda, and regular Amazon ECS deployments, the value of `aws:SourceArn` should include the CodeDeploy deployment group ARN with which CodeDeploy is allowed to assume the IAM role.

For [Amazon ECS blue/green deployments created through CloudFormation](deployments-create-ecs-cfn.md), the value of `aws:SourceArn` should include the CloudFormation stack ARN with which CodeDeploy is allowed to assume the IAM role.

The most effective way to protect against the confused deputy problem is to use the `aws:SourceArn` key with the full ARN of the resource. If you don't know the full ARN or if you're specifying multiple resources, use wildcard characters (\$1) for the unknown portions.

For example, you might use the following trust policy with a EC2/On-Premises, AWS Lambda, or regular Amazon ECS deployment:

------
#### [ JSON ]

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement": [
        {
            "Sid": "",
            "Effect": "Allow",
            "Principal": {
                "Service": "codedeploy.amazonaws.com"
            },
            "Action": "sts:AssumeRole",
            "Condition": {
                "StringEquals": {
                    "aws:SourceAccount": "111122223333"
                },
                "ArnLike": {
                    "aws:SourceArn": "arn:aws:codedeploy:us-east-1:111122223333:deploymentgroup:myApplication/*"
                }
            }
        }
    ]
}
```

------

For an [Amazon ECS blue/green deployment created through CloudFormation](deployments-create-ecs-cfn.md), you might use:

------
#### [ JSON ]

****  

```
{
    "Version":"2012-10-17",		 	 	 
    "Statement": [
        {
            "Sid": "",
            "Effect": "Allow",
            "Principal": {
                "Service": "codedeploy.amazonaws.com"
            },
            "Action": "sts:AssumeRole",
            "Condition": {
                "StringEquals": {
                    "aws:SourceAccount": "111122223333"
                },
                "ArnLike": {
                    "aws:SourceArn": "arn:aws:cloudformation:us-east-1:111122223333:stack/MyCloudFormationStackName/*"
                }
            }
        }
    ]
}
```

------