-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathmain.tf
77 lines (61 loc) · 1.58 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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
provider "aws" {
region = "us-east-1"
}
data "aws_caller_identity" "this" {}
data "aws_region" "this" {}
data "aws_vpc" "default" {
default = true
}
resource "random_string" "this" {
length = 32
special = false
numeric = false
upper = false
}
locals {
bucket_name = random_string.this.id
access_point_name = "access-point-test-vpc"
account_id = data.aws_caller_identity.this.account_id
region = data.aws_region.this.name
}
###################################################
# S3 Bucket
###################################################
module "bucket" {
source = "../../modules/s3-bucket"
# source = "tedilabs/data/aws//modules/s3-bucket"
# version = "~> 0.2.0"
name = local.bucket_name
force_destroy = true
tags = {
"project" = "terraform-aws-data-examples"
}
}
###################################################
# S3 Access Point
###################################################
module "access_point" {
source = "../../modules/s3-access-point"
# source = "tedilabs/data/aws//modules/s3-access-point"
# version = "~> 0.2.0"
name = local.access_point_name
bucket = {
name = module.bucket.name
}
network_origin = "VPC"
vpc_id = data.aws_vpc.default.id
policy = jsonencode({
Version = "2008-10-17"
Statement = [{
Effect = "Allow"
Action = "s3:GetObjectTagging"
Principal = {
AWS = "*"
}
Resource = "arn:aws:s3:${local.region}:${local.account_id}:accesspoint/${local.access_point_name}/object/*"
}]
})
block_public_access = {
enabled = true
}
}