Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
5 changes: 5 additions & 0 deletions released/usecases/app_identifer_for_roles/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Creation of role collections

In some scenarios the creation of a service instance or an app subscription only creates the roles but leaves the creation of the role collections to the user. The biggest pain point when automating this setup is to fetch the correct app identifier.

In this setup we want to show how you can fetch this identifier and use it to create the role collections.
54 changes: 54 additions & 0 deletions released/usecases/app_identifer_for_roles/main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
resource "btp_subaccount" "self" {
name = "My Dev Project"
subdomain = "my-dev-project"
region = var.region
}

resource "btp_subaccount_entitlement" "auditlog-management_default" {
subaccount_id = btp_subaccount.self.id
service_name = "auditlog-management"
plan_name = "default"
}

data "btp_subaccount_service_plan" "auditlog_default" {
name = "default"
offering_name = "auditlog-management"
subaccount_id = btp_subaccount.self.id

depends_on = [btp_subaccount_entitlement.auditlog-management_default]
}

resource "btp_subaccount_service_instance" "auditlog_default" {
name = "auditlog-default-dev"
serviceplan_id = data.btp_subaccount_service_plan.auditlog_default.id
subaccount_id = btp_subaccount.self.id
}

data "btp_subaccount_apps" "all" {
subaccount_id = btp_subaccount.self.id

depends_on = [btp_subaccount_service_instance.auditlog_default]
}

locals {
app_id = try(
{ for app in data.btp_subaccount_apps.all.values : app.xsappname => app.id
if app.xsappname == "auditlog-management" }
)
}

resource "btp_subaccount_role_collection" "auditlog-viewer" {

description = "Audit Log Viewer Role Collection"
name = "Audit Log Viewer"
roles = [
{
name = "Auditlog_Auditor"
role_template_app_id = local.app_id.auditlog-management
role_template_name = "Auditlog_Auditor"
},
]
subaccount_id = btp_subaccount.self.id

depends_on = [data.btp_subaccount_apps.all]
}
14 changes: 14 additions & 0 deletions released/usecases/app_identifer_for_roles/provider.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
terraform {
required_providers {
btp = {
source = "sap/btp"
version = "~>1.12.0"
}
}
}

# Please checkout documentation on how best to authenticate against SAP BTP
# via the Terraform provider for SAP BTP
provider "btp" {
globalaccount = var.globalaccount
}
10 changes: 10 additions & 0 deletions released/usecases/app_identifer_for_roles/variables.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
variable "globalaccount" {
description = "The subdomainof the global account to use for the SAP BTP provider"
type = string
}

variable "region" {
description = "The region of the subaccount"
type = string
default = "us10"
}