generated from ministryofjustice/template-repository
-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DPR2-893: Glue connection and placeholder operational datastore secret (
#6670) * DPR2-893: Glue connection and placeholder operational datastore secrets for use in datahub jobs. * DPR2-893: Add data source for operational_datastore secret. * DPR2-893: Fix typo and add in initial attempt at glue connection security group rules * DPR2-893: Fix name * DPR2-893: Fix reference * DPR2-893: Fix to ports in security group * DPR2-893: try removing allow all traffic to any IP. * Revert "DPR2-893: try removing allow all traffic to any IP." This reverts commit 3c5ce9a. * DPR2-893: Remove egress allowed via security group * DPR2-893: Switch to all tcp traffic ingress allowed from same SG * DPR2-893: restrict glue connection and operational datastore secret related resources to development environment only for now.
- Loading branch information
1 parent
1939617
commit b7477ea
Showing
4 changed files
with
91 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
terraform/environments/digital-prison-reporting/operational_datastore.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
resource "aws_glue_connection" "glue_operational_datastore_connection" { | ||
count = (local.environment == "development" ? 1 : 0) | ||
name = "${local.project}-operational-datastore-connection" | ||
connection_type = "JDBC" | ||
|
||
connection_properties = { | ||
# This will be replaced by the details for the real Operational Data Store | ||
JDBC_CONNECTION_URL = "jdbc:postgresql://dpr2-834-instance-1.cja8lnnvvipo.eu-west-2.rds.amazonaws.com:5432/postgres" | ||
SECRET_ID = data.aws_secretsmanager_secret.operational_datastore[0].name | ||
} | ||
|
||
physical_connection_requirements { | ||
availability_zone = data.aws_subnet.private_subnets_a.availability_zone | ||
security_group_id_list = [aws_security_group.glue_operational_datastore_connection_sg[0].id] | ||
subnet_id = data.aws_subnet.private_subnets_a.id | ||
} | ||
} | ||
|
||
resource aws_security_group "glue_operational_datastore_connection_sg" { | ||
count = (local.environment == "development" ? 1 : 0) | ||
name = "${local.project}-operational-datastore-connection_sg" | ||
description = "Security group to allow glue access to Operational Datastore via JDBC Connection" | ||
vpc_id = data.aws_vpc.shared.id | ||
|
||
# This SG is attached to the Glue connection and should also be attached to the Operational Datastore RDS | ||
# See https://docs.aws.amazon.com/glue/latest/dg/setup-vpc-for-glue-access.html | ||
|
||
# A self-referencing inbound rule for all TCP ports to enable AWS Glue to communicate between its components | ||
ingress { | ||
from_port = 0 | ||
to_port = 65535 | ||
protocol = "TCP" | ||
self = true | ||
description = "Security Group can Ingress to itself on all ports - required for Glue to communicate with itself" | ||
} | ||
|
||
# Allow all traffic out | ||
egress { | ||
from_port = 0 | ||
to_port = 0 | ||
protocol = "-1" | ||
cidr_blocks = ["0.0.0.0/0"] | ||
description = "Allow all traffic out from this Security Group" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters