Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migrate provider from cloudfoundry-community to cloudfoundry #57

Merged
merged 19 commits into from
Dec 9, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 5 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,13 @@ Creates an s3 bucket and outputs the `bucket_id` for use elsewhere.

```
module "s3" {
source = "github.com/GSA-TTS/terraform-cloudgov//s3?ref=v1.1.0"
source = "github.com/GSA-TTS/terraform-cloudgov//s3?ref=v2.0.0-beta.1"

cf_org_name = local.cf_org_name
cf_space_name = local.cf_space_name
name = "${local.app_name}-s3-${local.env}"
tags = ["tag1", "tag2"]
cf_space_id = data.cloudfoundry_space.app_space.id
name = "${local.app_name}-s3-${local.env}"
tags = ["tag1", "tag2"]
# See options at https://cloud.gov/docs/services/s3/#setting-optional-parameters
json_params = jsonencode(
json_params = jsonencode(
{
"object_ownership" : "ObjectWriter",
}
Expand Down
19 changes: 10 additions & 9 deletions s3/main.tf
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
data "cloudfoundry_space" "space" {
org_name = var.cf_org_name
name = var.cf_space_name
locals {
tags = setunion(["terraform-cloudgov"], var.tags)
rahearn marked this conversation as resolved.
Show resolved Hide resolved
}

data "cloudfoundry_service" "s3" {
name = "s3"
data "cloudfoundry_service_plans" "s3" {
name = var.s3_plan_name
service_offering_name = "s3"
}

resource "cloudfoundry_service_instance" "bucket" {
name = var.name
space = data.cloudfoundry_space.space.id
service_plan = data.cloudfoundry_service.s3.service_plans[var.s3_plan_name]
tags = var.tags
json_params = var.json_params
space = var.cf_space_id
type = "managed"
service_plan = data.cloudfoundry_service_plans.s3.service_plans.0.id
mogul marked this conversation as resolved.
Show resolved Hide resolved
tags = local.tags
parameters = var.json_params
}
4 changes: 2 additions & 2 deletions s3/providers.tf
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ terraform {
required_version = "~> 1.0"
required_providers {
cloudfoundry = {
source = "cloudfoundry-community/cloudfoundry"
version = ">=0.53.1"
source = "cloudfoundry/cloudfoundry"
version = ">=1.1.0"
}
}
}
20 changes: 10 additions & 10 deletions s3/tests/creation.tftest.hcl
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@ provider "cloudfoundry" {
}

variables {
cf_org_name = "gsa-tts-devtools-prototyping"
cf_space_name = "terraform-cloudgov-ci-tests"
s3_plan_name = "basic"
name = "terraform-cloudgov-s3-test"
tags = ["terraform-cloudgov", "tests"]
# this is the ID of the terraform-cloudgov-ci-tests space
cf_space_id = "15836eb6-a57e-4579-bca7-99764c5a01a4"
s3_plan_name = "basic-sandbox"
name = "terraform-cloudgov-s3-test"
tags = ["terraform-cloudgov", "tests"]
}

run "test_bucket_creation" {
Expand All @@ -23,7 +23,7 @@ run "test_bucket_creation" {
}

assert {
condition = cloudfoundry_service_instance.bucket.service_plan == data.cloudfoundry_service.s3.service_plans[var.s3_plan_name]
condition = cloudfoundry_service_instance.bucket.service_plan == data.cloudfoundry_service_plans.s3.service_plans.0.id
mogul marked this conversation as resolved.
Show resolved Hide resolved
error_message = "Service Plan should match the s3_plan_name variable"
}

Expand All @@ -33,12 +33,12 @@ run "test_bucket_creation" {
}

assert {
condition = cloudfoundry_service_instance.bucket.tags == var.tags
condition = cloudfoundry_service_instance.bucket.tags == tolist(var.tags)
error_message = "Service instance tags should match the tags variable"
}
}

run "test_json_params" {
run "test_parameters" {
command = plan

variables {
Expand All @@ -48,7 +48,7 @@ run "test_json_params" {
}

assert {
condition = cloudfoundry_service_instance.bucket.json_params == "{\"object_ownership\":\"BucketOwnerEnforced\"}"
error_message = "Service instance json_params should be configurable"
condition = cloudfoundry_service_instance.bucket.parameters == "{\"object_ownership\":\"BucketOwnerEnforced\"}"
error_message = "Service instance parameters should be configurable"
}
}
11 changes: 3 additions & 8 deletions s3/variables.tf
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
variable "cf_org_name" {
variable "cf_space_id" {
type = string
description = "cloud.gov organization name"
}

variable "cf_space_name" {
type = string
description = "cloud.gov space name (staging or prod)"
description = "cloud.gov space id"
}

variable "name" {
Expand All @@ -22,7 +17,7 @@ variable "s3_plan_name" {

variable "tags" {
description = "A list of tags to add to the resource"
type = list(string)
type = set(string)
default = []
}

Expand Down