Skip to content

Commit d8399bd

Browse files
committed
style(infrastructure): fixed format and docs
1 parent 61a78b4 commit d8399bd

File tree

7 files changed

+78
-0
lines changed

7 files changed

+78
-0
lines changed

terraform/modules/ecs/main.tf

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,37 @@ terraform {
55
# Set up necessary IAM Roles for ECS Hosts
66

77
data "aws_iam_policy_document" "ecs_cluster_asg_policy" {
8+
statement {
9+
actions = [
10+
"ssmmessages:CreateControlChannel",
11+
"ssmmessages:CreateDataChannel",
12+
"ssmmessages:OpenControlChannel",
13+
"ssmmessages:OpenDataChannel"
14+
]
15+
effect = "Allow"
16+
17+
resources = ["*"]
18+
}
19+
20+
statement {
21+
actions = [
22+
"s3:GetEncryptionConfiguration"
23+
]
24+
effect = "Allow"
25+
resources = ["*"]
26+
}
27+
28+
statement {
29+
30+
actions = [
31+
"kms:Decrypt"
32+
]
33+
34+
effect = "Allow"
35+
36+
resources = ["*"]
37+
}
38+
839
statement {
940
actions = [
1041
"ecs:DeregisterContainerInstance",
@@ -66,6 +97,11 @@ resource "aws_iam_role_policy" "ecs_cluster_asg_policy" {
6697
policy = data.aws_iam_policy_document.ecs_cluster_asg_policy.json
6798
}
6899

100+
resource "aws_iam_role_policy_attachment" "ssm_policy_attachment" {
101+
policy_arn = "arn:aws:iam::aws:policy/AmazonSSMManagedInstanceCore"
102+
role = aws_iam_role.ecs_cluster.name
103+
}
104+
69105
resource "aws_iam_instance_profile" "ecs_cluster_asg_profile" {
70106
name_prefix = "ecs_cluster_asg_profile-"
71107
role = aws_iam_role.ecs_cluster.name

terraform/modules/sg/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
| Name | Description | Type | Default | Required |
1313
|------|-------------|------|---------|:-----:|
14+
| db\_ingress\_cidrs | n/a | `list(string)` | n/a | yes |
1415
| mytags | Tags to include on the resources | `map` | `{}` | no |
1516
| vpc\_id | VPC ID | `any` | n/a | yes |
1617

@@ -20,6 +21,7 @@
2021
|------|-------------|
2122
| alb-sg-id | ALB Security Group ID |
2223
| ecs\_sg\_id | ECS Security Group ID |
24+
| sg\_postgresql\_id | n/a |
2325

2426
<!-- END OF PRE-COMMIT-TERRAFORM DOCS HOOK -->
2527

terraform/modules/sg/main.tf

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,4 +54,31 @@ resource "aws_security_group" "sg-ecs" {
5454
}
5555
}
5656

57+
resource "aws_security_group" "sg_postgresql" {
58+
name = "bmore-responsive-db-access"
59+
vpc_id = var.vpc_id
60+
61+
# Merge tags from environment tfvars and create name tag
62+
tags = merge(map("Name", "bmore-responsive-db-access"), var.mytags)
63+
64+
ingress {
65+
# TLS (change to whatever ports you need)
66+
from_port = 5432
67+
to_port = 5432
68+
protocol = "tcp"
69+
70+
# We open to 0.0.0.0/0 here to support the testing activities.
71+
# In a production environment, these connections would be limited to
72+
# approved internal IPs. (10.x.x.x/x block(s))
73+
cidr_blocks = var.db_ingress_cidrs
74+
}
75+
76+
egress {
77+
from_port = 0
78+
to_port = 0
79+
protocol = "-1"
80+
cidr_blocks = ["0.0.0.0/0"]
81+
}
82+
}
83+
5784
# TODO: Add SG Rules for ECS ASG and Load Balancer.

terraform/modules/sg/outputs.tf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,7 @@ output "alb-sg-id" {
77
description = "ALB Security Group ID"
88
value = aws_security_group.sg-alb.id
99
}
10+
11+
output "sg_postgresql_id" {
12+
value = aws_security_group.sg_postgresql.id
13+
}

terraform/modules/sg/variables.tf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,7 @@ variable "mytags" {
77
type = "map"
88
default = {}
99
}
10+
11+
variable "db_ingress_cidrs" {
12+
type = list(string)
13+
}

terraform/modules/vpc/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
| Name | Description |
2323
|------|-------------|
24+
| private\_subnet\_cidrs | n/a |
2425
| public-subnet-ids | Subnet IDs |
2526
| subnet\_ids | Subnet IDs |
2627
| vpc-id | VPC ID |

terraform/modules/vpc/outputs.tf

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,8 @@ output "subnet_ids" {
1010
output "public-subnet-ids" {
1111
description = "Subnet IDs"
1212
value = aws_subnet.public-subnet.*.id
13+
}
14+
15+
output "private_subnet_cidrs" {
16+
value = var.private_subnet_cidrs
1317
}

0 commit comments

Comments
 (0)