-
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.
- Loading branch information
Showing
9 changed files
with
247 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
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,20 @@ | ||
resource "octopusdeploy_environment" "development_environment" { | ||
allow_dynamic_infrastructure = true | ||
description = "A test environment" | ||
name = "Development" | ||
use_guided_failure = false | ||
} | ||
|
||
resource "octopusdeploy_environment" "test_environment" { | ||
allow_dynamic_infrastructure = true | ||
description = "A test environment" | ||
name = "Test" | ||
use_guided_failure = false | ||
} | ||
|
||
resource "octopusdeploy_environment" "production_environment" { | ||
allow_dynamic_infrastructure = true | ||
description = "A test environment" | ||
name = "Production" | ||
use_guided_failure = false | ||
} |
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,22 @@ | ||
data "octopusdeploy_machine_policies" "default_machine_policy" { | ||
ids = null | ||
partial_name = "Default Machine Policy" | ||
skip = 0 | ||
take = 1 | ||
} | ||
|
||
resource "octopusdeploy_cloud_region_deployment_target" "test_target" { | ||
environments = ["${octopusdeploy_environment.development_environment.id}"] | ||
name = "Test" | ||
roles = ["cloud"] | ||
default_worker_pool_id = "" | ||
health_status = "Healthy" | ||
is_disabled = false | ||
machine_policy_id = "${data.octopusdeploy_machine_policies.default_machine_policy.machine_policies[0].id}" | ||
shell_name = "Unknown" | ||
shell_version = "Unknown" | ||
tenant_tags = [] | ||
tenanted_deployment_participation = "Untenanted" | ||
tenants = [] | ||
thumbprint = "" | ||
} |
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,79 @@ | ||
data "octopusdeploy_lifecycles" "lifecycle_default_lifecycle" { | ||
ids = null | ||
partial_name = "Default Lifecycle" | ||
skip = 0 | ||
take = 1 | ||
} | ||
|
||
resource "octopusdeploy_project_group" "project_group_test" { | ||
name = "Test" | ||
description = "Test Description" | ||
} | ||
|
||
|
||
|
||
resource "octopusdeploy_project" "test_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" | ||
} | ||
template { | ||
name = "Project Template Variable" | ||
label = "Test" | ||
default_value = "Test" | ||
display_settings = { "Octopus.ControlType" = "SingleLineText" } | ||
} | ||
} | ||
|
||
resource "octopusdeploy_deployment_process" "test_deployment_process" { | ||
project_id = octopusdeploy_project.test_project.id | ||
step { | ||
condition = "Success" | ||
name = "Hello world (using PowerShell)" | ||
package_requirement = "LetOctopusDecide" | ||
start_trigger = "StartAfterPrevious" | ||
run_script_action { | ||
can_be_used_for_project_versioning = false | ||
condition = "Success" | ||
is_disabled = false | ||
is_required = true | ||
name = "Hello world (using PowerShell)" | ||
script_body = <<-EOT | ||
Write-Host 'Hello world, using PowerShell' | ||
#TODO: Experiment with steps of your own :) | ||
Write-Host '[Learn more about the types of steps available in Octopus](https://g.octopushq.com/OnboardingAddStepsLearnMore)' | ||
EOT | ||
run_on_server = true | ||
} | ||
} | ||
} | ||
|
||
resource "octopusdeploy_channel" "test_channel" { | ||
depends_on = [octopusdeploy_deployment_process.test_deployment_process] | ||
description = "Test Channel" | ||
name = "Test Channel", | ||
project_id = octopusdeploy_project.test_project.id | ||
|
||
rule { | ||
version_range = "1.0" | ||
} | ||
} |
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}" | ||
} |
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,66 @@ | ||
resource "octopusdeploy_variable" "unscoped_project_variable" { | ||
owner_id = octopusdeploy_project.test_project.id | ||
type = "String" | ||
name = "UnscopedVariable" | ||
value = "UnscopedVariable" | ||
} | ||
|
||
resource "octopusdeploy_variable" "scoped_project_variable_action" { | ||
owner_id = octopusdeploy_project.test_project.id | ||
type = "String" | ||
name = "ActionScopedVariable" | ||
value = "unscoped variable" | ||
scope { | ||
actions = [octopusdeploy_deployment_process.test_deployment_process.step[0].run_script_action[0].id] | ||
} | ||
} | ||
|
||
resource "octopusdeploy_variable" "scoped_project_variable_channel" { | ||
owner_id = octopusdeploy_project.test_project.id | ||
type = "String" | ||
name = "ChannelScopedVariable" | ||
value = "ChannelScopedVariable" | ||
scope { | ||
channels = [octopusdeploy_channel.test_channel.id] | ||
} | ||
} | ||
|
||
resource "octopusdeploy_variable" "scoped_project_variable_environment" { | ||
owner_id = octopusdeploy_project.test_project.id | ||
type = "String" | ||
name = "EnvironmentScopedVariable" | ||
value = "EnvironmentScopedVariable" | ||
scope { | ||
channels = [octopusdeploy_environment.development_environment.id] | ||
} | ||
} | ||
|
||
resource "octopusdeploy_variable" "scoped_project_variable_machine" { | ||
owner_id = octopusdeploy_project.test_project.id | ||
type = "String" | ||
name = "MachineScopedVariable" | ||
value = "MachineScopedVariable" | ||
scope { | ||
machines = [octopusdeploy_cloud_region_deployment_target.test_target.id] | ||
} | ||
} | ||
|
||
resource "octopusdeploy_variable" "scoped_project_variable_process" { | ||
owner_id = octopusdeploy_project.test_project.id | ||
type = "String" | ||
name = "ProcessScopedVariable" | ||
value = "ProcessScopedVariable" | ||
scope { | ||
processes = [octopusdeploy_deployment_process.test_deployment_process.id] | ||
} | ||
} | ||
|
||
resource "octopusdeploy_variable" "scoped_project_variable_role" { | ||
owner_id = octopusdeploy_project.test_project.id | ||
type = "String" | ||
name = "RoleScopedVariable" | ||
value = "RoleScopedVariable" | ||
scope { | ||
roles = ["role"] | ||
} | ||
} |