Skip to content

Commit 986f9ad

Browse files
author
rahul-infra
committed
Made changes in main.tf.
1 parent 7543256 commit 986f9ad

File tree

3 files changed

+102
-2
lines changed

3 files changed

+102
-2
lines changed

.github/workflows/terraform-checks.yaml

Lines changed: 56 additions & 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.14.0"
18+
terraform_version: "1.13.0"
1919

2020
- name: Initialize Terraform
2121
id: init
@@ -25,6 +25,27 @@ jobs:
2525
id: fmt
2626
run: terraform test
2727

28+
validateExamples:
29+
name: Terraform Validate Examples
30+
runs-on: ubuntu-latest
31+
32+
steps:
33+
- name: Checkout
34+
uses: actions/checkout@v4
35+
36+
- name: Setup Terraform
37+
uses: hashicorp/setup-terraform@v3
38+
with:
39+
terraform_version: "1.6.0"
40+
41+
- name: Validate all example folders
42+
run: |
43+
for dir in examples/*/; do
44+
echo "Validating $dir"
45+
terraform -chdir="$dir" init -input=false > /dev/null
46+
terraform -chdir="$dir" validate
47+
done
48+
2849
collectInputs:
2950
name: Collect workflow inputs
3051
needs: test
@@ -64,6 +85,23 @@ jobs:
6485
with:
6586
directory: ${{ matrix.directory }}
6687

88+
- name: Inject CI provider configs
89+
run: |
90+
echo "Injecting provider configs for CI..."
91+
for dir in examples/*/; do
92+
cat <<EOF > $dir/ci-providers.tf
93+
provider "aws" {
94+
region = "ap-south-1"
95+
}
96+
97+
provider "aws" {
98+
alias = "cross_account_provider"
99+
region = "ap-south-1"
100+
}
101+
EOF
102+
done
103+
104+
67105
- name: Pre-commit Terraform ${{ steps.minMax.outputs.minVersion }}
68106
# Run only validate pre-commit check on min version supported
69107
if: ${{ matrix.directory != '.' }}
@@ -105,6 +143,23 @@ jobs:
105143
id: minMax
106144
uses: clowdhaus/terraform-min-max@v2.1.0
107145

146+
- name: Inject CI provider configs
147+
run: |
148+
echo "Injecting provider configs for CI..."
149+
for dir in examples/*/; do
150+
cat <<EOF > $dir/ci-providers.tf
151+
provider "aws" {
152+
region = "ap-south-1"
153+
}
154+
155+
provider "aws" {
156+
alias = "cross_account_provider"
157+
region = "ap-south-1"
158+
}
159+
EOF
160+
done
161+
162+
108163
- name: Pre-commit Terraform ${{ steps.minMax.outputs.maxVersion }}
109164
uses: clowdhaus/terraform-composite-actions/pre-commit@v1.14.0
110165
with:

examples/same-account/main.tf

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ provider "aws" {
22
region = var.region
33
}
44

5-
65
module "kong" {
76
source = "../../"
87

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
provider "aws" {
2+
region = "ap-south-1"
3+
}
4+
5+
run "kong_db_connection_test" {
6+
command = plan
7+
8+
module {
9+
source = "../"
10+
}
11+
12+
variables {
13+
vpc_id = "vpc-1234567890abcdef"
14+
public_subnet_ids = ["subnet-111111111", "subnet-222222222"]
15+
private_subnet_ids = ["subnet-333333333", "subnet-444444444"]
16+
kong_public_domain_name = "kong-public.example.com"
17+
kong_admin_domain_name = "kong-admin.example.com"
18+
postgres_major_engine_version = 17
19+
postgres_engine_version = 17.4
20+
}
21+
22+
assert {
23+
condition = can(output.kong_rds_instance_endpoint)
24+
error_message = "Kong RDS endpoint output is missing"
25+
}
26+
27+
assert {
28+
condition = regex("^.*\\.rds\\.amazonaws\\.com$", output.kong_rds_instance_endpoint)
29+
error_message = "Kong RDS endpoint output format is invalid"
30+
}
31+
32+
assert {
33+
condition = can(output.kong_ecs_service_arn)
34+
error_message = "ECS service ARN is missing"
35+
}
36+
37+
assert {
38+
condition = can(output.kong_public_alb_dns_name)
39+
error_message = "Kong public ALB DNS output is missing"
40+
}
41+
42+
assert {
43+
condition = can(output.kong_ecs_service_arn) && can(output.kong_rds_instance_endpoint)
44+
error_message = "ECS service and RDS endpoint not linked properly"
45+
}
46+
}

0 commit comments

Comments
 (0)