Skip to content

Commit 938de8c

Browse files
authored
Merge pull request #7 from mouhsen-ibrahim/mi-add-environment
Make sure that humanitec environment is created
2 parents 8e24f43 + 4fb40e1 commit 938de8c

File tree

3 files changed

+19
-5
lines changed

3 files changed

+19
-5
lines changed

1_demo.sh

+4-3
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,11 @@ set -eo pipefail
44
echo "Deploying workload"
55

66
humanitec_app=$(terraform -chdir=setup/terraform output -raw humanitec_app)
7+
humanitec_environment=$(terraform -chdir=setup/terraform output -raw humanitec_environment)
78

8-
humctl score deploy --app "$humanitec_app" --env development -f ./score.yaml --wait
9+
humctl score deploy --app "$humanitec_app" --env "$humanitec_environment" -f ./score.yaml --wait
910

10-
workload_host=$(humctl get active-resources --app "$humanitec_app" --env development -o yaml | yq '.[] | select(.metadata.type == "route") | .status.resource.host')
11+
workload_host=$(humctl get active-resources --app "$humanitec_app" --env "$humanitec_environment" -o yaml | yq '.[] | select(.metadata.type == "route") | .status.resource.host')
1112

1213
echo "Waiting for workload to be available"
1314

@@ -19,6 +20,6 @@ if curl -I --retry 30 --retry-delay 3 --retry-all-errors --fail \
1920
else
2021
echo "Workload not available"
2122
kubectl get pods --all-namespaces
22-
kubectl -n "$humanitec_app-development" logs deployment/hello-world
23+
kubectl -n "$humanitec_app-$humanitec_environment" logs deployment/hello-world
2324
exit 1
2425
fi

setup/terraform/idp-base.tf

+10-2
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,23 @@ resource "random_string" "install_id" {
88
}
99

1010
locals {
11-
app = "5min-idp-${random_string.install_id.result}"
12-
prefix = "${local.app}-"
11+
app = "5min-idp-${random_string.install_id.result}"
12+
prefix = "${local.app}-"
13+
environment = "development-${random_string.install_id.result}"
1314
}
1415

1516
resource "humanitec_application" "demo" {
1617
id = local.app
1718
name = local.app
1819
}
1920

21+
resource "humanitec_environment" "demo" {
22+
app_id = humanitec_application.demo.id
23+
id = local.environment
24+
name = "A demo environment for 5min-idp"
25+
type = "development"
26+
}
27+
2028
# Configure k8s namespace naming
2129

2230
resource "humanitec_resource_definition" "k8s_namespace" {

setup/terraform/outputs.tf

+5
Original file line numberDiff line numberDiff line change
@@ -2,3 +2,8 @@ output "humanitec_app" {
22
description = "The ID of the Humanitec application"
33
value = humanitec_application.demo.id
44
}
5+
6+
output "humanitec_environment" {
7+
description = "The ID of the Humanitec environment"
8+
value = humanitec_environment.demo.id
9+
}

0 commit comments

Comments
 (0)