Skip to content

Commit 46c7c14

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

File tree

3 files changed

+77
-7
lines changed

3 files changed

+77
-7
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/[email protected]
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/[email protected]
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

main.tf

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ data "aws_ssm_parameter" "rds" {
1515
module "postgres_security_group" {
1616
source = "terraform-aws-modules/security-group/aws"
1717
version = "~> 5.3.0"
18+
providers = {
19+
aws = aws
20+
}
21+
1822

1923
name = local.rds.sg_name
2024
description = local.rds.sg_description
@@ -45,6 +49,9 @@ module "postgres_security_group" {
4549
module "kong_rds" {
4650
source = "terraform-aws-modules/rds/aws"
4751
version = "~> 6.13.0"
52+
providers = {
53+
aws = aws
54+
}
4855

4956
identifier = local.rds.db_identifier
5057
engine = local.rds.engine
@@ -86,6 +93,9 @@ module "kong_rds" {
8693
module "internal_alb_security_group" {
8794
source = "terraform-aws-modules/security-group/aws"
8895
version = "~> 5.3.0"
96+
providers = {
97+
aws = aws
98+
}
8999

90100
name = local.kong.alb_sg_name
91101
vpc_id = var.vpc_id
@@ -113,6 +123,9 @@ module "internal_alb_security_group" {
113123
module "public_alb_security_group" {
114124
source = "terraform-aws-modules/security-group/aws"
115125
version = "~> 5.3.0"
126+
providers = {
127+
aws = aws
128+
}
116129

117130
name = local.kong.alb_sg_name
118131
vpc_id = var.vpc_id
@@ -143,6 +156,9 @@ module "public_alb_security_group" {
143156
module "ecs_task_security_group" {
144157
source = "terraform-aws-modules/security-group/aws"
145158
version = "~> 5.3.0"
159+
providers = {
160+
aws = aws
161+
}
146162

147163
name = local.kong.ecs_task_sg_name
148164
vpc_id = var.vpc_id
@@ -206,6 +222,11 @@ module "ecs_kong" {
206222
source = "infraspecdev/ecs-deployment/aws"
207223
version = "4.3.6"
208224

225+
providers = {
226+
aws = aws
227+
aws.cross_account_provider = aws.cross_account_provider
228+
}
229+
209230
vpc_id = var.vpc_id
210231
cluster_name = data.aws_ecs_cluster.this.cluster_name
211232

@@ -314,11 +335,6 @@ module "ecs_kong" {
314335
}
315336

316337
create_acm = true
317-
318-
providers = {
319-
aws = aws
320-
aws.cross_account_provider = aws.cross_account_provider
321-
}
322338
acm_certificates = {
323339
(local.kong.public_acm_certificate) = {
324340
domain_name = var.kong_public_domain_name

0 commit comments

Comments
 (0)