Menu
AWS CodeDeploy
User Guide (API Version 2014-10-06)

Integrating AWS CodeDeploy with GitHub

AWS CodeDeploy supports GitHub, a web-based code hosting and sharing service. AWS CodeDeploy can deploy application revisions stored in GitHub repositories or Amazon S3 buckets to instances.

Video Introduction to AWS CodeDeploy Integration with GitHub

This short video (5:20) demonstrates how to automate application deployments with AWS CodeDeploy from your existing GitHub workflows.

Deploying AWS CodeDeploy Revisions from GitHub

To deploy an application revision from a GitHub repository to instances:

  1. Create a revision that's compatible with AWS CodeDeploy and the Amazon EC2 instance type to which you will deploy.

    To create a compatible revision, follow the instructions in Plan a Revision for AWS CodeDeploy and Add an Application Specification File to a Revision for AWS CodeDeploy.

  2. Use a GitHub account to add your revision to a GitHub repository.

    To create a GitHub account, see Join GitHub. To create a GitHub repository, see Create a Repo.

  3. Use the Create deployment page in the AWS CodeDeploy console or the AWS CLI create-deployment command to deploy your revision from your GitHub repository to target instances configured for use in AWS CodeDeploy deployments.

    If you want to call the create-deployment command, you must first use the Create deployment page of the console to give AWS CodeDeploy permission to interact with GitHub on behalf of your preferred GitHub account for the specified application. You only need to do this once per application.

    To learn how to use the Create deployment page to deploy from a GitHub repository, see Create a Deployment with AWS CodeDeploy.

    To learn how to call the create-deployment command to deploy from a GitHub repository, see Create a Deployment (CLI).

    To learn how to prepare instances for use in AWS CodeDeploy deployments, see Working with Instances for AWS CodeDeploy.

For more information, see Tutorial: Use AWS CodeDeploy to Deploy an Application from GitHub.

GitHub Behaviors with AWS CodeDeploy

GitHub Authentication with Applications in AWS CodeDeploy

After you give AWS CodeDeploy permission to interact with GitHub, the association between that GitHub account and application is stored in AWS CodeDeploy. You can link the application to a different GitHub account. You can also revoke permission for AWS CodeDeploy to interact with GitHub.

To link a GitHub account to an application in AWS CodeDeploy

  1. Sign in to the AWS Management Console and open the AWS CodeDeploy console at https://console.aws.amazon.com/codedeploy.

    Note

    Sign in with the same account or IAM user information you used in Getting Started with AWS CodeDeploy.

  2. On the AWS CodeDeploy menu, choose Deployments.

  3. Choose Create deployment.

    Note

    You don't have to create a new deployment. This is currently the only way to link a different GitHub account to an application.

  4. From the Application drop-down list, choose the application you want to link to a different GitHub account.

  5. Next to Repository type, choose My application is stored in GitHub.

  6. In Connect to GitHub, do one of the following:

    • To create a connection for AWS CodeDeploy applications to a GitHub account, sign out of GitHub in a separate web browser tab. In GitHub account, type a name to identify this connection, and then choose Connect to GitHub. The web page prompts you to authorize AWS CodeDeploy to interact with GitHub for your application. Continue to step 2.

    • To use a connection you have already created, in GitHub account, select its name, and then choose Connect to GitHub. Continue to step 4.

    • To create a connection to a different GitHub account, sign out of GitHub in a separate web browser tab. Choose Connect to a different GitHub account, and then choose Connect to GitHub. Continue to step 2.

  7. If you are not already signed in to GitHub, follow the instructions on the Sign in page to sign in with the GitHub account to which you want to link the application.

  8. Choose Authorize application. GitHub gives AWS CodeDeploy permission to interact with GitHub on behalf of the signed-in GitHub account for the selected application.

  9. If you do not want to create a deployment, choose Cancel.

To revoke permission for AWS CodeDeploy to interact with GitHub

  1. Sign in to GitHub using credentials for the GitHub account in which you want to revoke AWS CodeDeploy permission.

  2. Open the GitHub Applications page, locate AWS CodeDeploy in the list of authorized applications, and then follow the GitHub procedure for revoking authorization for an application.

AWS CodeDeploy Interaction with Private and Public GitHub Repositories

AWS CodeDeploy supports the deployment of applications from private and public GitHub repositories. When you give AWS CodeDeploy permission to access GitHub on your behalf, AWS CodeDeploy will have read-write access to all of the private GitHub repositories to which your GitHub account has access. However, AWS CodeDeploy only reads from GitHub repositories. It will not write to any of your private GitHub repositories.

AWS CodeDeploy Interaction with Organization-Managed GitHub Repositories

By default, GitHub repositories that are managed by an organization (as opposed to your account's own private or public repositories) do not grant access to third-party applications, including AWS CodeDeploy. Your deployment will fail if an organization's third-party application restrictions are enabled in GitHub and you attempt to deploy code from its GitHub repository. There are two ways to resolve this issue.

For more information, see About Third-Party Application Restrictions.

Automatically Deploy from GitHub with AWS CodeDeploy

You can trigger a deployment from a GitHub repository whenever the source code changes. For instructions, see Automatically Deploy from GitHub Using AWS CodeDeploy.