-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.tf
52 lines (47 loc) · 1.38 KB
/
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
47
48
49
50
51
52
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 5.0"
}
}
backend "s3" {
bucket = "terraform-staging-environment"
workspace_key_prefix = "bisina/test_vpc"
key = "test_vpc.tfstate"
region = "eu-central-1"
dynamodb_table = "eu-central-1-terraform-locks"
encrypt = true
}
}
provider "aws" {
region = var.region
default_tags {
tags = {
"environment" = "${var.environment_type}"
"application" = "${var.application_type}"
"vetstoria:environment" = "staging"
"vetstoria:resource-manager" = "Terraform"
"vetstoria:resource-group" = "test"
"vetstoria:team" = "devops"
"vetstoria:application" = "test"
"vetstoria:component" = "test"
}
}
}
resource "null_resource" "workspace_name_check" {
lifecycle {
precondition {
condition = (terraform.workspace == "staging" || terraform.workspace == "production")
error_message = "Workspace name does not match a valid environment."
}
}
}
resource "null_resource" "workspace_variable_file_check" {
lifecycle {
precondition {
condition = terraform.workspace == var.environment_type
error_message = "Variables file refers to a different workspace."
}
}
}