-
Notifications
You must be signed in to change notification settings - Fork 1
/
neptune.tf
105 lines (89 loc) · 2.99 KB
/
neptune.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
# --------------------------------------------------------------------------------
# Copyright 2020 Leap Beyond Emerging Technologies B.V.
# --------------------------------------------------------------------------------
# --------------------------------------------------------------------------------
# neptune cluster
# --------------------------------------------------------------------------------
resource aws_security_group example {
name = var.vpc_name
description = "Allow access to neptune from the VPC"
vpc_id = module.vpc.vpc_id
ingress {
description = "Allow inbound access to neptune"
from_port = 8182
to_port = 8182
protocol = "tcp"
cidr_blocks = [var.vpc_cidr]
}
egress {
description = "allow any-to-any outbound"
from_port = 0
to_port = 0
protocol = "-1"
cidr_blocks = ["0.0.0.0/0"]
}
tags = merge({ "Name" = var.vpc_name }, var.tags)
}
data aws_kms_key by_alias {
key_id = "alias/aws/rds"
}
resource aws_neptune_subnet_group example {
name_prefix = var.vpc_name
description = "subnet group to mount neptune into"
subnet_ids = module.vpc.public_subnet_id
tags = merge({ "Name" = var.vpc_name }, var.tags)
}
resource aws_neptune_cluster example {
cluster_identifier_prefix = var.vpc_name
backup_retention_period = 1
skip_final_snapshot = true
iam_database_authentication_enabled = false
apply_immediately = true
deletion_protection = false
neptune_subnet_group_name = aws_neptune_subnet_group.example.id
kms_key_arn = data.aws_kms_key.by_alias.arn
storage_encrypted = true
iam_roles = [aws_iam_role.example.arn]
tags = merge({ "Name" = var.vpc_name }, var.tags)
vpc_security_group_ids = [
aws_security_group.example.id
]
}
resource aws_neptune_cluster_instance example {
count = 2
identifier_prefix = var.vpc_name
cluster_identifier = aws_neptune_cluster.example.id
instance_class = "db.t3.medium"
apply_immediately = true
neptune_subnet_group_name = aws_neptune_cluster.example.neptune_subnet_group_name
publicly_accessible = false
tags = merge({ "Name" = "${var.vpc_name}-${count.index}" }, var.tags)
}
# --------------------------------------------------------------------------------
# role to allow neptune to read from our bucket
# --------------------------------------------------------------------------------
resource aws_iam_role example {
name = var.vpc_name
assume_role_policy = <<EOF
{
"Version": "2012-10-17",
"Statement": [
{
"Sid": "",
"Effect": "Allow",
"Principal": {
"Service": [
"rds.amazonaws.com"
]
},
"Action": "sts:AssumeRole"
}
]
}
EOF
tags = merge({ "Name" = var.vpc_name }, var.tags)
}
resource aws_iam_role_policy_attachment example {
role = aws_iam_role.example.name
policy_arn = "arn:aws:iam::aws:policy/AmazonS3ReadOnlyAccess"
}