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

feat: add timeout block for subaccount subscription #869

Merged
merged 5 commits into from
Jul 25, 2024
Merged

Conversation

lechnerc77
Copy link
Member

Purpose

Does this introduce a breaking change?

[ ] Yes
[X] No

Pull Request Type

What kind of change does this Pull Request introduce?

[ ] Bugfix
[X] Feature
[ ] Refactoring (no functional changes, no api changes)
[ ] Documentation content changes
[ ] Other... Please describe:

How to Test

  • Test the code via automated test
go test ./...
  • Additional test steps
Execute setup with prior released version and do a terraform plan with new version

What to Check

Verify that the following are valid:

  • Automated tests are executed successfully
  • Validate regression

Other Information

n/a

Checklist for reviewer

The following organizational tasks must be completed before merging this PR:

  • The PR is assigned to the Terraform project and a status is set (typically "in review").
  • The PR has the matching labels assigned to it.
  • The PR has a milestone assigned to it.
  • If the PR closes an issue, the issue is referenced.
  • Possible follow-up items are created and linked.

@lechnerc77 lechnerc77 added the enhancement New feature or request label Jul 24, 2024
@lechnerc77 lechnerc77 added this to the 1.6.0 milestone Jul 24, 2024
@lechnerc77 lechnerc77 self-assigned this Jul 24, 2024
@lechnerc77 lechnerc77 marked this pull request as ready for review July 24, 2024 09:48
@lechnerc77
Copy link
Member Author

lechnerc77 commented Jul 24, 2024

Retest for regression was successful, TF framework handles empty timeouts block out of the box, no inconsistencies.

Subscription was CICD application.

Here is the sample configuration used to validate the setup:

provider.tf

terraform {
  required_providers {
    btp = {
      source  = "SAP/btp"
      version = "~>1.4.0"
    }
  }
}

# Configure the BTP Provider
provider "btp" {
  globalaccount  = var.globalaccount
}

main.tf

locals {
  project_subaccount_domain = lower("${var.subaccount_name}")
  project_subaccount_cf_org = substr(replace("${local.project_subaccount_domain}${var.org}", "-", ""), 0, 32)
}

resource "btp_subaccount" "sa_devops" {
  name      = var.subaccount_name
  subdomain = local.project_subaccount_domain
  region    = lower(var.region)
  labels    = var.subaccount_labels
  usage     = var.subaccount_usage
}

resource "btp_subaccount_entitlement" "cicd_app" {
  subaccount_id = resource.btp_subaccount.sa_devops.id
  service_name  = "cicd-app"
  plan_name     = var.cicd_service_plan
}

resource "btp_subaccount_subscription" "cicd_app" {
  subaccount_id = resource.btp_subaccount.sa_devops.id
  app_name      = "cicd-app"
  plan_name     = var.cicd_service_plan
  depends_on    = [btp_subaccount_entitlement.cicd_app]
}

variables.tf

variable "globalaccount" {
  type        = string
  description = "The globalaccount subdomain where the sub account shall be created."
  default     = "PUT YOUR GLOBAL ACCOUNT SUBDOMAIN HERE"
}

variable "subaccount_name" {
  type        = string
  description = "The subaccount name."
  default     = "devopsdemo"
}

variable "region" {
  type        = string
  description = "The region where the sub account shall be created in."
  default     = "us10"
}

variable "org" {
  type        = string
  description = "Your SAP BTP org e.g. department"
  default     = "IT"
}

variable "subaccount_usage" {
  type        = string
  description = "The usage type of the subaccount"
  default     = "NOT_USED_FOR_PRODUCTION"
  validation {
    condition     = contains(["NOT_USED_FOR_PRODUCTION", "USED_FOR_PRODUCTION"], var.subaccount_usage)
    error_message = "Invalid value for the subaccount usage. Only 'NOT_USED_FOR_PRODUCTION' and 'USED_FOR_PRODUCTION' are allowed."
  }
}

variable "cicd_service_plan" {
  type        = string
  description = "The plan for Continous Integration & Delivery subscription"
  default     = "default"
  validation {
    condition     = contains(["free", "default"], var.cicd_service_plan)
    error_message = "Invalid value for Continous Integration & Delivery. Only 'free' and 'default' are allowed."
  }
}

variable "subaccount_labels" {
  type        = map(set(string))
  description = "Labels for subaccount"
  default     = { CostCenter = ["123456789"] }
}

@lechnerc77 lechnerc77 requested review from vipinvkmenon and CHERIANS and removed request for vipinvkmenon and CHERIANS July 24, 2024 10:03
@lechnerc77
Copy link
Member Author

@vipinvkmenon @CHERIANS: when doing the review, please also validate the regression e.g. via the sample configuration provided above.

@lechnerc77 lechnerc77 enabled auto-merge (squash) July 24, 2024 10:39
@diya-dhan
Copy link
Contributor

Tested with the provided configuration. Works as expected. Empty timeout blocks are also handled properly as mentioned by @lechnerc77

Copy link
Contributor

@CHERIANS CHERIANS left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, Have tested with the provided sample

@lechnerc77 lechnerc77 merged commit 021d3c9 into main Jul 25, 2024
15 checks passed
@lechnerc77 lechnerc77 deleted the feat/issue-848 branch July 25, 2024 10:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[FEATURE] Make timeouts on subscription resource configurable
3 participants