

# Integrations

An integration connects AWS Continuum to a source provider, such as a GitHub organization, a GitLab group, or an Amazon S3 bucket. You create an integration once, and then choose it when you create an environment. The steps to create an integration are the same for every capability. An integration is a shared resource, so you manage it in the navigation pane under **Shared resources**.

The following table shows which capabilities use each integration.


| Integration | Code vulnerabilities | Penetration testing | 
| --- | --- | --- | 
| GitHub | Yes | Yes | 
| GitLab | Yes | Yes | 
| Amazon S3 | Yes | No\* | 

\*You can still provide source code from Amazon S3 in a penetration test. For more information, see [Amazon S3 buckets](pt-getting-started.md#pt-getting-started-source-s3).

**Important**  
Amazon S3 integrations apply only to code vulnerabilities. Penetration testing uses GitHub and GitLab integrations only.

## AWS Continuum IP addresses
<a name="integrations-ip-addresses"></a>

AWS Continuum connects to your source code repositories from a fixed set of IP addresses, one set per AWS Region. The same IP addresses are used for every supported source code provider: GitHub and GitLab. This includes GitLab self-managed instances that are reachable over the public internet.

**Important**  
If your repository provider or the network in front of it restricts access with an IP allow list, add the AWS Continuum IP addresses for your environment's AWS Region to that allow list. Wait a few minutes for the change to take effect, then create the integration. Examples include a GitHub organization IP allow list, a GitLab allowed IP range, or a firewall in front of a self-managed GitLab instance.

The following IP addresses are used to access your connected repositories:
+ US East (N. Virginia) (`us-east-1`)
  + `34.228.181.128`
  + `44.219.176.187`
  + `54.226.244.221`
+ US West (Oregon) (`us-west-2`)
  + `34.212.16.133`
  + `52.89.67.212`
  + `54.187.135.61`

## GitHub
<a name="integrations-github"></a>

To use code hosted in GitHub, create a GitHub integration.

If your GitHub organization restricts access with an IP allow list, first add the AWS Continuum IP addresses. For more information, see [AWS Continuum IP addresses](#integrations-ip-addresses).

Use a GitHub account that can install the GitHub app, or request approval from an organization owner.

**To configure a GitHub integration**

1. Open the AWS Continuum console at [https://console.aws.amazon.com/continuum/](https://console.aws.amazon.com/continuum/).

1. In the navigation pane, under **Shared resources**, choose **Integrations**.

1. Choose **Add integration**.

1. For **Source provider**, select **GitHub**.

1. For **Name**, enter an integration name.

1. For **GitHub account**, select **Personal account** or **Organization**.

1. If you selected **Organization**, enter the GitHub organization name for **Organization name**.

1. If the GitHub app is not installed, choose **Install GitHub app**. Install the app in the account that you selected.

1. If GitHub requires organization approval, wait for an owner to approve the installation.

1. If you opened the GitHub installation tab, close it and return to the AWS Continuum console.

1. Choose **Authorize with GitHub and create**.

1. Complete authorization in the GitHub window.

1. Return to the AWS Continuum console.

1. If the console still shows **Waiting for GitHub** after you authorize, choose **Cancel authorization**. Start authorization again.

After you create the integration, you can choose it when you create an environment. For more information, see [Next steps](#integrations-next-steps).

### Troubleshooting GitHub integrations
<a name="integrations-github-troubleshooting"></a>

#### Incorrect GitHub account
<a name="integrations-github-troubleshooting-account"></a>

An access denied error occurs for one of the following reasons:
+ You installed the GitHub app in your GitHub organization, but you selected **Personal account** instead of **Organization** for **GitHub account**.
+ You selected **Organization**, but you left **Organization name** blank or entered a name that doesn't match the organization that you installed the app in.

To resolve this, do the following:

1. In GitHub, uninstall the app from the organization.

1. In the AWS Continuum console, restart the integration process by choosing **Add integration**. Install and authorize the app in your organization again.

1. For **GitHub account**, select **Organization**.

1. Make sure that the **Organization name** that you enter is exactly the same as the name of the organization that you installed the app in.

1. Choose **Authorize with GitHub and create**.

#### Insufficient GitHub permissions
<a name="integrations-github-troubleshooting-install"></a>

When you install the GitHub app in an organization, the button on the installation page depends on your role. An organization member sees **Authorize & Request**. An organization owner sees **Install & Authorize**.

To verify whether you are a member or an owner, do the following:

1. Go to github.com, and choose your profile.

1. On the menu, choose **Organizations**.

1. Find the organization in the list. GitHub shows whether you are a member or an owner next to the organization name.

To verify the installation, AWS Continuum lists the apps that are installed in the organization. It uses the GitHub account that authorized the app. GitHub allows only organization owners to list installed apps. Registration fails for a member even after an owner approves the installation request of the member.

To resolve this, do one of the following:
+ Have an organization owner complete the whole integration process: install the app, authorize it, and create the integration in the AWS Continuum console.
+ Have an owner change your role in the GitHub organization from member to owner, and then restart the integration process.

## GitLab
<a name="integrations-gitlab"></a>

To use code hosted in GitLab, create a GitLab integration. AWS Continuum supports GitLab.com and self-managed GitLab instances, and connects to GitLab only over HTTPS.

If your GitLab group or self-managed instance restricts access by IP address, first add the AWS Continuum IP addresses. For more information, see [AWS Continuum IP addresses](#integrations-ip-addresses).

A GitLab integration authenticates with a GitLab access token. You can use a personal, group, or project access token for a GitLab group or project. AWS Continuum validates the token when you create the integration. If the token can't access the group or project that you specify, AWS Continuum doesn't create the integration.

**Important**  
For code vulnerabilities, AWS Continuum works only with GitLab groups and projects whose visibility is **Private**. It doesn't support internal or public projects.  
Create a dedicated access token for this integration, and don't reuse it with other tools. If the token has the `self_rotate` scope, AWS Continuum rotates it automatically with a 90-day lifetime. Otherwise, replace the token before it expires. For more information about securing GitLab integrations, see [Security for GitLab integrations in AWS Continuum](gitlab-integration-security.md).

**To configure a GitLab integration**

1. Open the AWS Continuum console at [https://console.aws.amazon.com/continuum/](https://console.aws.amazon.com/continuum/).

1. In the navigation pane, under **Shared resources**, choose **Integrations**.

1. Choose **Add integration**.

1. For **Source provider**, select **GitLab**.

1. For **Name**, enter an integration name.

1. For **GitLab instance**, select **GitLab.com** or a self-managed instance. If you select a self-managed instance, enter the instance URL. The URL must use HTTPS.

1. For **Access token**, enter a personal, group, or project access token with the `api` scope and at least the **Maintainer** role on the group or project.

1. For **What this integration reads**, choose **Group** to read every project in a group, including subgroups. Choose **Project** to read a single project. You can't change this choice after you create the integration.

1. For **Group path** or **Project path**, enter the full path as it appears in the GitLab URL, such as `anycompany/platform` or `anycompany/platform/checkout`.

After you create the integration, you can choose it when you create an environment. For more information, see [Next steps](#integrations-next-steps).

### Using a single project from GitLab
<a name="integrations-gitlab-single-project"></a>

To use only one GitLab project, use a project integration, or use a group integration and select only that project in the environment.

**To use a project integration**

1. When you create the integration, for **What this integration reads**, choose **Project**.

1. For **Project path**, enter the project's full path. Use a personal or project access token with at least the **Maintainer** role on the project.

The integration reads only that project.

**To use a group integration**

1. When you create the environment, for **Integration**, select the group integration.

1. For **Projects**, enter only the project's path, such as `group/project`. The project must be in the integration's group or one of its subgroups.

In the API, a project integration is a `CreateIntegration` request whose `gitlab` configuration sets `targetType` to `PROJECT` and `targetPath` to the project's full path. In `CreateEnvironment`, each entry in `repositorySources` selects one project. Its `repository` value is the project's full path.

## Amazon S3
<a name="integrations-s3"></a>

**Important**  
Amazon S3 integrations apply only to code vulnerabilities. Penetration testing doesn't use them.

Penetration tests can still use content in Amazon S3. Add the bucket in the **Source code and documentation** step of the environment setup instead. For more information, see [Amazon S3 buckets](pt-getting-started.md#pt-getting-started-source-s3).

To scan code stored in Amazon S3, prepare a bucket with your code. Create an AWS Identity and Access Management (IAM) role that grants AWS Continuum access to the bucket. Then create an Amazon S3 integration.

In the following example, replace {{amzn-s3-demo-bucket}} with your bucket name. Replace {{my-app.zip}} with your package file name.

The example source URI is `s3://{{amzn-s3-demo-bucket}}/code/{{my-app.zip}}`. Its object key is `code/{{my-app.zip}}`. The corresponding **Source code base path** value is `code/`.

**To prepare an Amazon S3 source**

1. Create an Amazon S3 bucket in the same account and AWS Region where you enable AWS Continuum.

1. Choose a prefix in the bucket for your source code, such as `code/`. You configure this prefix when creating the environment.

1. Upload your code under the chosen prefix as a .zip package. For instructions on uploading objects, see [Uploading objects](https://docs.aws.amazon.com/AmazonS3/latest/userguide/upload-objects.html) in the *Amazon S3 User Guide*.

1. In the Amazon S3 console, on **Upload: status**, confirm that the upload succeeded. If the upload fails, resolve the error before continuing.

### Granting bucket access
<a name="integrations-s3-role"></a>

As an administrator, create an IAM role in the same account as the bucket. The role path must be `/continuum/integrations/`. The role needs a permissions policy for the bucket and a trust policy so that AWS Continuum can assume the role.

In addition to the read permissions for the console, the IAM principal that creates the integration must have the following permissions:
+ `continuum:CreateIntegration` to create the integration
+ `iam:ListRoles` to select the integration role
+ `s3:ListAllMyBuckets` to browse Amazon S3 buckets
+ `iam:PassRole` to pass the integration role

Restrict `iam:PassRole` to the integration role. Use the `iam:PassedToService` condition key with the value `continuum.amazonaws.com`.

For information about permissions required to create an integration in the console, see [Allowing users to access the AWS Continuum console](security_iam_id-based-policy-examples.md#security_iam_id-based-policy-examples-console).

Save the following JSON permissions policy as `integration-permissions.json`. Use it to let AWS Continuum list the bucket and read source objects and versions under your code and context prefixes. It also grants AWS Continuum permission to upload and read patches under `continuum-patches/`.

Grant `s3:ListBucket` without a condition. AWS Continuum uses this permission to validate access to the bucket when you create the integration.

Use each configured prefix exactly, including any trailing slash. If you omit these values, the defaults are `code/` and `context/`, respectively. Your source files can be stored under other prefixes, but the policy must grant access to those prefixes.

Replace {{bucket-name}} with the bucket used by your integration. Replace {{code-prefix}} with the **Source code base path** value. Replace {{context-prefix}} with the **Knowledge documents base path** value:

```json
{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "ListSourceBucket",
      "Effect": "Allow",
      "Action": [
        "s3:ListBucket"
      ],
      "Resource": "arn:aws:s3:::{{bucket-name}}"
    },
    {
      "Sid": "ReadSourcePrefixes",
      "Effect": "Allow",
      "Action": [
        "s3:GetObject",
        "s3:GetObjectVersion"
      ],
      "Resource": [
        "arn:aws:s3:::{{bucket-name}}/{{code-prefix}}*",
        "arn:aws:s3:::{{bucket-name}}/{{context-prefix}}*"
      ]
    },
    {
      "Sid": "DeliverContinuumPatches",
      "Effect": "Allow",
      "Action": [
        "s3:PutObject",
        "s3:GetObject",
        "s3:GetObjectVersion"
      ],
      "Resource": "arn:aws:s3:::{{bucket-name}}/continuum-patches/*"
    }
  ]
}
```

Use the following trust policy so that the AWS Continuum service principal, `continuum.amazonaws.com`, can assume the role with an external ID. Replace {{external-id}} with the external ID that you enter when creating the integration. Save the policy as `trust-policy.json`:

```json
{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "ContinuumAccess",
      "Effect": "Allow",
      "Principal": {
        "Service": "continuum.amazonaws.com"
      },
      "Action": "sts:AssumeRole",
      "Condition": {
        "StringEquals": {
          "sts:ExternalId": "{{external-id}}"
        }
      }
    }
  ]
}
```

To create the role, configure the AWS CLI with a customer administrator principal that can create the role and attach an inline policy. Save both policy files in the current directory.

If a command fails, resolve the error before continuing. If `create-role` returns `EntityAlreadyExists`, choose an unused role name and use it consistently in these commands.

**To create the integration role (AWS CLI)**

1. Create the role with the required path.

   ```bash
   PROMPT> aws iam create-role \
       --role-name ContinuumIntegrationRole \
       --path /continuum/integrations/ \
       --assume-role-policy-document file://trust-policy.json
   ```

   The command returns details of the new role.

1. Attach the bucket permissions as an inline policy.

   ```bash
   PROMPT> aws iam put-role-policy \
       --role-name ContinuumIntegrationRole \
       --policy-name ContinuumIntegrationAccess \
       --policy-document file://integration-permissions.json
   ```

   This command produces no output on success.

1. Verify that the role's Amazon Resource Name (ARN) includes `role/continuum/integrations/`.

   ```bash
   PROMPT> aws iam get-role \
       --role-name ContinuumIntegrationRole \
       --query 'Role.Arn' \
       --output text
   ```

   The output has the following format, where {{account-id}} is your AWS account ID and {{role-name}} is the role name that you used in the commands:

   ```text
   arn:aws:iam::{{account-id}}:role/continuum/integrations/{{role-name}}
   ```

If a command returns an access denied error, ask your administrator to check your permissions. These commands require `iam:CreateRole`, `iam:PutRolePolicy`, and `iam:GetRole`, respectively.

For information about diagnosing policies that deny access, see [Troubleshoot access denied error messages](https://docs.aws.amazon.com/IAM/latest/UserGuide/troubleshoot_access-denied.html) in the *IAM User Guide*.

Changes to IAM roles and policies can take time to become available. Before you use the role to create the integration, allow time for the changes to propagate. For more information, see [Changes that I make are not always immediately visible](https://docs.aws.amazon.com/IAM/latest/UserGuide/troubleshoot_general.html#troubleshoot_general_eventual-consistency) in the *IAM User Guide*.

Keep the role and its policies while an integration uses them. When you no longer need an integration, first update or delete every environment that references it, and then delete the integration. After deleting every integration that uses the role, delete the role and its policies if no other workload uses them. For information about deleting roles, see [Delete roles or instance profiles](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_manage_delete.html) in the *IAM User Guide*.

For more information about external IDs, see [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*.

### Creating Amazon S3 integrations
<a name="integrations-s3-create"></a>

After you prepare the bucket and IAM role, create an Amazon S3 integration. The integration connects the bucket and role so that an environment can access your code.

**To configure an Amazon S3 integration**

1. Open the AWS Continuum console at [https://console.aws.amazon.com/continuum/](https://console.aws.amazon.com/continuum/).

1. In the navigation pane, under **Shared resources**, choose **Integrations**.

1. Choose **Add integration**.

1. For **Source provider**, select Amazon S3.

1. For **Name**, enter an integration name.

1. For **S3 bucket**, choose how to specify the bucket. Do one of the following:
   + To navigate to a bucket, choose **Browse S3**. Select your bucket.
   + To enter an ARN, choose **Enter bucket ARN manually**. For **Bucket ARN**, enter the bucket ARN.

1. For **IAM role ARN**, select the role that you created.

1. For **External ID**, enter the value required by the role's `sts:ExternalId` condition. The integration value must match the trust policy value.

1. Choose **Create integration**.

After you create the integration, you can choose it when you create an environment. For more information, see [Next steps](#integrations-next-steps).

If access validation fails, check the required role path. Verify the integration role trust policy and matching external ID. Check that the role's permissions allow access to the bucket and prefixes that you use.

## Customer managed keys
<a name="integrations-encryption"></a>

When you create a GitHub or GitLab integration, you can specify a customer managed key from AWS Key Management Service (AWS KMS) to encrypt the data that belongs to that integration. This includes the integration's credentials and the content that AWS Continuum handles for the integration, such as pull request submissions. If you don't specify a key, AWS Continuum uses AWS owned keys.

To use a customer managed key, choose the key in the encryption settings when you create the integration. In the API, include the `kmsKeyId` parameter when you call `CreateIntegration`.

**Important**  
Before you create the integration, update the key policy so that AWS Continuum can use the key. You can't add, change, or remove the key of an existing integration. For the required key policy statements, see [Required AWS KMS permissions](encryption-at-rest.md#encryption-at-rest-permissions).

Amazon S3 integrations don't support customer managed keys.

## Next steps
<a name="integrations-next-steps"></a>

After you create an integration, select it when you create an environment:
+ For code vulnerabilities, see [Creating an environment](cv-getting-started.md#cv-getting-started-s3-environment).
+ For penetration testing, see [Creating an environment](pt-getting-started.md#pt-getting-started-environment). Use a GitHub or GitLab integration.