> ## Documentation Index
> Fetch the complete documentation index at: https://docs.nofire.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# AWS

> Connect your AWS account with NOFire AI

Connecting your AWS account to NOFire AI enables automatic discovery and monitoring of your AWS infrastructure across multiple regions. NOFire AI discovers:

* **RDS Instances** - MySQL, PostgreSQL, MariaDB, Oracle, SQL Server databases
* **Aurora Clusters** - Including cluster members and read replicas
* **ElastiCache Clusters** - Redis and Memcached deployments
* **Lambda Functions** - Serverless functions with complete configuration
* **Multi-Region Support** - Discover resources across all your specified AWS regions

This metadata enhances NOFire AI's understanding of your infrastructure landscape, enabling deeper context for investigations and root cause analysis.

To ensure a smooth integration, we follow AWS's best practices by utilizing an assumed [role](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_create_for-custom.html) and [external ID](https://docs.aws.amazon.com/IAM/latest/UserGuide/id_roles_common-scenarios_third-party.html) for secure access.

## Step 1: Create IAM Role

<Accordion title="Navigate to AWS IAM console" defaultOpen>
  Access the AWS Management Console using an account that has the necessary permissions to create IAM roles. Then, proceed with the steps outlined below:

  1. **Access IAM:** Navigate to the IAM service in the AWS console.
  2. **Create a new role**: In the navigation pane on the left, choose **Roles** > **Create role**.

       <img src="https://mintcdn.com/nofireai/wh5897D8Wg6Di6JO/images/nofireai-create-role.png?fit=max&auto=format&n=wh5897D8Wg6Di6JO&q=85&s=9d0c7e87f9c52b55cc8ad36b9948f7fd" alt="nofireai-create-role.png" width="1628" height="632" data-path="images/nofireai-create-role.png" />
  3. **Enter credentials**:

     * **Add NOFire AI's Account ID**: In the **Account ID** input box, paste the NOFire AI AWS Account ID: **593113792344**. This will give us access to the IAM role.
     * **Add an External ID**: Under **Options**, enter a unique external ID (you'll need this later). You can generate one or use the one provided in the NOFire AI dashboard.

       <img src="https://mintcdn.com/nofireai/wh5897D8Wg6Di6JO/images/nofireai-aws-console-provider.png?fit=max&auto=format&n=wh5897D8Wg6Di6JO&q=85&s=7a4f8ee95e62c68b04e994983d6dcf47" alt="NOFire AI Aws Console Provider Pn" width="1799" height="1292" data-path="images/nofireai-aws-console-provider.png" />
  4. **Assign permissions:** On the permissions console, search for and attach these **AWS managed policies**:

     * **ReadOnlyAccess** - Provides comprehensive readonly access across all AWS services
     * **CloudWatchLogsReadOnlyAccess** - Enables log querying and analysis
     * **AmazonRDSPerformanceInsightsReadOnly** - Provides deep RDS database performance insights

       <Tip>
         AWS managed policies are automatically maintained and updated by AWS, ensuring you always have the latest permissions for new services without manual updates.
       </Tip>

     Search for "ReadOnlyAccess" in the AWS managed policies, select it, then repeat for the other two policies. Click **Next** when done.

       <img src="https://mintcdn.com/nofireai/wh5897D8Wg6Di6JO/images/nofireai-create-rolepermissions.png?fit=max&auto=format&n=wh5897D8Wg6Di6JO&q=85&s=52e681fccda247c440a39f4a05e372c1" alt="NOFire AI Create Rolepermissions Pn" width="1453" height="605" data-path="images/nofireai-create-rolepermissions.png" />
  5. **Finalize and review**:

     * **Role name**: Enter a descriptive name (e.g., `nofireai-readonly-role`)
     * **Description**: Add an optional description (e.g., "NOFire AI readonly access for infrastructure discovery")
     * Review the three attached policies and trust relationship

       <img src="https://mintcdn.com/nofireai/wh5897D8Wg6Di6JO/images/nofireai-create-role-namereview.png?fit=max&auto=format&n=wh5897D8Wg6Di6JO&q=85&s=08ba64727a8ada8edeef824c25d5ed0c" alt="NOFire AI Create Role Namereview Pn" width="1434" height="1482" data-path="images/nofireai-create-role-namereview.png" />
  6. If everything looks correct, click the **Create role** button at the bottom right corner.
  7. **Copy the Role ARN**: Once the role is created, navigate to it and copy the role ARN. You'll need this to complete the connection setup on the NOFire AI dashboard.

       <img src="https://mintcdn.com/nofireai/ws2Z4vL95N8YSpBD/images/nofireai-iam-summary-copy-arn.png?fit=max&auto=format&n=ws2Z4vL95N8YSpBD&q=85&s=08ddfef8a4c7bc9f94e00d146db4bfea" alt="NOFire AI Iam Summary Copy Arn Pn" width="1514" height="358" data-path="images/nofireai-iam-summary-copy-arn.png" />
</Accordion>

<Accordion title="Alternative: Create role using AWS CLI" defaultOpen="false">
  For automation or scripting, you can create the IAM role using the AWS CLI:

  ```bash theme={null}
  # Set your variables
  NOFIREAI_ACCOUNT_ID="593113792344"
  EXTERNAL_ID="your-unique-external-id"
  ROLE_NAME="nofireai-readonly-role"

  # Create trust policy
  cat > trust-policy.json <<EOF
  {
    "Version": "2012-10-17",
    "Statement": [{
      "Effect": "Allow",
      "Principal": {"AWS": "arn:aws:iam::${NOFIREAI_ACCOUNT_ID}:root"},
      "Action": "sts:AssumeRole",
      "Condition": {"StringEquals": {"sts:ExternalId": "${EXTERNAL_ID}"}}
    }]
  }
  EOF

  # Create role and attach policies
  aws iam create-role \
    --role-name ${ROLE_NAME} \
    --assume-role-policy-document file://trust-policy.json \
    --description "NOFire AI readonly access for infrastructure discovery"

  # Attach managed policies
  aws iam attach-role-policy \
    --role-name ${ROLE_NAME} \
    --policy-arn arn:aws:iam::aws:policy/ReadOnlyAccess

  aws iam attach-role-policy \
    --role-name ${ROLE_NAME} \
    --policy-arn arn:aws:iam::aws:policy/CloudWatchLogsReadOnlyAccess

  aws iam attach-role-policy \
    --role-name ${ROLE_NAME} \
    --policy-arn arn:aws:iam::aws:policy/AmazonRDSPerformanceInsightsReadOnly

  # Get Role ARN
  aws iam get-role --role-name ${ROLE_NAME} --query 'Role.Arn' --output text
  ```
</Accordion>

<Accordion title="Alternative: Create role using Terraform" defaultOpen="false">
  If you manage infrastructure with Terraform, copy the module below into your configuration. Set `external_id` to the value shown in the NOFire AI dashboard — keep it secret and never commit it to version control.

  ```hcl theme={null}
  variable "external_id" {
    type        = string
    description = "External ID provided by NOFire AI for the trust policy condition."
    sensitive   = true
  }

  variable "role_name" {
    type        = string
    default     = "nofireai-readonly-role"
    description = "IAM role name assumed by NOFire AI."
  }

  locals {
    nofireai_account_id = "593113792344"
  }

  data "aws_iam_policy_document" "nofireai_trust" {
    statement {
      effect  = "Allow"
      actions = ["sts:AssumeRole"]

      principals {
        type        = "AWS"
        identifiers = ["arn:aws:iam::${local.nofireai_account_id}:root"]
      }

      condition {
        test     = "StringEquals"
        variable = "sts:ExternalId"
        values   = [var.external_id]
      }
    }
  }

  resource "aws_iam_role" "nofireai" {
    name               = var.role_name
    assume_role_policy = data.aws_iam_policy_document.nofireai_trust.json
  }

  resource "aws_iam_role_policy_attachment" "readonly" {
    role       = aws_iam_role.nofireai.name
    policy_arn = "arn:aws:iam::aws:policy/ReadOnlyAccess"
  }

  resource "aws_iam_role_policy_attachment" "cloudwatch_logs" {
    role       = aws_iam_role.nofireai.name
    policy_arn = "arn:aws:iam::aws:policy/CloudWatchLogsReadOnlyAccess"
  }

  resource "aws_iam_role_policy_attachment" "rds_performance_insights" {
    role       = aws_iam_role.nofireai.name
    policy_arn = "arn:aws:iam::aws:policy/AmazonRDSPerformanceInsightsReadOnly"
  }

  output "nofireai_role_arn" {
    value       = aws_iam_role.nofireai.arn
    description = "Role ARN to share with NOFire AI."
  }
  ```

  Apply the configuration and copy the role ARN from the `nofireai_role_arn` output:

  ```bash theme={null}
  terraform apply -var="external_id=<your-external-id>"
  terraform output nofireai_role_arn
  ```
</Accordion>

## Step 2: Add AWS Connection to NOFire AI

<Accordion title="Navigate to the Connections Tab" defaultOpen>
  1. **Select AWS:** From the list of available connections, select AWS.

     Click **Next** at the top right corner.

       <img src="https://mintcdn.com/nofireai/Nk0CfRdb7TV6Ga_A/images/nofireai-cloud-provider-select.png?fit=max&auto=format&n=Nk0CfRdb7TV6Ga_A&q=85&s=3031aee7480ab6437505661e33e9f3be" alt="NOFire AI Cloud Provider Select Pn" width="897" height="351" data-path="images/nofireai-cloud-provider-select.png" />
  2. **Enter connection details:**
     * **Connection name** - A descriptive name for this connection (e.g., "Production AWS", "Staging Environment")
     * **Role ARN** - The IAM role ARN you copied from AWS (e.g., `arn:aws:iam::123456789012:role/nofireai-readonly-role`)
     * **External ID** - The unique external ID you used when creating the role
     * **Regions** - Select one or more AWS regions to discover (e.g., us-east-1, us-west-2, eu-west-1)

         <img src="https://mintcdn.com/nofireai/Nk0CfRdb7TV6Ga_A/images/nofireai-aws-connection-dashboard.png?fit=max&auto=format&n=Nk0CfRdb7TV6Ga_A&q=85&s=6930d052b87d3f757be6b89a94a8d3c6" alt="NOFire AI Aws Connection Dashboard Pn" width="362" height="721" data-path="images/nofireai-aws-connection-dashboard.png" />

         <Tip>
           Only select regions where you have active resources to optimize discovery time and reduce costs.
         </Tip>

       Click **Save** to create the connection.
  3. **Connection initialization:** Once the connection is established, NOFire AI automatically:

     * Validates the IAM role and permissions
     * Discovers RDS instances, Aurora clusters, ElastiCache clusters, and Lambda functions across specified regions
     * Builds the infrastructure graph and tracks relationships
     * Updates the connection status to **READY** when complete

     You can monitor the connection status in the Connections dashboard.
</Accordion>
