add initial main file for creating s3 bucket

Signed-off-by: Jakub Sokołowski <jakub@status.im>
This commit is contained in:
Jakub Sokołowski 2019-05-28 12:33:58 -04:00
parent 7cc340133f
commit f923028eb9
No known key found for this signature in database
GPG Key ID: 4EF064D0E6D63020
3 changed files with 79 additions and 0 deletions

46
main.tf Normal file
View File

@ -0,0 +1,46 @@
/* DERIVED --------------------------------------*/
provider "aws" {
region = "us-east-1"
access_key = "${var.aws_access_key}"
secret_key = "${var.aws_secret_key}"
}
//provider "gandi" {
// key = "<the API key>"
// sharing_id = "<the sharing_id>"
//}
/* DATA -----------------------------------------*/
//terraform {
// backend "s3" {
// bucket = "dapps-terraform-state"
// key = "infra-dapps"
// region = "us-east-2"
// encrypt = true
// }
//}
/* INVENTORY ------------------------------------*/
resource "aws_s3_bucket" "tf-state" {
bucket = "dapps-terraform-state"
acl = "private"
tags = {
Name = "Terraform State Store"
}
policy = "${file("s3policy.json")}"
versioning {
enabled = true
}
lifecycle {
prevent_destroy = true
}
}
/* RESOURCES ------------------------------------*/

12
s3policy.json Normal file
View File

@ -0,0 +1,12 @@
{
"Statement": [
{
"Effect": "Allow",
"Principal": {
"AWS": "arn:aws:iam::760668534108:user/terraform-user"
},
"Action": "s3:*",
"Resource": "arn:aws:s3:::dapps-infra-tf-state"
}
]
}

21
variables.tf Normal file
View File

@ -0,0 +1,21 @@
/* REQUIRED -------------------------------------*/
variable aws_access_key {
description = "Access key for the AWS API."
}
variable aws_secret_key {
description = "Secret key for the AWS API."
}
/* GENERAL --------------------------------------*/
variable hosts_domain {
description = "Domain for hosts entries."
default = "hosts.dap.ps"
}
variable public_domain {
description = "Public DNS Domain address"
default = "dap.ps"
}