diff --git a/.gitignore b/.gitignore index 8c400f9..10bebef 100644 --- a/.gitignore +++ b/.gitignore @@ -7,6 +7,7 @@ infra/**/terraform.tfvars infra/keys/ infra/**/out.plan infra/terraform.tfstate +infra/**/secrets.sh infra/terraform.tfstate.backup playbooks/hosts.ini playbooks/.ssh/ diff --git a/infra/new-project/Makefile b/infra/new-project/Makefile new file mode 100644 index 0000000..08dd323 --- /dev/null +++ b/infra/new-project/Makefile @@ -0,0 +1,24 @@ +plan=out.plan + +SHELL := /bin/bash + +$(plan): *.tf + source ./secrets.sh && terraform plan -var-file variables.tfvars -input=false -out $(plan) + +push: build + source ./secrets.sh && terraform apply $(plan) + +refresh: + source ./secrets.sh && terraform apply -refresh-only + +test: + terraform validate + + +rip: + source ./secrets.sh && terraform destroy + +clean: + rm -f $(plan) + +.PHONY: test build clean push rip diff --git a/infra/new-project/backend.tf b/infra/new-project/backend.tf new file mode 100644 index 0000000..12e870b --- /dev/null +++ b/infra/new-project/backend.tf @@ -0,0 +1,34 @@ +terraform { + required_version = ">= 0.13" + backend s3 { + bucket = "project-athens" + key = "infra/new-project/state/build.tfstate" + region = var.aws_region + encrypt = true + } + required_providers { + aws = { + source = "hashicorp/aws" + version = "~> 5.0" + } + vultr = { + source = "vultr/vultr" + version = "2.19.0" + } + } +} + +provider vultr { + api_key = var.vultr_api_key + rate_limit = 100 + retry_limit = 3 +} + +provider aws { + access_key = var.aws_key + secret_key = var.aws_secret + region = var.aws_region + max_retries = 1 +} + + diff --git a/infra/new-project/variables.tf b/infra/new-project/variables.tf new file mode 100644 index 0000000..bceb1ff --- /dev/null +++ b/infra/new-project/variables.tf @@ -0,0 +1,20 @@ +# API Keys required to reach AWS/Vultr +variable vultr_api_key { + type = string + sensitive = true +} + +variable aws_key { + type = string + sensitive = true +} + +variable aws_secret { + type = string + sensitive = true +} + +variable aws_region { + type = string + sensitive = true +} diff --git a/infra/new-project/variables.tfvars b/infra/new-project/variables.tfvars new file mode 100644 index 0000000..ecfb573 --- /dev/null +++ b/infra/new-project/variables.tfvars @@ -0,0 +1,8 @@ +# These variables are set through environment variables and not through +# the terraform configuration +# vultr_api_key = "example" +# aws_key = "example" +# aws_secret = "example" +# aws_region = "example" + +