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
Turbot/AdminorTurbot/Ownerpermissions.- The
awsmod installed. - In the target GovCloud/China account:
- An IAM user with a policy allowing
sts:AssumeRolefor the Guardrails role. - An IAM role with the desired permissions (e.g.,
AdministratorAccess) and a trust policy allowing the IAM user. - An access key pair for the IAM user.
- An External ID configured in the role's trust policy.
- An IAM user with a policy allowing
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:
- Attach
arn:aws:iam::aws:policy/AdministratorAccess
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
- From the Dashboard, select CONNECT (or from Workspace > Accounts, select Import) to open the Create Connection wizard.
- Select AWS, then AWS Account.
- Select the destination folder and click Next.
- Set the Environment to US Government or China Cloud.
- Enter the Role Name and External ID.
- Click Add access key pair and enter the access key ID and secret.
- Enter the IAM Role ARN and click Test Connection.
- Click Connect to import.
Recommended Mods
- aws (required)
- aws-iam
- aws-kms
- aws-ec2
- aws-vpc-core, aws-vpc-internet, aws-vpc-connect, aws-vpc-security
- aws-sns
- aws-cloudtrail
- aws-events