project template

This commit is contained in:
shockrah 2024-02-18 19:26:27 -08:00
parent 5bd1f53222
commit f896e9a3ff
5 changed files with 87 additions and 0 deletions

1
.gitignore vendored
View File

@ -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/

View File

@ -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

View File

@ -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
}

View File

@ -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
}

View File

@ -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"