-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.tf
46 lines (37 loc) · 849 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
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 4.24"
}
}
required_version = ">= 1.0.0"
}
provider "aws" {
region = "eu-west-2"
access_key = var.credentials.access_key
secret_key = var.credentials.secret_key
}
module "aws_s3" {
source = "terraform-aws-modules/s3-bucket/aws"
// Generate randome bucket name
bucket = "ht-gj-bucket-${lower(random_string.s3_bucket_name.result)}"
}
resource "random_string" "s3_bucket_name" {
length = 8
special = false
}
variable "credentials" {
description = "The credentials for connecting to AWS."
type = object({
access_key = string
secret_key = string
})
sensitive = true
}
output "region" {
value = module.aws_s3.s3_bucket_region
}
output "bucket" {
value = module.aws_s3.s3_bucket_bucket_domain_name
}