forked from lugnitdgp/Online-Judge
-
Notifications
You must be signed in to change notification settings - Fork 0
/
onlinejudge.tf
53 lines (44 loc) · 1.38 KB
/
onlinejudge.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
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 2.70"
}
}
}
provider "aws" {
profile = "default"
region = var.region
access_key = var.access_key
secret_key = var.secret_key
}
resource "aws_s3_bucket" "online-judge-bucket" {
bucket = "online-judge-glug"
acl = "public-read"
}
data "aws_iam_policy_document" "online-judge-policy-document" {
statement {
actions = ["s3:PutObject","s3:GetObjectAcl","s3:GetObject","s3:ListBucket","s3:DeleteObject","s3:PutObjectAcl"]
resources = [aws_s3_bucket.online-judge-bucket.arn, join("", [aws_s3_bucket.online-judge-bucket.arn, "/*"])]
}
}
resource "aws_iam_user" "online-judge-iam-user" {
name = "online-judge"
}
resource "aws_iam_user_policy" "online-judge-policy" {
name = "online-judge-policy"
user = aws_iam_user.online-judge-iam-user.name
policy = data.aws_iam_policy_document.online-judge-policy-document.json
}
resource "aws_iam_access_key" "online-judge-iam-user-access-key" {
user = aws_iam_user.online-judge-iam-user.name
}
output "online-judge-iam-user-access-key" {
value = aws_iam_access_key.online-judge-iam-user-access-key.id
}
output "online-judge-iam-user-secret-key" {
value = aws_iam_access_key.online-judge-iam-user-access-key.secret
}
output "online-judge-bucket-domain" {
value = aws_s3_bucket.online-judge-bucket.bucket_domain_name
}