GovCloud and China Accounts

AWS GovCloud (aws-us-gov) and AWS China (aws-cn) accounts are in separate partitions from commercial AWS. Since Guardrails SaaS is hosted in the commercial partition, these accounts require IAM access key pairs for authentication (in addition to the cross-account IAM role).

Prerequisites

Step 1: Create the IAM User

Create an IAM user in the GovCloud/China account with a policy allowing it to assume the Guardrails role:

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Sid": "AssumeRolePolicy",
      "Effect": "Allow",
      "Action": "sts:AssumeRole",
      "Resource": "arn:aws-us-gov:iam::123456789012:role/turbot-import-role"
    }
  ]
}

Generate an access key pair for this user.

Step 2: Create the IAM Role

Create a role with the desired permissions. For full governance:

Configure the trust policy to allow the IAM user and require an External ID:

{
  "Version": "2012-10-17",
  "Statement": [
    {
      "Effect": "Allow",
      "Principal": {
        "AWS": "arn:aws-us-gov:iam::123456789012:user/turbot-import-user"
      },
      "Action": "sts:AssumeRole",
      "Condition": {
        "StringEquals": {
          "sts:ExternalId": "your-external-id"
        }
      }
    }
  ]
}

Step 3: Import via Terraform

# Create the AWS Account resource
resource "turbot_resource" "account_resource" {
  parent   = "id-of-parent-folder"
  type     = "tmod:@turbot/aws#/resource/types/account"
  akas     = ["arn:aws-us-gov:::123456789012"]
  metadata = jsonencode({
    "aws" : {
      "accountId" : "123456789012",
      "partition" : "aws-us-gov"
    }
  })
  data = jsonencode({
    "Id" : "123456789012"
  })
}

# AWS > Account > Turbot IAM Access Key ID
resource "turbot_policy_setting" "turbotIamAccessKeyId" {
  resource = turbot_resource.account_resource.id
  type     = "tmod:@turbot/aws#/policy/types/turbotIamAccessKeyId"
  value    = "AKIA..."
}

# AWS > Account > Turbot IAM Secret Access Key
resource "turbot_policy_setting" "turbotIamSecretAccessKey" {
  resource = turbot_resource.account_resource.id
  type     = "tmod:@turbot/aws#/policy/types/turbotIamSecretAccessKey"
  value    = "your-secret-access-key"
}

# AWS > Account > Turbot IAM Credential Type
resource "turbot_policy_setting" "turbotIamCredentialType" {
  resource = turbot_resource.account_resource.id
  type     = "tmod:@turbot/aws#/policy/types/turbotIamCredentialType"
  value    = "Access Key Pair and Role"
}

# AWS > Account > Turbot IAM Role
resource "turbot_policy_setting" "turbotIamRole" {
  resource = turbot_resource.account_resource.id
  type     = "tmod:@turbot/aws#/policy/types/turbotIamRole"
  value    = "arn:aws-us-gov:iam::123456789012:role/turbot-import-role"
}

# AWS > Account > Turbot IAM Role > External ID
resource "turbot_policy_setting" "turbotIamRoleExternalId" {
  resource = turbot_resource.account_resource.id
  type     = "tmod:@turbot/aws#/policy/types/turbotIamRoleExternalId"
  value    = "your-external-id"
}

Import via the Console

  1. From the Dashboard, select CONNECT (or from Workspace > Accounts, select Import) to open the Create Connection wizard.
  2. Select AWS, then AWS Account.
  3. Select the destination folder and click Next.
  4. Set the Environment to US Government or China Cloud.
  5. Enter the Role Name and External ID.
  6. Click Add access key pair and enter the access key ID and secret.
  7. Enter the IAM Role ARN and click Test Connection.
  8. Click Connect to import.
  1. aws (required)
  2. aws-iam
  3. aws-kms
  4. aws-ec2
  5. aws-vpc-core, aws-vpc-internet, aws-vpc-connect, aws-vpc-security
  6. aws-sns
  7. aws-cloudtrail
  8. aws-events