Skip to content

Commit

Permalink
Update config
Browse files Browse the repository at this point in the history
  • Loading branch information
nicholasjackson committed Feb 26, 2024
1 parent d314f65 commit c69c82c
Show file tree
Hide file tree
Showing 9 changed files with 206 additions and 75 deletions.
16 changes: 8 additions & 8 deletions course/providers.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ resource "chapter" "providers" {
title = "Providers"

tasks = {
install_provider = resource.task.install_provider
install_provider = resource.task.install_provider
provider_configuration = resource.task.provider_configuration
}

Expand All @@ -16,23 +16,23 @@ resource "chapter" "providers" {
}

resource "task" "install_provider" {
prerequisites = resource.chapter.workflow.tasks != null ? values(resource.chapter.workflow.tasks).*.id : []
prerequisites = resource.chapter.workflow.tasks != null ? values(resource.chapter.workflow.tasks).*.meta.id : []

config {
user = "root"
user = "root"
target = variable.terraform_target
}

condition "provider_added" {
description = "The vault provider is added to the code"

check {
script = file("checks/providers/install_provider/provider_added")
script = file("checks/providers/install_provider/provider_added")
failure_message = "The \"hashicorp/vault\" provider was not added to required_providers"
}

solve {
script = file("checks/providers/install_provider/solve")
script = file("checks/providers/install_provider/solve")
timeout = 120
}
}
Expand All @@ -41,7 +41,7 @@ resource "task" "install_provider" {
description = "The vault provider is installed"

check {
script = file("checks/providers/install_provider/provider_installed")
script = file("checks/providers/install_provider/provider_installed")
failure_message = "the vault provider was not correctly initialized"
}
}
Expand All @@ -53,15 +53,15 @@ resource "task" "provider_configuration" {
]

config {
user = "root"
user = "root"
target = variable.terraform_target
}

condition "configuration_added" {
description = "The provider configuration is added"

check {
script = file("checks/providers/provider_configuration/configuration_added")
script = file("checks/providers/provider_configuration/configuration_added")
failure_message = "The provider configuration does not specify the Vault address"
}

Expand Down
20 changes: 10 additions & 10 deletions course/state.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ resource "chapter" "state" {

tasks = {
viewing_state = resource.task.viewing_state
list_state = resource.task.list_state
show_state = resource.task.show_state
list_state = resource.task.list_state
show_state = resource.task.show_state
}

page "viewing_state" {
Expand All @@ -21,10 +21,10 @@ resource "chapter" "state" {
}

resource "task" "viewing_state" {
prerequisites = resource.chapter.providers.tasks != null ? values(resource.chapter.providers.tasks).*.id : []
prerequisites = resource.chapter.providers.tasks != null ? values(resource.chapter.providers.tasks).*.meta.id : []

config {
user = "root"
user = "root"
target = variable.terraform_target
}

Expand All @@ -36,7 +36,7 @@ resource "task" "viewing_state" {
}

check {
script = file("checks/state/viewing_state/show_command")
script = file("checks/state/viewing_state/show_command")
failure_message = "The terraform show command was not used to view the state"
}

Expand All @@ -49,7 +49,7 @@ resource "task" "viewing_state" {
description = "The state is in a machine-readable format"

check {
script = file("checks/state/viewing_state/json_flag")
script = file("checks/state/viewing_state/json_flag")
failure_message = "The terraform state was not viewed in a machine-readable format such as JSON"
}
}
Expand All @@ -61,15 +61,15 @@ resource "task" "list_state" {
]

config {
user = "root"
user = "root"
target = variable.terraform_target
}

condition "list_command" {
description = "The state for all resources is listed"

check {
script = file("checks/state/list_state/list_command")
script = file("checks/state/list_state/list_command")
failure_message = "The terraform state list command was not used"
}

Expand All @@ -85,15 +85,15 @@ resource "task" "show_state" {
]

config {
user = "root"
user = "root"
target = variable.terraform_target
}

condition "show_command" {
description = "The state of the Vault Docker container was shown"

check {
script = file("checks/state/show_state/show_command")
script = file("checks/state/show_state/show_command")
failure_message = "The terraform state show command was not used to view the state for docker_container.vault"
}

Expand Down
64 changes: 32 additions & 32 deletions course/workflow.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ resource "chapter" "workflow" {
title = "Terraform workflow"

tasks = {
terraform_init = resource.task.terraform_init
terraform_plan = resource.task.terraform_plan
terraform_apply = resource.task.terraform_apply
update_resources = resource.task.update_resources
terraform_init = resource.task.terraform_init
terraform_plan = resource.task.terraform_plan
terraform_apply = resource.task.terraform_apply
update_resources = resource.task.update_resources
terraform_destroy = resource.task.terraform_destroy
}

Expand All @@ -31,23 +31,23 @@ resource "chapter" "workflow" {
}

resource "task" "terraform_init" {
prerequisites = resource.chapter.installation.tasks != null ? values(resource.chapter.installation.tasks).*.id : []
prerequisites = resource.chapter.installation.tasks != null ? values(resource.chapter.installation.tasks).*.meta.id : []

config {
user = "root"
user = "root"
target = variable.terraform_target
}

condition "init_command" {
description = "The terraform_basics working directory is initialized"

check {
script = file("checks/workflow/terraform_init/init_command")
script = file("checks/workflow/terraform_init/init_command")
failure_message = "'terraform init' command was not used to initialize the working directory"
}

solve {
script = file("checks/workflow/terraform_init/solve")
script = file("checks/workflow/terraform_init/solve")
timeout = 120
}
}
Expand All @@ -56,7 +56,7 @@ resource "task" "terraform_init" {
description = "The terraform lock file has been created"

check {
script = file("checks/workflow/terraform_init/dependency_lock_file")
script = file("checks/workflow/terraform_init/dependency_lock_file")
failure_message = "'.terraform.lock.hcl' file does not exist"
}
}
Expand All @@ -65,7 +65,7 @@ resource "task" "terraform_init" {
description = "The Docker provider is initialized"

check {
script = file("checks/workflow/terraform_init/docker_provider")
script = file("checks/workflow/terraform_init/docker_provider")
failure_message = "the docker provider was not correctly initialized"
}
}
Expand All @@ -77,15 +77,15 @@ resource "task" "terraform_plan" {
]

config {
user = "root"
user = "root"
target = variable.terraform_target
}

condition "plan_command" {
description = "Use the terraform plan command"

check {
script = file("checks/workflow/terraform_plan/plan_command")
script = file("checks/workflow/terraform_plan/plan_command")
failure_message = "'terraform plan' command was not used to preview changes"
}

Expand All @@ -101,20 +101,20 @@ resource task "terraform_apply" {
]

config {
user = "root"
user = "root"
target = variable.terraform_target
}

condition "apply_command" {
description = "Use the terraform apply command"

check {
script = file("checks/workflow/terraform_apply/apply_command")
script = file("checks/workflow/terraform_apply/apply_command")
failure_message = "'terraform apply' command was not used to apply changes"
}

solve {
script = file("checks/workflow/terraform_apply/solve")
script = file("checks/workflow/terraform_apply/solve")
timeout = 300
}
}
Expand All @@ -123,16 +123,16 @@ resource task "terraform_apply" {
description = "The Terraform state contains the Docker image"

check {
script = file("checks/workflow/terraform_apply/state_image")
script = file("checks/workflow/terraform_apply/state_image")
failure_message = "docker_image.vault not found in terraform state"
}
}

condition "state_container" {
condition "state_container" {
description = "The Terraform state contains the Docker container"

check {
script = file("checks/workflow/terraform_apply/state_container")
script = file("checks/workflow/terraform_apply/state_container")
failure_message = "docker_container.vault not found in terraform state"
}
}
Expand All @@ -141,7 +141,7 @@ resource task "terraform_apply" {
description = "The Docker image is created"

check {
script = file("checks/workflow/terraform_apply/docker_image")
script = file("checks/workflow/terraform_apply/docker_image")
failure_message = "the docker \"vault\" image with tag \"1.12.6\" was not pulled"
}
}
Expand All @@ -150,7 +150,7 @@ resource task "terraform_apply" {
description = "The Docker container is running"

check {
script = file("checks/workflow/terraform_apply/docker_container")
script = file("checks/workflow/terraform_apply/docker_container")
failure_message = "the docker container named \"terraform-basics-vault\" is not running"
}
}
Expand All @@ -162,20 +162,20 @@ resource "task" "update_resources" {
]

config {
user = "root"
user = "root"
target = variable.terraform_target
}

condition "update_code" {
description = "Change the version of the vault image"

check {
script = file("checks/workflow/update_resources/update_code")
script = file("checks/workflow/update_resources/update_code")
failure_message = "The version of the vault image has not been updated to 1.12.7"
}

solve {
script = file("checks/workflow/update_resources/solve")
script = file("checks/workflow/update_resources/solve")
timeout = 300
}
}
Expand All @@ -184,7 +184,7 @@ resource "task" "update_resources" {
description = "The Terraform state is updated"

check {
script = file("checks/workflow/update_resources/state_changed")
script = file("checks/workflow/update_resources/state_changed")
failure_message = "The Terraform state does not contain the updated resources"
}
}
Expand All @@ -193,7 +193,7 @@ resource "task" "update_resources" {
description = "The Docker image is updated"

check {
script = file("checks/workflow/update_resources/docker_image")
script = file("checks/workflow/update_resources/docker_image")
failure_message = "the docker 'vault' image with tag '1.12.7' was not pulled"
}
}
Expand All @@ -202,7 +202,7 @@ resource "task" "update_resources" {
description = "The Docker container is running"

check {
script = file("checks/workflow/update_resources/docker_container")
script = file("checks/workflow/update_resources/docker_container")
failure_message = "the docker container named 'terraform-basics-vault' is not running"
}
}
Expand All @@ -214,15 +214,15 @@ resource "task" "terraform_destroy" {
]

config {
user = "root"
user = "root"
target = variable.terraform_target
}

condition "destroy_command" {
description = "Use the terraform destroy command"

check {
script = file("checks/workflow/terraform_destroy/destroy_command")
script = file("checks/workflow/terraform_destroy/destroy_command")
failure_message = "'terraform destroy' command was not used to clean up the environment"
}

Expand All @@ -235,7 +235,7 @@ resource "task" "terraform_destroy" {
description = "The Terraform state is empty"

check {
script = file("checks/workflow/terraform_destroy/state_empty")
script = file("checks/workflow/terraform_destroy/state_empty")
failure_message = "the terraform state is not empty"
}
}
Expand All @@ -244,7 +244,7 @@ resource "task" "terraform_destroy" {
description = "The Docker container is removed"

check {
script = file("checks/workflow/terraform_destroy/docker_container")
script = file("checks/workflow/terraform_destroy/docker_container")
failure_message = "the docker container named 'terraform-basics-vault' is still running"
}
}
Expand All @@ -253,7 +253,7 @@ resource "task" "terraform_destroy" {
description = "The Docker container is removed"

check {
script = file("checks/workflow/terraform_destroy/docker_image")
script = file("checks/workflow/terraform_destroy/docker_image")
failure_message = "the docker 'vault' image with tag '1.12.7' was not removed"
}
}
Expand Down
Loading

0 comments on commit c69c82c

Please sign in to comment.