-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathmain.tf
49 lines (42 loc) · 834 Bytes
/
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
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 4.3.0"
}
random = {
source = "hashicorp/random"
version = "3.1.0"
}
}
}
resource "random_pet" "valheim" {
keepers = {
valheim = var.world_name
}
}
provider "aws" {
region = var.region
}
resource "aws_default_vpc" "default" {
tags = {
Name = "Default VPC"
}
}
locals {
world = "valheim-${random_pet.valheim.id}"
vpc_id = var.vpc_id == "" ? aws_default_vpc.default.id : var.vpc_id
}
data "aws_subnets" "default" {
filter {
name = "vpc-id"
values = [local.vpc_id]
}
}
resource "aws_s3_bucket" "backups" {
bucket_prefix = "valheim-backup-${lower(var.world_name)}"
}
resource "aws_s3_bucket_acl" "backups" {
bucket = aws_s3_bucket.backups.id
acl = "private"
}