Skip to content

Commit 1763cfd

Browse files
jacklearyaxelkrastek1-nhs
authored andcommitted
NRL-1188 terraform linting and glue python version update
1 parent d99de77 commit 1763cfd

File tree

11 files changed

+112
-107
lines changed

11 files changed

+112
-107
lines changed
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
module "dev-athena" {
22
source = "../modules/athena"
33
name_prefix = "nhsd-nrlf--dev"
4-
}
4+
}
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
module "dev-glue" {
2-
source = "../modules/glue"
3-
name_prefix = "nhsd-nrlf--dev"
4-
python_version = "3"
5-
}
2+
source = "../modules/glue"
3+
name_prefix = "nhsd-nrlf--dev"
4+
python_version = "3.12.2"
5+
}

terraform/account-wide-infrastructure/modules/athena/athena.tf

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@ resource "aws_athena_database" "reporting-db" {
33

44
bucket = aws_s3_bucket.target-data-bucket.bucket
55

6-
# encryption_configuration {
7-
# encryption_option = "SSE_KMS"
8-
# kms_key = aws_kms_key.athena.arn
9-
# }
6+
# encryption_configuration {
7+
# encryption_option = "SSE_KMS"
8+
# kms_key = aws_kms_key.athena.arn
9+
# }
1010

1111
force_destroy = true
1212
}
@@ -28,4 +28,4 @@ resource "aws_athena_workgroup" "athena" {
2828
}
2929
}
3030

31-
}
31+
}

terraform/account-wide-infrastructure/modules/athena/kms.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ resource "aws_kms_key" "athena" {
44
resource "aws_kms_alias" "athena" {
55
name = "alias/${var.prefix}-athena"
66
target_key_id = aws_kms_key.athena.key_id
7-
}
7+
}

terraform/account-wide-infrastructure/modules/athena/outputs.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ output "bucket" {
88

99
output "database" {
1010
value = aws_athena_database.reporting-db
11-
}
11+
}

terraform/account-wide-infrastructure/modules/athena/s3.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@ resource "aws_s3_bucket_server_side_encryption_configuration" "athena" {
1212
}
1313
}
1414

15-
}
15+
}
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
variable "database" {
2-
description = "What the db will be called"
3-
default = "NRL-Reporting"
2+
description = "What the db will be called"
3+
default = "NRL-Reporting"
44
}
55

66
variable "name_prefix" {
77
type = string
88
description = "The prefix to apply to all resources in the module."
9-
}
9+
}

terraform/account-wide-infrastructure/modules/glue/glue.tf

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,13 @@ resource "aws_glue_crawler" "raw_log_crawler" {
1616
delete_behavior = "LOG"
1717
}
1818
configuration = jsonencode({
19-
"Version":1.0,
20-
"Grouping": {
21-
"TableGroupingPolicy": "CombineCompatibleSchemas"
19+
"Version" : 1.0,
20+
"Grouping" : {
21+
"TableGroupingPolicy" : "CombineCompatibleSchemas"
2222
}
2323
})
2424
}
25-
resource "aws_glue_trigger""raw_log_trigger" {
25+
resource "aws_glue_trigger" "raw_log_trigger" {
2626
name = "org-report-trigger"
2727
type = "ON_DEMAND"
2828
actions {
@@ -46,12 +46,17 @@ resource "aws_glue_job" "glue_job" {
4646
}
4747

4848
default_arguments = {
49-
"--enable-auto-scaling" = "true""--enable-continous-cloudwatch-log" = "true""--datalake-formats" = "delta""--source-path" = "s3://${aws_s3_bucket.dc-source-data-bucket.id}/" # Specify the source S3 path
49+
"--enable-auto-scaling" = "true"
50+
"--enable-continous-cloudwatch-log" = "true"
51+
"--datalake-formats" = "delta"
52+
"--source-path" = "s3://${aws_s3_bucket.source-data-bucket.id}/" # Specify the source S3 path
5053
"--destination-path" = "s3://${aws_s3_bucket.target-data-bucket.id}/" # Specify the destination S3 path
51-
"--job-name" = "poc-glue-job""--enable-continuous-log-filter" = "true""--enable-metrics" = "true"
54+
"--job-name" = "poc-glue-job"
55+
"--enable-continuous-log-filter" = "true"
56+
"--enable-metrics" = "true"
5257
}
5358
}
5459

5560
output "glue_crawler_name" {
5661
value = "s3//${aws_s3_bucket.source-data-bucket.id}/"
57-
}
62+
}
Lines changed: 78 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -1,93 +1,93 @@
1-
resource "aws_iam_role""glue_service_role" {
1+
resource "aws_iam_role" "glue_service_role" {
22
name = "glue_service_role"
33

44
assume_role_policy = jsonencode({
5-
"Version": "2012-10-17",
6-
"Statement": [
7-
{
8-
"Effect": "Allow",
9-
"Principal": {
10-
"Service": "glue.amazonaws.com"
5+
"Version" : "2012-10-17",
6+
"Statement" : [
7+
{
8+
"Effect" : "Allow",
9+
"Principal" : {
10+
"Service" : "glue.amazonaws.com"
1111
},
12-
"Action": "sts:AssumeRole"
13-
}
12+
"Action" : "sts:AssumeRole"
13+
}
1414
]
15-
})
15+
})
1616
}
1717

18-
resource "aws_iam_role_policy""glue_service_role_policy" {
19-
name = "glue_service_role_policy"
20-
role = aws_iam_role.glue_service_role.name
18+
resource "aws_iam_role_policy" "glue_service_role_policy" {
19+
name = "glue_service_role_policy"
20+
role = aws_iam_role.glue_service_role.name
2121
policy = jsonencode({
22-
"Version": "2012-10-17",
23-
"Statement": [
24-
{
25-
"Effect": "Allow",
26-
"Action": [
27-
"glue:*",
28-
"s3:GetBucketLocation",
29-
"s3:ListBucket",
30-
"s3:ListAllMyBuckets",
31-
"s3:GetBucketAcl",
32-
"ec2:DescribeVpcEndpoints",
33-
"ec2:DescribeRouteTables",
34-
"ec2:CreateNetworkInterface",
35-
"ec2:DeleteNetworkInterface",
36-
"ec2:DescribeNetworkInterfaces",
37-
"ec2:DescribeSecurityGroups",
38-
"ec2:DescribeSubnets",
39-
"ec2:DescribeVpcAttribute",
40-
"iam:ListRolePolicies",
41-
"iam:GetRole",
42-
"iam:GetRolePolicy",
43-
"cloudwatch:PutMetricData"
22+
"Version" : "2012-10-17",
23+
"Statement" : [
24+
{
25+
"Effect" : "Allow",
26+
"Action" : [
27+
"glue:*",
28+
"s3:GetBucketLocation",
29+
"s3:ListBucket",
30+
"s3:ListAllMyBuckets",
31+
"s3:GetBucketAcl",
32+
"ec2:DescribeVpcEndpoints",
33+
"ec2:DescribeRouteTables",
34+
"ec2:CreateNetworkInterface",
35+
"ec2:DeleteNetworkInterface",
36+
"ec2:DescribeNetworkInterfaces",
37+
"ec2:DescribeSecurityGroups",
38+
"ec2:DescribeSubnets",
39+
"ec2:DescribeVpcAttribute",
40+
"iam:ListRolePolicies",
41+
"iam:GetRole",
42+
"iam:GetRolePolicy",
43+
"cloudwatch:PutMetricData"
4444
],
45-
"Resource": ["*"]
46-
},
47-
{
48-
"Effect": "Allow",
49-
"Action": ["s3:CreateBucket"],
50-
"Resource": ["arn:aws:s3:::aws-glue-*"]
51-
},
52-
{
53-
"Effect": "Allow",
54-
"Action": ["s3:GetObject", "s3:PutObject", "s3:DeleteObject"],
55-
"Resource": [
56-
"arn:aws:s3:::*/*",
57-
"arn:aws:s3:::*/*aws-glue-*/*"
45+
"Resource" : ["*"]
46+
},
47+
{
48+
"Effect" : "Allow",
49+
"Action" : ["s3:CreateBucket"],
50+
"Resource" : ["arn:aws:s3:::aws-glue-*"]
51+
},
52+
{
53+
"Effect" : "Allow",
54+
"Action" : ["s3:GetObject", "s3:PutObject", "s3:DeleteObject"],
55+
"Resource" : [
56+
"arn:aws:s3:::*/*",
57+
"arn:aws:s3:::*/*aws-glue-*/*"
5858
]
59-
},
60-
{
61-
"Effect": "Allow",
62-
"Action": ["s3:GetObject"],
63-
"Resource": [
64-
"arn:aws:s3:::crawler-public*",
65-
"arn:aws:s3:::aws-glue-*"
59+
},
60+
{
61+
"Effect" : "Allow",
62+
"Action" : ["s3:GetObject"],
63+
"Resource" : [
64+
"arn:aws:s3:::crawler-public*",
65+
"arn:aws:s3:::aws-glue-*"
6666
]
67-
},
68-
{
69-
"Effect": "Allow",
70-
"Action": [
71-
"logs:CreateLogGroup",
72-
"logs:CreateLogStream",
73-
"logs:PutLogEvents"
67+
},
68+
{
69+
"Effect" : "Allow",
70+
"Action" : [
71+
"logs:CreateLogGroup",
72+
"logs:CreateLogStream",
73+
"logs:PutLogEvents"
7474
],
75-
"Resource": ["arn:aws:logs:*:*:*:/aws-glue/*"]
76-
},
77-
{
78-
"Effect": "Allow",
79-
"Action": ["ec2:CreateTags", "ec2:DeleteTags"],
80-
"Condition": {
81-
"ForAllValues:StringEquals": {
82-
"aws:TagKeys": ["aws-glue-service-resource"]
83-
}
75+
"Resource" : ["arn:aws:logs:*:*:*:/aws-glue/*"]
76+
},
77+
{
78+
"Effect" : "Allow",
79+
"Action" : ["ec2:CreateTags", "ec2:DeleteTags"],
80+
"Condition" : {
81+
"ForAllValues:StringEquals" : {
82+
"aws:TagKeys" : ["aws-glue-service-resource"]
83+
}
8484
},
85-
"Resource": [
86-
"arn:aws:ec2:*:*:network-interface/*",
87-
"arn:aws:ec2:*:*:security-group/*",
88-
"arn:aws:ec2:*:*:instance/*"
85+
"Resource" : [
86+
"arn:aws:ec2:*:*:network-interface/*",
87+
"arn:aws:ec2:*:*:security-group/*",
88+
"arn:aws:ec2:*:*:instance/*"
8989
]
90-
}
90+
}
9191
]
92-
})
93-
}
92+
})
93+
}

terraform/account-wide-infrastructure/modules/glue/s3.tf

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,9 @@ resource "aws_s3_bucket" "code-bucket" {
1414
bucket = "code-bucket"
1515
}
1616

17-
resource "aws_s3_bucket_object""code-data-object" {
17+
resource "aws_s3_bucket_object" "code-data-object" {
1818
bucket = aws_s3_bucket.code-bucket.bucket
1919
key = "main.py"
2020
source = "${path.module}/src/main.py"
21-
etag = "${filemd5("${path.module}/src/main.py")}"
22-
}
21+
etag = filemd5("${path.module}/src/main.py")
22+
}

0 commit comments

Comments
 (0)