project template
This commit is contained in:
parent
5bd1f53222
commit
f896e9a3ff
1
.gitignore
vendored
1
.gitignore
vendored
@ -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/
|
||||
|
24
infra/new-project/Makefile
Normal file
24
infra/new-project/Makefile
Normal 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
|
34
infra/new-project/backend.tf
Normal file
34
infra/new-project/backend.tf
Normal 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
|
||||
}
|
||||
|
||||
|
20
infra/new-project/variables.tf
Normal file
20
infra/new-project/variables.tf
Normal 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
|
||||
}
|
8
infra/new-project/variables.tfvars
Normal file
8
infra/new-project/variables.tfvars
Normal 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"
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user