|
| 1 | +<!-- BEGIN_TF_DOCS --> |
| 2 | +# Cross-Account Example |
| 3 | + |
| 4 | +This example demonstrates Kong deployment with **Route53 hosted zone in a different AWS account** using cross-account IAM role assumption. |
| 5 | + |
| 6 | +## Use Case |
| 7 | + |
| 8 | +Use this example when: |
| 9 | +- Your Route53 hosted zone is managed in a separate AWS account (common in enterprise setups) |
| 10 | +- You have a centralized DNS management account |
| 11 | +- You need to manage DNS records across AWS accounts |
| 12 | +- You follow security best practices with separate accounts for different concerns |
| 13 | + |
| 14 | +## Key Features |
| 15 | + |
| 16 | +- Cross-account Route53 DNS record management |
| 17 | +- IAM role assumption for secure cross-account access |
| 18 | +- Separate provider configuration for DNS operations |
| 19 | +- Minimal configuration with module defaults for other resources |
| 20 | +- Secure cross-account permissions model |
| 21 | + |
| 22 | +## Provider Configuration |
| 23 | + |
| 24 | +This example uses two providers: |
| 25 | +1. **Default provider** - For Kong infrastructure (VPC, ECS, RDS, ALB) |
| 26 | +2. **Cross-account provider** - For Route53 DNS records in a different account |
| 27 | + |
| 28 | +```hcl |
| 29 | +provider "aws" { |
| 30 | + alias = "cross_account_provider" |
| 31 | + region = var.region |
| 32 | + assume_role { |
| 33 | + role_arn = var.route53_assume_role_arn # IAM role in DNS account |
| 34 | + } |
| 35 | +} |
| 36 | +``` |
| 37 | + |
| 38 | +## Prerequisites |
| 39 | + |
| 40 | +1. An IAM role must exist in the Route53 account that allows the Kong account to assume it |
| 41 | +2. The role should have permissions to manage Route53 records |
| 42 | +3. Example trust policy for the IAM role in the DNS account: |
| 43 | + |
| 44 | +```json |
| 45 | +{ |
| 46 | + "Version": "2012-10-17", |
| 47 | + "Statement": [ |
| 48 | + { |
| 49 | + "Effect": "Allow", |
| 50 | + "Principal": { |
| 51 | + "AWS": "arn:aws:iam::KONG_ACCOUNT_ID:root" |
| 52 | + }, |
| 53 | + "Action": "sts:AssumeRole" |
| 54 | + } |
| 55 | + ] |
| 56 | +} |
| 57 | +``` |
| 58 | + |
| 59 | +## Usage |
| 60 | + |
| 61 | +### Example Variable Values |
| 62 | + |
| 63 | +Here is an example of how to define the variable values in your `terraform.tfvars` file: |
| 64 | + |
| 65 | +```hcl |
| 66 | +vpc_id = "vpc-12345678" |
| 67 | +public_subnet_ids = ["subnet-abcdef01", "subnet-abcdef02"] |
| 68 | +private_subnet_ids = ["subnet-abcdef03", "subnet-abcdef04"] |
| 69 | +kong_public_domain_name = "api.example.com" |
| 70 | +kong_admin_domain_name = "admin-api.example.com" |
| 71 | +
|
| 72 | +# Cross-account Route53 IAM role (in the DNS account) |
| 73 | +route53_assume_role_arn = "arn:aws:iam::DNS_ACCOUNT_ID:role/route53-cross-account-role" |
| 74 | +
|
| 75 | +region = "ap-south-1" |
| 76 | +cluster_name = "default" |
| 77 | +``` |
| 78 | + |
| 79 | +Place this `terraform.tfvars` file in the same directory as your Terraform configuration to automatically load these values. Adjust the values as needed to fit your specific environment and requirements. |
| 80 | + |
| 81 | +## Requirements |
| 82 | + |
| 83 | +| Name | Version | |
| 84 | +|------|---------| |
| 85 | +| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.13.0 | |
| 86 | + |
| 87 | +## Providers |
| 88 | + |
| 89 | +No providers. |
| 90 | + |
| 91 | +## Modules |
| 92 | + |
| 93 | +| Name | Source | Version | |
| 94 | +|------|--------|---------| |
| 95 | +| <a name="module_kong"></a> [kong](#module\_kong) | ../../ | n/a | |
| 96 | + |
| 97 | +## Resources |
| 98 | + |
| 99 | +No resources. |
| 100 | + |
| 101 | +## Inputs |
| 102 | + |
| 103 | +| Name | Description | Type | Default | Required | |
| 104 | +|------|-------------|------|---------|:--------:| |
| 105 | +| <a name="input_kong_admin_domain_name"></a> [kong\_admin\_domain\_name](#input\_kong\_admin\_domain\_name) | The admin domain name for Kong | `string` | n/a | yes | |
| 106 | +| <a name="input_kong_public_domain_name"></a> [kong\_public\_domain\_name](#input\_kong\_public\_domain\_name) | The public domain name for Kong | `string` | n/a | yes | |
| 107 | +| <a name="input_private_subnet_ids"></a> [private\_subnet\_ids](#input\_private\_subnet\_ids) | List of private subnet IDs | `list(string)` | n/a | yes | |
| 108 | +| <a name="input_public_subnet_ids"></a> [public\_subnet\_ids](#input\_public\_subnet\_ids) | List of public subnet IDs | `list(string)` | n/a | yes | |
| 109 | +| <a name="input_vpc_id"></a> [vpc\_id](#input\_vpc\_id) | The ID of the VPC | `string` | n/a | yes | |
| 110 | + |
| 111 | +## Outputs |
| 112 | + |
| 113 | +No outputs. |
| 114 | +<!-- END_TF_DOCS --> |
0 commit comments