Skip to content

About

It is a terraform module respository for connecting the aws account with DCI features.

Resources

Stars

2 stars

Watchers

0 watching

Forks

Repository files navigation

terraform-aws-doit-cloudconnect

Terraform module for connecting AWS accounts with DoiT Cloud Intelligence (DCI) features. Creates IAM resources in the customer's AWS account to grant DoiT cross-account access based on selected features.

What it does

  • Creates an IAM role with a trust policy allowing DoiT to assume it via sts:AssumeRole with an external ID
  • Attaches a core read-only managed policy (always present)
  • Attaches a write managed policy when write features are selected
  • Attaches feature-specific policies for Composer, RealTimeData, Attribute, and Expert Advice
  • Attaches three AWS managed policies: SecurityAudit, AWSSavingsPlansReadOnlyAccess, Billing
  • Registers the account with DoiT CloudConnect after AWS resources are in place

Supported features

Customer feature name Backend ID Type Description
Kubernetes auto connect clusters fsk8s_auto_connect write EKS access entries
PerfectScale for Commitments - Read & Recommend ps4commitment_core write Commitment analysis
PerfectScale for Commitments - Purchases ps4commitment_purchase write Savings Plans purchases
PerfectScale for Spot spot-scaling write Also creates doitintl-asg-opt EventBridge role
Real-time anomalies real-time-data separate policy + bucket notification S3 bucket access and object-created notifications to the DoiT prod SNS account 676206900418 (requires bucket_name and bucket_region config). Topic name is realtime-event-topic-trigger in us-east-1 and realtime-event-topic-trigger-<region> elsewhere.
DCI Composer composer separate policy Broad read-only access for Composer
Expert Advice expert-advice separate resources DoiT Support Gateway (OIDC providers, support roles)
Reflex reflex separate policy Metadata-only read access for DoiT Reflex. AWS-managed job-function/ViewOnlyAccess and AWSSupportAccess (SecurityAudit already attached by core), plus a small policy for the reads they do not cover. Support write actions are denied.
Attribute attribute separate policy Read access for Attribute cost and resource utilization analysis, plus Cost Explorer actions. See Attribute permissions.

Pass the customer feature names in additional_features. The module maps them to the backend IDs shown above when registering the account with DoiT CloudConnect.

Spot Scaling permissions

PerfectScale for Spot grants iam:PassRole, ec2:RunInstances and ec2:TerminateInstances on all resources. This is intentional: the feature converts your existing Auto Scaling groups and launches instances with the instance profiles they already use. Those roles and ASGs are yours, so they can't be enumerated in advance or restricted by DoiT-managed tags.

The role can only be assumed by DoiT's AWS account with your external ID, and the feature is opt-in. Leave PerfectScale for Spot out of additional_features if you don't want to grant these permissions.

Attribute permissions

Attribute mostly reads data. Besides read access for cost and resource utilization analysis, it grants Cost Explorer actions that change account state:

  • ce:UpdateCostAllocationTagsStatus activates or deactivates cost allocation tags. Activated tags appear in your billing data from the time they are activated.
  • ce:StartSavingsPlansPurchaseRecommendationGeneration starts generating Savings Plans purchase recommendations. It does not purchase anything.

Leave Attribute out of additional_features if you don't want to grant these permissions.

Managed policy quota

IAM limits each role to 10 attached managed policies by default. Selecting every optional feature exceeds that limit. The module attaches:

  • always: the core policy plus SecurityAudit, AWSSavingsPlansReadOnlyAccess and Billing
  • one policy each for write features, Real-time anomalies, DCI Composer and Attribute
  • three for Reflex: its own policy plus ViewOnlyAccess and AWSSupportAccess

The quota is only exceeded when write features, Real-time anomalies, DCI Composer, Attribute and Reflex are all selected. In that case, request an increase of the IAM Managed policies per role quota in Service Quotas before running terraform apply.

Prerequisites

  • AWS credentials with permission to create IAM resources and configure S3 bucket notifications for Real-time anomalies
  • External ID from the DoiT Console
  • DoiT API key for the DoiT Terraform provider

Provide the DoiT API key through the DOIT_API_TOKEN environment variable:

export DOIT_API_TOKEN="..."

Do not pass the DoiT API key to this module. The module uses the configured doit provider to register the account with DoiT CloudConnect.

Usage

Read-only (no additional features)

module "doit_cloudconnect" {
  source = "github.com/doitintl/terraform-aws-doit-cloudconnect"

  external_id = var.doit_external_id # from DoiT Console
  account_id  = "123456789012"
}

With write features

module "doit_cloudconnect" {
  source = "github.com/doitintl/terraform-aws-doit-cloudconnect"

  external_id = var.doit_external_id
  account_id  = "123456789012"

  additional_features = ["PerfectScale for Spot", "Kubernetes auto connect clusters"]
}

With resource-scoped features

module "doit_cloudconnect" {
  source = "github.com/doitintl/terraform-aws-doit-cloudconnect"

  external_id = var.doit_external_id
  account_id  = "123456789012"

  additional_features = ["Real-time anomalies"]

  feature_config = {
    real-time-data = {
      bucket_name   = "my-cur-export-bucket"
      bucket_region = "us-east-1"
    }
  }
}

Custom trust policy

Restrict the trust policy to specific IAM roles in the DoiT account instead of the whole account, and/or add further trust statements (for example a time-boxed one). Either input works on its own:

module "doit_cloudconnect" {
  source = "github.com/doitintl/terraform-aws-doit-cloudconnect"

  external_id = var.doit_external_id
  account_id  = "123456789012"

  doit_principal_arns = ["arn:aws:iam::068664126052:role/example-role"]

  additional_trust_policy_statements = [{
    Effect    = "Allow"
    Principal = { AWS = "arn:aws:iam::111111111111:role/example-other-role" }
    Action    = "sts:AssumeRole"
    Condition = {
      StringEquals = { "sts:ExternalId" = var.doit_external_id }
      DateLessThan = { "aws:CurrentTime" = "2026-12-31T00:00:00Z" }
    }
  }]
}

Inputs

Name Description Type Default Required Sensitive
external_id External ID from DoiT Console for trust policy string — yes yes
account_id Customer AWS Account ID (12 digits) string — yes no
doit_account_id DoiT AWS account ID for trust policy string "068664126052" no no
doit_principal_arns Restricts the trust policy to these DoiT IAM role ARNs (must be in doit_account_id) instead of the account root list(string) null no no
additional_trust_policy_statements Extra IAM statements appended to the role trust policy any [] no no
additional_features Customer feature names to enable. The module maps them to DoiT backend feature IDs. list(string) [] no no
feature_config Per-feature configuration map. Real-time anomalies uses the real-time-data key with bucket_name and bucket_region. map(map(string)) {} no no

Outputs

Name Description
role_arn ARN of the created IAM role
role_name Name of the created IAM role
enabled_features List of enabled features
custom_policy_arns Map of policy type to customer-managed policy ARN
aws_managed_policy_arns List of AWS managed policy ARNs attached to the role
support_gateway_role_arn ARN of the DoiT Support Gateway role (null if Expert Advice not enabled)
cloudconnect_time_linked Timestamp returned by DoiT when the account was linked
cloudconnect_supported_features Supported DCI features and permission status returned by DoiT

Requirements

Name Version
Terraform >= 1.3
AWS provider ~> 6.50
DoiT provider >= 1.5.0
Time provider ~> 0.13

The root Terraform configuration using this module must configure the DoiT provider. Prefer DOIT_API_TOKEN instead of hardcoding the API key:

terraform {
  required_providers {
    aws = {
      source  = "hashicorp/aws"
      version = "~> 6.50"
    }
    doit = {
      source  = "doitintl/doit"
      version = ">= 1.5.0"
    }
  }
}

provider "doit" {}

Alternatively, configure the provider with a sensitive Terraform variable:

variable "doit_api_token" {
  type      = string
  sensitive = true
}

provider "doit" {
  api_token = var.doit_api_token
}

License

MIT

About

It is a terraform module respository for connecting the aws account with DCI features.

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages