Skip to content

Commit 8b7e557

Browse files
author
rahul-infra
committed
feat: Introduce cross-account provider configuration allowing Route53 records to be managed in a separate AWS account from the Kong deployment.
updated terraform version.
1 parent 75b6c73 commit 8b7e557

27 files changed

+473
-44
lines changed

.github/workflows/terraform-checks.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ jobs:
1515
- name: Setup Terraform
1616
uses: hashicorp/setup-terraform@v3
1717
with:
18-
terraform_version: "1.13.1"
18+
terraform_version: "1.14.0"
1919

2020
- name: Initialize Terraform
2121
id: init

.github/workflows/terraform-docs.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
- name: Checkout repository
2222
uses: actions/checkout@v5
2323
with:
24-
ref: ${{ github.event_name == 'pull_request' && github.head_ref || github.ref }}
24+
ref: ${{ github.event_name == 'pull_request' && github.head_ref || github.event.pull_request.head.ref || github.ref }}
2525
token: ${{ secrets.GITHUB_TOKEN }}
2626

2727
- name: Render and Push terraform docs for main module

.pre-commit-config.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@ repos:
2020
- '--args=--only=terraform_workspace_remote'
2121
- '--args=--only=terraform_unused_required_providers'
2222
- id: terraform_validate
23+
args:
24+
- --hook-config=--retry-once-with-cleanup=true
25+
files: ^examples/
2326
- repo: https://github.com/pre-commit/pre-commit-hooks
2427
rev: v6.0.0
2528
hooks:

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Terraform Module to setup Kong(OSS) in ECS with self managed EC2 instances.
99

1010
# Assumptions
1111

12-
This setup assumes that the `ECS cluster` that has `Auto Scaling Group (ASG)` exist with the name `default`. If you are using different name, you can provide those in the variables section of your Terraform configuration.
12+
This setup assumes that the `ECS cluster` that has `Auto Scaling Group (ASG)` exist with the name `default`. If you are using different name, you can provide those in the variables section of your Terraform configuration.This module also have a provision that your hosted zone can be in same amazon account where your resources are going to create or in a different amazon account. So, if you are having hosted zone in a different account you need to pass IAM role ARN for cross-account Route53 access.
1313

1414
## Adding Parameters to AWS Systems Manager Parameter Store
1515

examples/complete/.header.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,10 @@ cpu_for_kong_task = 512
4040
memory_for_kong_task = 1024
4141
desired_count_for_kong_service = 2
4242
force_new_deployment = true
43+
postgres_engine_version = 16.3
44+
postgres_major_engine_version = 16
45+
route53_assume_role_arn = arn:aws:iam::aws-account-id:role/role-name
46+
region = us-east-1
4347
```
4448

4549
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.

examples/complete/README.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,28 @@
11
<!-- BEGIN_TF_DOCS -->
2+
# Complete Example
3+
4+
This example demonstrates a **production-ready Kong deployment** with all configurable options, including RDS settings, ECS task configuration, monitoring, and cross-account Route53 support.
5+
6+
## Use Case
7+
8+
Use this example when you need:
9+
- Full control over RDS database configuration (instance class, storage, backup retention, multi-AZ, etc.)
10+
- Custom ECS task settings (CPU, memory, logging)
11+
- Performance insights and monitoring
12+
- Production-grade setup with deletion protection and backups
13+
- Flexible Route53 DNS configuration (same-account or cross-account)
14+
15+
## Key Features
16+
17+
- Comprehensive RDS PostgreSQL configuration with performance insights
18+
- Multi-AZ deployment support for high availability
19+
- Customizable ECS task resources and logging
20+
- SSL/TLS configuration with custom SSL policies
21+
- Cross-account Route53 support via assume role
22+
- Production backup and maintenance windows
23+
24+
## Usage
25+
226
### Example Variable Values
327

428
Here is an example of how to define the variable values in your `terraform.tfvars` file:

examples/complete/main.tf

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,24 @@
1+
provider "aws" {
2+
region = var.region
3+
}
4+
5+
provider "aws" {
6+
alias = "cross_account_provider"
7+
region = var.region
8+
assume_role {
9+
role_arn = var.route53_assume_role_arn
10+
}
11+
}
12+
13+
114
module "kong" {
215
source = "../../"
316

17+
providers = {
18+
aws = aws
19+
aws.cross_account_provider = aws.cross_account_provider
20+
}
21+
422
vpc_id = var.vpc_id
523
public_subnet_ids = var.public_subnet_ids
624
private_subnet_ids = var.private_subnet_ids
@@ -30,4 +48,5 @@ module "kong" {
3048
force_new_deployment = var.force_new_deployment
3149
postgres_engine_version = var.postgres_engine_version
3250
postgres_major_engine_version = var.postgres_major_engine_version
51+
route53_assume_role_arn = var.route53_assume_role_arn
3352
}

examples/complete/variables.tf

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,3 +132,13 @@ variable "postgres_major_engine_version" {
132132
description = "The major version of the Postgres engine"
133133
type = number
134134
}
135+
136+
variable "route53_assume_role_arn" {
137+
description = "IAM role ARN for cross-account Route53 access."
138+
type = string
139+
}
140+
141+
variable "region" {
142+
description = "The AWS region"
143+
type = string
144+
}

examples/complete/versions.tf

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
11
terraform {
22
required_version = ">= 1.13.0"
3+
4+
required_providers {
5+
aws = {
6+
source = "hashicorp/aws"
7+
version = ">= 6.0"
8+
}
9+
}
310
}

examples/cross-accout/.header.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
### Example Variable Values
2+
3+
Here is an example of how to define the variable values in your `terraform.tfvars` file:
4+
5+
```hcl
6+
vpc_id = "vpc-12345678"
7+
public_subnet_ids = ["subnet-abcdef01", "subnet-abcdef02"]
8+
private_subnet_ids = ["subnet-abcdef03", "subnet-abcdef04"]
9+
kong_public_domain_name = "api.example.com"
10+
kong_admin_domain_name = "admin-api.example.com"
11+
region = "us-east-1"
12+
route53_assume_role_arn = "arn:aws:iam::account-id:role/role-id"
13+
```
14+
15+
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.

0 commit comments

Comments
 (0)