Skip to content

Commit

Permalink
Fix terraform (#780)
Browse files Browse the repository at this point in the history
* add missing TF version requirements

* update version

* move provider definition

* move provider definitions to top-level

* move data source

* refactor

* delete file
  • Loading branch information
markdboyd authored Nov 13, 2023
1 parent 02ea099 commit c8e2633
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 14 deletions.
4 changes: 2 additions & 2 deletions terraform/modules/tcp-routing/versions.tf
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
terraform {
required_version = ">= 0.14"
required_version = "< 2.0.0"
required_providers {
cloudfoundry = {
source = "cloudfoundry-community/cloudfoundry"
version = "0.14.0"
version = "< 1.0.0"
}
}
}
11 changes: 8 additions & 3 deletions terraform/modules/test_cdn/test_cdn.tf
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,19 @@ data "cloudfoundry_service" "external_domain" {
name = "external-domain"
}

data "cloudfoundry_space" "hello_worlds" {
name = var.space_name
org = var.organization_id
}

resource "zipper_file" "test_cdn_src" {
source = "https://github.com/cloud-gov/cf-hello-worlds/tree/main/static"
output_path = "test-static-app.zip"
}

resource "cloudfoundry_route" "test_cdn_route" {
domain = data.cloudfoundry_domain.fr_domain.id
space = var.space_id
space = data.cloudfoundry_space.hello_worlds.id
hostname = "test-cdn"
}

Expand All @@ -26,15 +31,15 @@ resource "cloudfoundry_route" "test_cdn_route" {
# https://github.com/cloud-gov/cg-provision/blob/417000c786a101988c3edd965f7c78f66ad334fe/terraform/stacks/dns/production.tf#L12-L17
resource "cloudfoundry_service_instance" "test_cdn_instance" {
name = "test-cdn-service"
space = var.space_id
space = data.cloudfoundry_space.hello_worlds.id
service_plan = data.cloudfoundry_service.external_domain.service_plans["domain-with-cdn"]
json_params = "{\"domains\": \"test-cdn.${local.domain_name}\"}"
}

resource "cloudfoundry_app" "test-cdn" {
name = "test-cdn"
buildpack = "staticfile_buildpack"
space = var.space_id
space = data.cloudfoundry_space.hello_worlds.id
path = zipper_file.test_cdn_src.output_path
source_code_hash = zipper_file.test_cdn_src.output_sha

Expand Down
10 changes: 8 additions & 2 deletions terraform/modules/test_cdn/variables.tf
Original file line number Diff line number Diff line change
@@ -1,7 +1,13 @@
variable "iaas_stack_name" {
}

variable "space_id" {
variable "organization_id" {
type = string
description = "Space GUID to deploy test CDN app"
description = "Organization GUID to use for test CDN app"
}

variable "space_name" {
type = string
description = "Space name to use for test CDN app"
default = "hello-worlds"
}
14 changes: 14 additions & 0 deletions terraform/modules/test_cdn/versions.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
terraform {
required_version = "< 2.0.0"
required_providers {
cloudfoundry = {
source = "cloudfoundry-community/cloudfoundry"
version = "< 1.0.0"
}

zipper = {
source = "ArthurHlt/zipper"
version = "0.14.0"
}
}
}
5 changes: 0 additions & 5 deletions terraform/stack/data.tf
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,3 @@ data "terraform_remote_state" "tooling" {
key = "${var.tooling_stack_name}/terraform.tfstate"
}
}

data "cloudfoundry_space" "hello_worlds" {
name = "hello-worlds"
org = cloudfoundry_org.cloud-gov.id
}
7 changes: 6 additions & 1 deletion terraform/stack/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,10 @@ module "test_cdn" {
count = var.iaas_stack_name == "development" ? 0 : 1
source = "../modules/test_cdn"
iaas_stack_name = var.iaas_stack_name
space_id = data.cloudfoundry_space.hello_worlds.id
organization_id = cloudfoundry_org.cloud-gov.id

providers = {
cloudfoundry = cloudfoundry
zipper = zipper
}
}
7 changes: 6 additions & 1 deletion terraform/stack/versions.tf
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,12 @@ terraform {
required_providers {
cloudfoundry = {
source = "cloudfoundry-community/cloudfoundry"
version = "< 1.0.0"
}

zipper = {
source = "ArthurHlt/zipper"
version = "0.14.0"
}
}
}
}

0 comments on commit c8e2633

Please sign in to comment.