Skip to content

Commit 7eb9457

Browse files
Update version.tf and remove unuse variable (#51)
* feat: update version.tf and remove unuse variable * feat: update version.tf and remove unuse variable * feat: update version.tf and remove unuse variable * feat: update github-action version and use locals in example * feat: update gitinnore and acm version * feat: update tf version
1 parent 8af7e4a commit 7eb9457

16 files changed

+178
-97
lines changed

.github/workflows/auto_assignee.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ on:
77
workflow_dispatch:
88
jobs:
99
assign-pr:
10-
uses: clouddrove/github-shared-workflows/.github/workflows/auto_assignee.yml@master
10+
uses: clouddrove/github-shared-workflows/.github/workflows/auto_assignee.yml@1.0.6
1111
secrets:
1212
GITHUB: ${{ secrets.GITHUB }}
1313
with:

.github/workflows/changelog.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ on:
77
workflow_dispatch:
88
jobs:
99
call-workflow-changelog:
10-
uses: clouddrove/github-shared-workflows/.github/workflows/changelog.yml@master
10+
uses: clouddrove/github-shared-workflows/.github/workflows/changelog.yml@1.0.6
1111
secrets: inherit
1212
with:
1313
branch: 'master'

.github/workflows/tf-checks.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@ on:
66
workflow_dispatch:
77
jobs:
88
tf-checks-complete-example:
9-
uses: clouddrove/github-shared-workflows/.github/workflows/tf-checks.yml@master
9+
uses: clouddrove/github-shared-workflows/.github/workflows/tf-checks.yml@1.0.6
1010
with:
1111
working_directory: './_examples/complete/'
1212
tf-checks-basic-example:
13-
uses: clouddrove/github-shared-workflows/.github/workflows/tf-checks.yml@master
13+
uses: clouddrove/github-shared-workflows/.github/workflows/tf-checks.yml@1.0.6
1414
with:
1515
working_directory: './_examples/vpc_link_api/'

.github/workflows/tflint.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ on:
66
workflow_dispatch:
77
jobs:
88
tf-lint:
9-
uses: clouddrove/test-tfsec/.github/workflows/tflint.yaml@master
9+
uses: clouddrove/test-tfsec/.github/workflows/tflint.yaml@1.0.6
1010
secrets:
1111
GITHUB: ${{ secrets.GITHUB }}

.github/workflows/tfsec.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ on:
55
workflow_dispatch:
66
jobs:
77
tfsec:
8-
uses: clouddrove/github-shared-workflows/.github/workflows/tfsec.yml@master
8+
uses: clouddrove/github-shared-workflows/.github/workflows/tfsec.yml@1.0.6
99
secrets: inherit
1010
with:
1111
working_directory: '.'

_examples/complete/example.tf

+16-18
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,19 @@ provider "aws" {
55
region = "eu-west-1"
66
}
77

8+
locals {
9+
name = "api"
10+
environment = "test"
11+
}
812
####----------------------------------------------------------------------------------
913
## This terraform module is designed to generate consistent label names and tags for resources.
1014
####----------------------------------------------------------------------------------
1115
module "acm" {
1216
source = "clouddrove/acm/aws"
13-
version = "1.3.0"
14-
15-
name = "certificate"
16-
environment = "test"
17-
label_order = ["name", "environment"]
17+
version = "1.4.1"
1818

19+
name = local.name
20+
environment = local.environment
1921
enable_aws_certificate = true
2022
domain_name = "clouddrove.ca"
2123
subject_alternative_names = ["*.clouddrove.ca"]
@@ -30,15 +32,13 @@ module "lambda" {
3032
source = "clouddrove/lambda/aws"
3133
version = "1.3.0"
3234

33-
name = "lambda"
34-
environment = "test"
35-
label_order = ["name", "environment"]
36-
37-
enabled = true
38-
timeout = 60
39-
filename = "./lambda_packages"
40-
handler = "index.lambda_handler"
41-
runtime = "python3.8"
35+
name = local.name
36+
environment = local.environment
37+
enabled = true
38+
timeout = 60
39+
filename = "./lambda_packages"
40+
handler = "index.lambda_handler"
41+
runtime = "python3.8"
4242
iam_actions = [
4343
"logs:CreateLogStream",
4444
"logs:CreateLogGroup",
@@ -72,10 +72,8 @@ module "lambda" {
7272
module "api_gateway" {
7373
source = "./../../"
7474

75-
name = "api"
76-
environment = "test"
77-
label_order = ["environment", "name"]
78-
75+
name = local.name
76+
environment = local.environment
7977
domain_name = "clouddrove.ca"
8078
domain_name_certificate_arn = module.acm.arn
8179
integration_uri = module.lambda.arn

_examples/complete/outputs.tf

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
output "api_id" {
2-
value = join("", module.api_gateway.*.api_id)
2+
value = join("", module.api_gateway[*].api_id)
33
description = "The API identifier."
44
}
55

66
output "api_arn" {
7-
value = join("", module.api_gateway.*.api_arn)
7+
value = join("", module.api_gateway[*].api_arn)
88
description = "The API arn."
99
}
1010

1111
output "api_endpoint" {
12-
value = join("", module.api_gateway.*.api_endpoint)
12+
value = join("", module.api_gateway[*].api_endpoint)
1313
description = "The URI of the API, of the form {api-id}.execute-api.{region}.amazonaws.com."
1414
}
1515

1616
output "invoke_url" {
17-
value = join("", module.api_gateway.*.invoke_url)
17+
value = join("", module.api_gateway[*].invoke_url)
1818
description = "URL to invoke the API pointing to the stage"
1919
}

_examples/complete/test-api.zip

330 Bytes
Binary file not shown.

_examples/complete/versions.tf

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Terraform version
2+
terraform {
3+
required_version = ">= 1.6.1"
4+
5+
required_providers {
6+
aws = {
7+
source = "hashicorp/aws"
8+
version = ">= 5.20.0"
9+
}
10+
}
11+
}

_examples/vpc_link_api/example.tf

+109-37
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,23 @@
44
provider "aws" {
55
region = "eu-west-1"
66
}
7+
8+
locals {
9+
vpc_cidr_block = module.vpc.vpc_cidr_block
10+
additional_cidr_block = "172.16.0.0/16"
11+
name = "api"
12+
environment = "test"
13+
}
714
####----------------------------------------------------------------------------------
815
## A VPC is a virtual network that closely resembles a traditional network that you'd operate in your own data center.
916
####----------------------------------------------------------------------------------
1017
module "vpc" {
1118
source = "clouddrove/vpc/aws"
1219
version = "2.0.0"
1320

14-
name = "vpc"
15-
environment = "test"
16-
label_order = ["name", "environment"]
17-
18-
cidr_block = "172.16.0.0/16"
21+
name = local.name
22+
environment = local.environment
23+
cidr_block = "172.16.0.0/16"
1924
}
2025

2126
####----------------------------------------------------------------------------------
@@ -24,12 +29,10 @@ module "vpc" {
2429
#tfsec:ignore:aws-ec2-no-public-ip-subnet
2530
module "public_subnets" {
2631
source = "clouddrove/subnet/aws"
27-
version = "1.3.0"
28-
29-
name = "public-subnet"
30-
environment = "test"
31-
label_order = ["name", "environment"]
32+
version = "2.0.0"
3233

34+
name = local.name
35+
environment = local.environment
3336
availability_zones = ["eu-west-1b", "eu-west-1c"]
3437
vpc_id = module.vpc.vpc_id
3538
cidr_block = module.vpc.vpc_cidr_block
@@ -41,30 +44,103 @@ module "public_subnets" {
4144
##----------------------------------------------------------------------------------
4245
## Below module will create SECURITY-GROUP and its components.
4346
##----------------------------------------------------------------------------------
44-
#tfsec:ignore:aws-ec2-no-public-ingress-sgr
45-
module "security_group" {
47+
48+
# ################################################################################
49+
# Security Groups module call
50+
################################################################################
51+
52+
module "ssh" {
53+
source = "clouddrove/security-group/aws"
54+
version = "2.0.0"
55+
56+
name = local.name
57+
environment = local.environment
58+
vpc_id = module.vpc.vpc_id
59+
new_sg_ingress_rules_with_cidr_blocks = [{
60+
rule_count = 1
61+
from_port = 22
62+
protocol = "tcp"
63+
to_port = 22
64+
cidr_blocks = [local.vpc_cidr_block, local.additional_cidr_block]
65+
description = "Allow ssh traffic."
66+
}]
67+
68+
## EGRESS Rules
69+
new_sg_egress_rules_with_cidr_blocks = [{
70+
rule_count = 1
71+
from_port = 22
72+
protocol = "tcp"
73+
to_port = 22
74+
cidr_blocks = [local.vpc_cidr_block, local.additional_cidr_block]
75+
description = "Allow ssh outbound traffic."
76+
}]
77+
}
78+
79+
#tfsec:ignore:aws-ec2-no-public-egress-sgr
80+
module "http_https" {
4681
source = "clouddrove/security-group/aws"
4782
version = "2.0.0"
4883

49-
name = "security-group"
50-
environment = "test"
51-
label_order = ["environment", "name"]
52-
vpc_id = module.vpc.vpc_id
53-
allowed_ip = ["0.0.0.0/0"]
54-
allowed_ports = [3306]
84+
name = local.name
85+
environment = local.environment
86+
vpc_id = module.vpc.vpc_id
87+
## INGRESS Rules
88+
new_sg_ingress_rules_with_cidr_blocks = [{
89+
rule_count = 1
90+
from_port = 22
91+
protocol = "tcp"
92+
to_port = 22
93+
cidr_blocks = [local.vpc_cidr_block]
94+
description = "Allow ssh traffic."
95+
},
96+
{
97+
rule_count = 2
98+
from_port = 80
99+
protocol = "tcp"
100+
to_port = 80
101+
cidr_blocks = [local.vpc_cidr_block]
102+
description = "Allow http traffic."
103+
},
104+
{
105+
rule_count = 3
106+
from_port = 443
107+
protocol = "tcp"
108+
to_port = 443
109+
cidr_blocks = [local.vpc_cidr_block]
110+
description = "Allow https traffic."
111+
},
112+
{
113+
rule_count = 3
114+
from_port = 3306
115+
protocol = "tcp"
116+
to_port = 3306
117+
cidr_blocks = [local.vpc_cidr_block]
118+
description = "Allow https traffic."
119+
}
120+
]
121+
122+
## EGRESS Rules
123+
new_sg_egress_rules_with_cidr_blocks = [{
124+
rule_count = 1
125+
from_port = 0
126+
protocol = "-1"
127+
to_port = 0
128+
cidr_blocks = ["0.0.0.0/0"]
129+
ipv6_cidr_blocks = ["::/0"]
130+
description = "Allow all traffic."
131+
}
132+
]
55133
}
56134

57135
####----------------------------------------------------------------------------------
58136
## This terraform module is designed to generate consistent label names and tags for resources.
59137
####----------------------------------------------------------------------------------
60138
module "acm" {
61139
source = "clouddrove/acm/aws"
62-
version = "1.3.0"
63-
64-
name = "certificate"
65-
environment = "test"
66-
label_order = ["name", "environment"]
140+
version = "1.4.1"
67141

142+
name = local.name
143+
environment = local.environment
68144
enable_aws_certificate = true
69145
domain_name = "clouddrove.ca"
70146
subject_alternative_names = ["*.clouddrove.ca"]
@@ -79,15 +155,13 @@ module "lambda" {
79155
source = "clouddrove/lambda/aws"
80156
version = "1.3.0"
81157

82-
name = "lambda"
83-
environment = "test"
84-
label_order = ["name", "environment"]
85-
86-
enabled = true
87-
timeout = 60
88-
filename = "./lambda_packages"
89-
handler = "index.lambda_handler"
90-
runtime = "python3.8"
158+
name = local.name
159+
environment = local.environment
160+
enabled = true
161+
timeout = 60
162+
filename = "./lambda_packages"
163+
handler = "index.lambda_handler"
164+
runtime = "python3.8"
91165
iam_actions = [
92166
"logs:CreateLogStream",
93167
"logs:CreateLogGroup",
@@ -121,17 +195,15 @@ module "lambda" {
121195
module "api_gateway" {
122196
source = "./../../"
123197

124-
name = "api"
125-
environment = "test"
126-
label_order = ["environment", "name"]
127-
198+
name = local.name
199+
environment = local.environment
128200
domain_name = "clouddrove.ca"
129201
create_vpc_link_enabled = true
130202
zone_id = "1`23456059QJZ25345678"
131203
integration_uri = module.lambda.arn
132204
domain_name_certificate_arn = module.acm.arn
133205
subnet_ids = tolist(module.public_subnets.public_subnet_id)
134-
security_group_ids = [module.security_group.security_group_ids]
206+
security_group_ids = [module.ssh.security_group_id, module.http_https.security_group_id]
135207
cors_configuration = {
136208
allow_credentials = true
137209
allow_methods = ["GET", "OPTIONS", "POST"]

_examples/vpc_link_api/outputs.tf

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
output "api_id" {
2-
value = join("", module.api_gateway.*.api_id)
2+
value = join("", module.api_gateway[*].api_id)
33
description = "The API identifier."
44
}
55

66
output "api_arn" {
7-
value = join("", module.api_gateway.*.api_arn)
7+
value = join("", module.api_gateway[*].api_arn)
88
description = "The API arn."
99
}
1010

1111
output "api_endpoint" {
12-
value = join("", module.api_gateway.*.api_endpoint)
12+
value = join("", module.api_gateway[*].api_endpoint)
1313
description = "The URI of the API, of the form {api-id}.execute-api.{region}.amazonaws.com."
1414
}
1515

1616
output "invoke_url" {
17-
value = join("", module.api_gateway.*.invoke_url)
17+
value = join("", module.api_gateway[*].invoke_url)
1818
description = "URL to invoke the API pointing to the stage"
1919
}

_examples/vpc_link_api/versions.tf

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Terraform version
2+
terraform {
3+
required_version = ">= 1.6.1"
4+
5+
required_providers {
6+
aws = {
7+
source = "hashicorp/aws"
8+
version = ">= 5.20.0"
9+
}
10+
}
11+
}

0 commit comments

Comments
 (0)