Skip to content

Commit e9e0ed0

Browse files
committed
updates
1 parent 03dfd52 commit e9e0ed0

File tree

7 files changed

+188
-0
lines changed

7 files changed

+188
-0
lines changed

terraform/main.tf

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,3 +103,81 @@ module "s3-dest" {
103103
# ]
104104
# }
105105
}
106+
107+
# REGION 1 (us-east-1)
108+
# ====================================
109+
110+
data "aws_vpc" "region1" {
111+
# provider = aws.us-west-2
112+
113+
default = true
114+
state = "available"
115+
}
116+
117+
data "aws_subnet" "region1" {
118+
# provider = aws.us-west-2
119+
120+
vpc_id = data.aws_vpc.region1.id
121+
availability_zone = "us-east-1a"
122+
state = "available"
123+
}
124+
125+
module "vpc-endpoint-s3-global-region1" {
126+
source = "./modules/vpc-endpoint"
127+
128+
private_dns_only_for_inbound_resolver_endpoint = false
129+
configuration = {
130+
service_name = "com.amazonaws.s3-global.accesspoint"
131+
subnet_type = "Private"
132+
region = "us-east-1"
133+
}
134+
135+
vpc_id = data.aws_vpc.region1.id
136+
subnet_ids = [data.aws_subnet.region1.id]
137+
}
138+
139+
# REGION 2 (us-west-2)
140+
# ====================================
141+
142+
data "aws_vpc" "region2" {
143+
provider = aws.us-west-2
144+
145+
default = true
146+
state = "available"
147+
}
148+
149+
data "aws_subnet" "region2" {
150+
provider = aws.us-west-2
151+
152+
vpc_id = data.aws_vpc.region2.id
153+
availability_zone = "us-west-2a"
154+
state = "available"
155+
}
156+
157+
module "vpc-endpoint-s3-global-region2" {
158+
providers = {
159+
aws = aws.us-west-2
160+
}
161+
source = "./modules/vpc-endpoint"
162+
163+
private_dns_only_for_inbound_resolver_endpoint = false
164+
configuration = {
165+
service_name = "com.amazonaws.s3-global.accesspoint"
166+
subnet_type = "Private"
167+
region = "us-west-2"
168+
}
169+
170+
vpc_id = data.aws_vpc.region2.id
171+
subnet_ids = [data.aws_subnet.region2.id]
172+
}
173+
174+
# S3 MRAP
175+
# ====================================
176+
177+
module "s3-mrap" {
178+
source = "./modules/s3-control"
179+
180+
create_mrap = true
181+
mrap_name = "example-test-mrap"
182+
mrap_bucket_names = [module.s3-source.bucket_name, module.s3-dest.bucket_name]
183+
}

terraform/modules/s3-control/main.tf

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
terraform {
2+
required_providers {
3+
aws = {
4+
source = "hashicorp/aws"
5+
version = "~> 5.50.0"
6+
}
7+
}
8+
}
9+
10+
resource "aws_s3control_multi_region_access_point" "mrap" {
11+
count = var.create_mrap ? 1 : 0
12+
13+
details {
14+
name = var.mrap_name
15+
16+
region {
17+
bucket = var.mrap_bucket_names[0]
18+
}
19+
20+
region {
21+
bucket = var.mrap_bucket_names[1]
22+
}
23+
}
24+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
output "arn" {
2+
value = aws_s3control_multi_region_access_point.mrap[0].arn
3+
}
4+
5+
output "alias" {
6+
value = aws_s3control_multi_region_access_point.mrap[0].alias
7+
}

terraform/modules/s3-control/vars.tf

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# variable "version" {
2+
# description = "The module version"
3+
# type = string
4+
# }
5+
6+
variable "create_mrap" {
7+
description = "Whether to create MRAP or not"
8+
type = bool
9+
}
10+
11+
variable "mrap_name" {
12+
description = "The name of the MRAP"
13+
type = string
14+
}
15+
16+
variable "mrap_bucket_names" {
17+
description = "The bucket names for the MRAP"
18+
type = list(string)
19+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
terraform {
2+
required_providers {
3+
aws = {
4+
source = "hashicorp/aws"
5+
version = "~> 5.50.0"
6+
}
7+
}
8+
}
9+
10+
resource "aws_vpc_endpoint" "endpoint" {
11+
vpc_endpoint_type = "Interface"
12+
vpc_id = var.vpc_id
13+
service_name = var.configuration.service_name
14+
subnet_ids = var.subnet_ids
15+
# security_group_ids = var.security_group_ids
16+
private_dns_enabled = var.private_dns_only_for_inbound_resolver_endpoint
17+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
output "id" {
2+
value = aws_vpc_endpoint.endpoint.id
3+
}
4+
5+
output "dns" {
6+
value = aws_vpc_endpoint.endpoint.dns_entry[0].dns_name
7+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
# variable "version" {
2+
# description = "The module version"
3+
# type = string
4+
# }
5+
6+
variable "private_dns_only_for_inbound_resolver_endpoint" {
7+
description = "Private DNS only for inbound resolver endpoint"
8+
type = bool
9+
}
10+
11+
variable "configuration" {
12+
description = "The configuration for the VPC endpoint"
13+
type = object({
14+
service_name = string
15+
subnet_type = string
16+
region = string
17+
})
18+
}
19+
20+
variable "vpc_id" {
21+
description = "The VPC ID"
22+
type = string
23+
default = "VPC_ID_HERE"
24+
}
25+
26+
variable "subnet_ids" {
27+
description = "The subnet IDs"
28+
type = list(string)
29+
default = ["SUBNET_IDS_HERE"]
30+
}
31+
32+
variable "security_group_ids" {
33+
description = "The security group IDs"
34+
type = list(string)
35+
default = ["SECURITY_GROUP_IDS_HERE"]
36+
}

0 commit comments

Comments
 (0)