1
+ # Ensure we don't have name conflicts
2
+
3
+ resource "random_string" "install_id" {
4
+ length = 4
5
+ special = false
6
+ upper = false
7
+ numeric = false
8
+ }
9
+
10
+ locals {
11
+ app = " 5min-idp-${ random_string . install_id . result } "
12
+ prefix = " ${ local . app } -"
13
+ }
14
+
15
+ resource "humanitec_application" "demo" {
16
+ id = local. app
17
+ name = local. app
18
+ }
19
+
1
20
# Configure k8s namespace naming
2
21
3
22
resource "humanitec_resource_definition" "k8s_namespace" {
4
23
driver_type = " humanitec/echo"
5
- id = " default -namespace"
6
- name = " default -namespace"
24
+ id = " ${ local . prefix } k8s -namespace"
25
+ name = " ${ local . prefix } k8s -namespace"
7
26
type = " k8s-namespace"
8
27
9
28
driver_inputs = {
@@ -15,13 +34,16 @@ resource "humanitec_resource_definition" "k8s_namespace" {
15
34
16
35
resource "humanitec_resource_definition_criteria" "k8s_namespace" {
17
36
resource_definition_id = humanitec_resource_definition. k8s_namespace . id
37
+ app_id = humanitec_application. demo . id
38
+
39
+ force_delete = true
18
40
}
19
41
20
42
# Configure DNS for localhost
21
43
22
- resource "humanitec_resource_definition" "localhost_dns " {
23
- id = " localhost- dns"
24
- name = " localhost- dns"
44
+ resource "humanitec_resource_definition" "dns_localhost " {
45
+ id = " ${ local . prefix } dns-localhost "
46
+ name = " ${ local . prefix } dns-localhost "
25
47
type = " dns"
26
48
driver_type = " humanitec/dns-wildcard"
27
49
@@ -40,8 +62,11 @@ resource "humanitec_resource_definition" "localhost_dns" {
40
62
}
41
63
}
42
64
43
- resource "humanitec_resource_definition_criteria" "localhost_dns" {
44
- resource_definition_id = humanitec_resource_definition. localhost_dns . id
65
+ resource "humanitec_resource_definition_criteria" "dns_localhost" {
66
+ resource_definition_id = humanitec_resource_definition. dns_localhost . id
67
+ app_id = humanitec_application. demo . id
68
+
69
+ force_delete = true
45
70
}
46
71
47
72
# Provide postgres resource
@@ -50,11 +75,13 @@ module "postgres_basic" {
50
75
# Not pinned as we don't have a release yet
51
76
# tflint-ignore: terraform_module_pinned_source
52
77
source = " github.com/humanitec-architecture/resource-packs-in-cluster//humanitec-resource-defs/postgres/basic"
53
- prefix = " 5min-idp- "
78
+ prefix = local . prefix
54
79
}
55
80
56
81
resource "humanitec_resource_definition_criteria" "postgres_basic" {
57
82
resource_definition_id = module. postgres_basic . id
58
83
class = " default"
59
- force_delete = true
84
+ app_id = humanitec_application. demo . id
85
+
86
+ force_delete = true
60
87
}
0 commit comments