# GitLab

Firefly integrates with GitLab to connect your infrastructure code repositories with your cloud resources. This integration enables powerful features like tracing cloud resources back to their defining code ("Jump to Code") and automatically creating Merge Requests for newly codified resources and drift remediation.

## Prerequisites

* A GitLab account with access to your infrastructure repositories.
* Appropriate permissions to create OAuth applications.
* Repositories containing Terraform, CloudFormation, or other IaC files you want to connect to Firefly.

## Setup Procedure

1. Log in to your GitLab account.
2. Click on your Avatar icon on the top right panel, then click on **Preferences**.
3. Select **Applications**, and then click on **Add new application**.
4. Select a name for the application.
5. In the **Redirect URI**, please paste the following URL: `https://app.firefly.ai/integrations/gitlab-integration`
6. In the **scope** section, please select the **API** option.

   > **Note**: API must be selected for the integration to be successful.
7. Scroll to the bottom of the page and click **Save application**. You will be directed to a new screen where you can see the Application ID, Secret and Callback URL.
8. Please copy the **Application ID** and paste it in Firefly's GitLab Integration page.
9. Please copy the **Secret** and paste it in Firefly's GitLab Integration page.
10. After filling the information, click the **Authorize** button in Firefly's GitLab Integration page.
11. In the new page that you were directed to, press the **Authorize \<APPLICATION NAME>** button.

    > **Note**: You must authorize the application for the integration to be successful.
12. After authorizing the new application, you will be redirected back to Firefly's application.
13. After the integration is completed, please select the **Project IDs** and/or **Group IDs** for webhooks to be installed from the dropdown menu below the "Authorize" button.

## Features Enabled

* **Jump to Code**: Trace resources in your cloud inventory back to the GitLab file and specific line that defines them.
* **Automated Merge Requests**: When Firefly codifies an unmanaged resource, it can commit the new infrastructure code as a Merge Request.
* **IaC Tracking**: Firefly maintains awareness of which resources are defined in code and which are not.
* **Drift Remediation**: Firefly can detect drift between the code and the actual resources and create a Merge Request to fix it.
* **Workspace Integration**: GitLab can be selected during Workspace creation or modification, enabling seamless integration with associated GitLab repositories.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.firefly.ai/integrations/version-control/gitlab.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
