Skip to content

Commit b6d3fb1

Browse files
Fix terraform lint issues
1 parent 6e6874d commit b6d3fb1

32 files changed

+800
-714
lines changed
+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
---
2+
# Copyright 2022 Samsung Corporation
3+
#
4+
# Licensed under the Apache License, Version 2.0 (the "License");
5+
# you may not use this file except in compliance with the License.
6+
# You may obtain a copy of the License at
7+
#
8+
# http://www.apache.org/licenses/LICENSE-2.0
9+
#
10+
# Unless required by applicable law or agreed to in writing, software
11+
# distributed under the License is distributed on an "AS IS" BASIS,
12+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
# See the License for the specific language governing permissions and
14+
# limitations under the License.
15+
16+
name: Check Terraform scripts
17+
# yamllint disable-line rule:truthy
18+
on:
19+
push:
20+
branches:
21+
- master
22+
paths:
23+
- '**.tf'
24+
pull_request:
25+
branches:
26+
- master
27+
paths:
28+
- '**.tf'
29+
30+
jobs:
31+
check-checkov:
32+
name: Check static code (checkov)
33+
runs-on: ubuntu-latest
34+
steps:
35+
- uses: actions/checkout@v3
36+
- name: Run Checkov action
37+
uses: bridgecrewio/checkov-action@master
38+
with:
39+
directory: ./deployment/terraform/aws
40+
quiet: true
41+
soft_fail: true
42+
framework: terraform
43+
download_external_modules: true
44+
check-lint:
45+
runs-on: ubuntu-latest
46+
steps:
47+
- uses: actions/checkout@v3
48+
- name: Lint Terraform
49+
uses: actionshub/terraform-lint@main
50+
check-terrascan:
51+
runs-on: ubuntu-latest
52+
name: terrascan-action
53+
steps:
54+
- uses: actions/checkout@v3
55+
- name: Run Terrascan
56+
id: terrascan
57+
uses: accurics/terrascan-action@main
58+
with:
59+
iac_type: 'terraform'
60+
only_warn: true

deployment/terraform/aws/main.tf

+59-59
Original file line numberDiff line numberDiff line change
@@ -1,93 +1,93 @@
11
provider "aws" {
2-
alias = "region_1"
3-
region = var.region_1
2+
alias = "region_1"
3+
region = var.region_1
44
}
55

66
provider "aws" {
7-
alias = "region_2"
8-
region = var.region_2
7+
alias = "region_2"
8+
region = var.region_2
99
}
1010

1111
# Validator
1212
module "validator" {
13-
source = "./validator"
14-
providers = {
15-
aws = aws.region_1
16-
}
13+
source = "./validator"
14+
providers = {
15+
aws = aws.region_1
16+
}
1717
}
1818

1919
# Private Sentries
2020
module "private_sentries" {
21-
source = "./private-sentries"
21+
source = "./private-sentries"
2222

23-
providers = {
24-
aws = aws.region_1
25-
aws.peer = aws.region_1
26-
}
23+
providers = {
24+
aws = aws.region_1
25+
aws.peer = aws.region_1
26+
}
2727

28-
peer_vpc = module.validator.vpc
28+
peer_vpc = module.validator.vpc
2929
}
3030

3131
# Public Sentries region 1
3232
module "public_sentries_1" {
33-
source = "./public-sentries"
34-
nodes_count = 1
35-
36-
# enable_ipv6 = false
37-
38-
providers = {
39-
aws = aws.region_1
40-
aws.peer = aws.region_1
41-
}
42-
43-
region_index = 1
44-
peer_vpc = module.private_sentries.vpc
33+
source = "./public-sentries"
34+
nodes_count = 1
35+
36+
# enable_ipv6 = false
37+
38+
providers = {
39+
aws = aws.region_1
40+
aws.peer = aws.region_1
41+
}
42+
43+
region_index = 1
44+
peer_vpc = module.private_sentries.vpc
4545
}
4646

4747
# Public Sentries region 2
4848
module "public_sentries_2" {
49-
source = "./public-sentries"
50-
nodes_count = 1
49+
source = "./public-sentries"
50+
nodes_count = 1
5151

52-
# enable_ipv6 = false
52+
# enable_ipv6 = false
5353

54-
providers = {
55-
aws = aws.region_2
56-
aws.peer = aws.region_1
57-
}
54+
providers = {
55+
aws = aws.region_2
56+
aws.peer = aws.region_1
57+
}
5858

59-
region_index = 2
60-
peer_vpc = module.private_sentries.vpc
59+
region_index = 2
60+
peer_vpc = module.private_sentries.vpc
6161
}
6262

6363
# Observers region 1
6464
module "observers_1" {
65-
source = "./observers"
66-
67-
providers = {
68-
aws = aws.region_1
69-
aws.peer = aws.region_1
70-
}
71-
72-
root_domain_name = var.root_domain_name
73-
enable_tls = var.enable_tls
74-
75-
region_index = 1
76-
peer_vpc = module.private_sentries.vpc
65+
source = "./observers"
66+
67+
providers = {
68+
aws = aws.region_1
69+
aws.peer = aws.region_1
70+
}
71+
72+
root_domain_name = var.root_domain_name
73+
enable_tls = var.enable_tls
74+
75+
region_index = 1
76+
peer_vpc = module.private_sentries.vpc
7777
}
7878

7979
# Observers region 2
8080
module "observers_2" {
81-
source = "./observers"
82-
83-
providers = {
84-
aws = aws.region_2
85-
aws.peer = aws.region_1
86-
}
87-
88-
root_domain_name = var.root_domain_name
89-
enable_tls = var.enable_tls
90-
91-
region_index = 2
92-
peer_vpc = module.private_sentries.vpc
81+
source = "./observers"
82+
83+
providers = {
84+
aws = aws.region_2
85+
aws.peer = aws.region_1
86+
}
87+
88+
root_domain_name = var.root_domain_name
89+
enable_tls = var.enable_tls
90+
91+
region_index = 2
92+
peer_vpc = module.private_sentries.vpc
9393
}
+13-13
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,25 @@
11
resource "aws_acm_certificate" "this_acm_cert" {
2-
count = local.enable_tls ? 1 : 0
2+
count = local.enable_tls ? 1 : 0
33

4-
domain_name = "on.${data.aws_route53_zone.this_zone[0].name}"
5-
validation_method = "DNS"
4+
domain_name = "on.${data.aws_route53_zone.this_zone[0].name}"
5+
validation_method = "DNS"
66
}
77

88
resource "aws_route53_record" "this_acm_val_records" {
9-
count = local.enable_tls ? length(aws_acm_certificate.this_acm_cert[0].domain_validation_options) : 0
9+
count = local.enable_tls ? length(aws_acm_certificate.this_acm_cert[0].domain_validation_options) : 0
1010

11-
name = tolist(aws_acm_certificate.this_acm_cert[0].domain_validation_options)[count.index].resource_record_name
12-
records = [tolist(aws_acm_certificate.this_acm_cert[0].domain_validation_options)[count.index].resource_record_value]
13-
type = tolist(aws_acm_certificate.this_acm_cert[0].domain_validation_options)[count.index].resource_record_type
11+
name = tolist(aws_acm_certificate.this_acm_cert[0].domain_validation_options)[count.index].resource_record_name
12+
records = [tolist(aws_acm_certificate.this_acm_cert[0].domain_validation_options)[count.index].resource_record_value]
13+
type = tolist(aws_acm_certificate.this_acm_cert[0].domain_validation_options)[count.index].resource_record_type
1414

15-
allow_overwrite = true
16-
ttl = 60
17-
zone_id = data.aws_route53_zone.this_zone[0].zone_id
15+
allow_overwrite = true
16+
ttl = 60
17+
zone_id = data.aws_route53_zone.this_zone[0].zone_id
1818
}
1919

2020
resource "aws_acm_certificate_validation" "this_acm_cert_validation" {
21-
count = local.enable_tls ? 1 : 0
21+
count = local.enable_tls ? 1 : 0
2222

23-
certificate_arn = aws_acm_certificate.this_acm_cert[0].arn
24-
validation_record_fqdns = aws_route53_record.this_acm_val_records[*].fqdn
23+
certificate_arn = aws_acm_certificate.this_acm_cert[0].arn
24+
validation_record_fqdns = aws_route53_record.this_acm_val_records[*].fqdn
2525
}

0 commit comments

Comments
 (0)