-
Notifications
You must be signed in to change notification settings - Fork 67
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add the worker_pool_id field to apply_terraform_template_action steps (…
- Loading branch information
1 parent
66a300b
commit a58b130
Showing
9 changed files
with
216 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
terraform { | ||
required_providers { | ||
octopusdeploy = { source = "OctopusDeployLabs/octopusdeploy", version = "0.11.3" } | ||
// Use the option below when debugging | ||
// octopusdeploy = { source = "octopus.com/com/octopusdeploy" } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,101 @@ | ||
data "octopusdeploy_lifecycles" "lifecycle_default_lifecycle" { | ||
ids = null | ||
partial_name = "Default Lifecycle" | ||
skip = 0 | ||
take = 1 | ||
} | ||
|
||
data "octopusdeploy_feeds" "feed_octopus_server__built_in_" { | ||
feed_type = "BuiltIn" | ||
ids = null | ||
partial_name = "" | ||
skip = 0 | ||
take = 1 | ||
lifecycle { | ||
postcondition { | ||
error_message = "Failed to resolve a feed called \"BuiltIn\". This resource must exist in the space before this Terraform configuration is applied." | ||
condition = length(self.feeds) != 0 | ||
} | ||
} | ||
} | ||
|
||
resource "octopusdeploy_project" "deploy_frontend_project" { | ||
auto_create_release = false | ||
default_guided_failure_mode = "EnvironmentDefault" | ||
default_to_skip_if_already_installed = false | ||
description = "Test project" | ||
discrete_channel_release = false | ||
is_disabled = false | ||
is_discrete_channel_release = false | ||
is_version_controlled = false | ||
lifecycle_id = data.octopusdeploy_lifecycles.lifecycle_default_lifecycle.lifecycles[0].id | ||
name = "Test" | ||
project_group_id = octopusdeploy_project_group.project_group_test.id | ||
tenanted_deployment_participation = "Untenanted" | ||
space_id = var.octopus_space_id | ||
included_library_variable_sets = [] | ||
versioning_strategy { | ||
template = "#{Octopus.Version.LastMajor}.#{Octopus.Version.LastMinor}.#{Octopus.Version.LastPatch}.#{Octopus.Version.NextRevision}" | ||
} | ||
|
||
connectivity_policy { | ||
allow_deployments_to_no_targets = false | ||
exclude_unhealthy_targets = false | ||
skip_machine_behavior = "SkipUnavailableMachines" | ||
} | ||
} | ||
|
||
resource "octopusdeploy_deployment_process" "deployment_process_terraform_apply" { | ||
project_id = "${octopusdeploy_project.deploy_frontend_project.id}" | ||
|
||
step { | ||
condition = "Success" | ||
name = "Apply a Terraform template" | ||
package_requirement = "LetOctopusDecide" | ||
start_trigger = "StartAfterPrevious" | ||
|
||
apply_terraform_template_action { | ||
name = "Terraform Apply" | ||
can_be_used_for_project_versioning = true | ||
channels = [] | ||
condition = "Success" | ||
environments = [] | ||
advanced_options { | ||
allow_additional_plugin_downloads = true | ||
apply_parameters = "" | ||
init_parameters = "" | ||
plugin_cache_directory = "" | ||
workspace = "" | ||
} | ||
is_disabled = false | ||
is_required = false | ||
|
||
inline_template = "variable \"images\" {\n type = \"map\"\n\n default = {\n us-east-1 = \"image-1234\"\n us-west-2 = \"image-4567\"\n }\n}\n\nvariable \"test2\" {\n type = \"map\"\n default = {\n val1 = [\"hi\"]\n }\n}\n\nvariable \"test3\" {\n type = \"map\"\n default = {\n val1 = {\n val2 = \"hi\"\n }\n }\n}\n\nvariable \"test4\" {\n type = \"map\"\n default = {\n val1 = {\n val2 = [\"hi\"]\n }\n }\n}\n\n# Example of getting an element from a list in a map\noutput \"nestedlist\" {\n value = \"$${element(var.test2[\"val1\"], 0)}\"\n}\n\n# Example of getting an element from a nested map\noutput \"nestedmap\" {\n value = \"$${lookup(var.test3[\"val1\"], \"val2\")}\"\n}" | ||
|
||
primary_package { | ||
acquisition_location = "Server" | ||
package_id = "Test" | ||
feed_id = "${data.octopusdeploy_feeds.feed_octopus_server__built_in_.feeds[0].id}" | ||
|
||
properties = { | ||
"SelectionMode" = "immediate" | ||
} | ||
} | ||
|
||
template { | ||
additional_variable_files = "" | ||
directory = "" | ||
run_automatic_file_substitution = true | ||
target_files = "" | ||
} | ||
|
||
worker_pool_id = octopusdeploy_static_worker_pool.workerpool_docker.id | ||
run_on_server = true | ||
sort_order = 1 | ||
} | ||
|
||
properties = {} | ||
target_roles = [] | ||
} | ||
depends_on = [] | ||
} |
4 changes: 4 additions & 0 deletions
4
terraform/50-applyterraformtemplateaction/project_group_test.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
resource "octopusdeploy_project_group" "project_group_test" { | ||
name = "Test" | ||
description = "Test Description" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
provider "octopusdeploy" { | ||
address = "${var.octopus_server}" | ||
api_key = "${var.octopus_apikey}" | ||
space_id = "${var.octopus_space_id}" | ||
} |
18 changes: 18 additions & 0 deletions
18
terraform/50-applyterraformtemplateaction/provider_vars.tf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
variable "octopus_server" { | ||
type = string | ||
nullable = false | ||
sensitive = false | ||
description = "The URL of the Octopus server e.g. https://myinstance.octopus.app." | ||
} | ||
variable "octopus_apikey" { | ||
type = string | ||
nullable = false | ||
sensitive = true | ||
description = "The API key used to access the Octopus server. See https://octopus.com/docs/octopus-rest-api/how-to-create-an-api-key for details on creating an API key." | ||
} | ||
variable "octopus_space_id" { | ||
type = string | ||
nullable = false | ||
sensitive = false | ||
description = "The space ID to populate" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
output "octopus_space_id" { | ||
value = var.octopus_space_id | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
resource "octopusdeploy_static_worker_pool" "workerpool_docker" { | ||
name = "Docker" | ||
description = "A test worker pool" | ||
is_default = false | ||
sort_order = 3 | ||
} |