-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
/
Copy pathmain.tf
61 lines (51 loc) · 1.57 KB
/
main.tf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
provider "aws" {
region = "eu-west-1"
}
#############################################################
# Data sources to get VPC and default security group details
#############################################################
data "aws_vpc" "default" {
default = true
}
data "aws_security_group" "default" {
name = "default"
vpc_id = data.aws_vpc.default.id
}
########################################################
# Create SGs
########################################################
resource "aws_security_group" "service_one" {
name = "service_one"
description = "Allow access from service two"
}
resource "aws_security_group" "service_two" {
name = "service_two"
description = "Allow access from service one"
}
########################################################
# Add SG rules
########################################################
module "rules_one" {
source = "../../"
create_sg = false
security_group_id = aws_security_group.service_one.id
ingress_with_source_security_group_id = [
{
description = "http from service two"
rule = "http-80-tcp"
source_security_group_id = aws_security_group.service_two.id
},
]
}
module "rules_two" {
source = "../../"
create_sg = false
security_group_id = aws_security_group.service_two.id
ingress_with_source_security_group_id = [
{
description = "http from service one"
rule = "http-80-tcp"
source_security_group_id = aws_security_group.service_one.id
},
]
}