-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
First version of Kyma mission 3252. Locally working. Creates a subacc…
…ount and enables Kyma.
- Loading branch information
Showing
5 changed files
with
337 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# Discovery Center mission - Get Started with SAP BTP, Kyma runtime creating a Hello-World Function | ||
|
||
## Overview | ||
|
||
This sample shows how to setup your SAP BTP account for the Discovery Center Mission - [Get Started with SAP BTP, Kyma runtime creating a Hello-World Function](https://discovery-center.cloud.sap/protected/index.html#/mymissiondetail/94380/?tab=projectboard) | ||
|
||
## Content of setup | ||
|
||
The setup comprises the following resources: | ||
|
||
- Creation of the SAP BTP subaccount | ||
- Entitlement to Kyma runtime | ||
- Provisioning Kyma runtime | ||
|
||
## Deploying the resources | ||
|
||
Make sure that you are familiar with SAP BTP and know both the [Get Started with btp-terraform-samples](https://github.com/SAP-samples/btp-terraform-samples/blob/main/GET_STARTED.md) and the [Get Started with the Terraform Provider for BTP](https://developers.sap.com/tutorials/btp-terraform-get-started.html) | ||
|
||
To deploy the resources you must: | ||
|
||
1. Set the environment variables BTP_USERNAME and BTP_PASSWORD to pass credentials to the BTP provider to authenticate and interact with your BTP environments. | ||
|
||
```bash | ||
export BTP_USERNAME=<your_username> | ||
export BTP_PASSWORD=<your_password> | ||
``` | ||
Alternativelly set: | ||
```bash | ||
export BTP_ENABLE_SSO=true | ||
``` | ||
|
||
2. Change the variables in the `sample.tfvars` file to meet your requirements | ||
|
||
> The minimal set of parameters you should specify (beside user_email and password) is globalaccount (i.e. its subdomain) | ||
|
||
> ⚠ NOTE: You should pay attention **specifically** to the users defined in the samples.tfvars whether they already exist in your SAP BTP accounts. Otherwise you might get error messages like e.g. `Error: The user could not be found: jane.doe@test.com`. | ||
|
||
|
||
3. Initialize your workspace: | ||
|
||
```bash | ||
terraform init | ||
``` | ||
|
||
4. You can check what Terraform plans to apply based on your configuration: | ||
|
||
```bash | ||
terraform plan -var-file="sample.tfvars" | ||
``` | ||
|
||
5. Apply your configuration to provision the resources: | ||
|
||
```bash | ||
terraform apply -var-file="sample.tfvars" | ||
``` |
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,80 @@ | ||
############################################################################################### | ||
# Setup of names in accordance to naming convention | ||
############################################################################################### | ||
resource "random_uuid" "uuid" {} | ||
|
||
locals { | ||
random_uuid = random_uuid.uuid.result | ||
project_subaccount_domain = lower(replace("mission-3252-${local.random_uuid}", "_", "-")) | ||
} | ||
|
||
############################################################################################### | ||
# Creation of subaccount | ||
############################################################################################### | ||
resource "btp_subaccount" "project" { | ||
name = var.subaccount_name | ||
subdomain = local.project_subaccount_domain | ||
region = lower(var.region) | ||
} | ||
|
||
############################################################################################### | ||
# Assignment of users as sub account administrators | ||
############################################################################################### | ||
resource "btp_subaccount_role_collection_assignment" "subaccount-admins" { | ||
for_each = toset("${var.subaccount_admins}") | ||
subaccount_id = btp_subaccount.project.id | ||
role_collection_name = "Subaccount Administrator" | ||
user_name = each.value | ||
} | ||
|
||
############################################################################################### | ||
# Assignment of users as sub account service administrators | ||
############################################################################################### | ||
resource "btp_subaccount_role_collection_assignment" "subaccount-service-admins" { | ||
for_each = toset("${var.subaccount_service_admins}") | ||
subaccount_id = btp_subaccount.project.id | ||
role_collection_name = "Subaccount Service Administrator" | ||
user_name = each.value | ||
} | ||
|
||
###################################################################### | ||
# Setup Kyma | ||
###################################################################### | ||
data "btp_regions" "all" {} | ||
|
||
data "btp_subaccount" "this" { | ||
id = btp_subaccount.project.id | ||
} | ||
|
||
locals { | ||
subaccount_iaas_provider = [for region in data.btp_regions.all.values : region if region.region == data.btp_subaccount.this.region][0].iaas_provider | ||
} | ||
|
||
resource "btp_subaccount_entitlement" "kymaruntime" { | ||
subaccount_id = btp_subaccount.project.id | ||
service_name = "kymaruntime" | ||
plan_name = lower(local.subaccount_iaas_provider) | ||
amount = 1 | ||
} | ||
|
||
|
||
resource "btp_subaccount_environment_instance" "kyma" { | ||
subaccount_id = btp_subaccount.project.id | ||
name = var.kyma_instance.name | ||
environment_type = "kyma" | ||
service_name = "kymaruntime" | ||
plan_name = lower(local.subaccount_iaas_provider) | ||
parameters = jsonencode({ | ||
name = var.kyma_instance.name | ||
region = var.kyma_instance.region | ||
machine_type = var.kyma_instance.machine_type | ||
auto_scaler_min = var.kyma_instance.auto_scaler_min | ||
auto_scaler_max = var.kyma_instance.auto_scaler_max | ||
}) | ||
timeouts = { | ||
create = var.kyma_instance.createtimeout | ||
update = var.kyma_instance.updatetimeout | ||
delete = var.kyma_instance.deletetimeout | ||
} | ||
depends_on = [btp_subaccount_entitlement.kymaruntime] | ||
} |
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,13 @@ | ||
terraform { | ||
required_providers { | ||
btp = { | ||
source = "SAP/btp" | ||
version = "~> 1.4.0" | ||
} | ||
} | ||
} | ||
|
||
provider "btp" { | ||
#cli_server_url = var.cli_server_url | ||
globalaccount = var.globalaccount | ||
} |
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,25 @@ | ||
# ------------------------------------------------------------------------------------------------------ | ||
# Provider configuration | ||
# ------------------------------------------------------------------------------------------------------ | ||
# Your global account subdomain | ||
globalaccount = "your global account id goes here eg. 0645xxxx-1xxx-4xxx-bxxx-4xxxxxxxxxxx" | ||
region = "eu30" | ||
subaccount_name = "DC Mission 3252 - Get Started with SAP BTP, Kyma runtime creating a Hello-World Function" | ||
|
||
kyma_instance = { | ||
name = "my-kyma-environment" | ||
region = "europe-west3" | ||
machine_type = "mx5.xlarge" | ||
auto_scaler_min = 3 | ||
auto_scaler_max = 20 | ||
createtimeout = "1h" | ||
updatetimeout = "35m" | ||
deletetimeout = "1h" | ||
} | ||
|
||
# ------------------------------------------------------------------------------------------------------ | ||
# Project specific configuration (please adapt!) | ||
# ------------------------------------------------------------------------------------------------------ | ||
subaccount_admins = ["your.admin.email.address@your.company.com"] | ||
subaccount_service_admins = ["your.admin.email.address@your.company.com"] | ||
|
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,164 @@ | ||
###################################################################### | ||
# Customer account setup | ||
###################################################################### | ||
# subaccount | ||
variable "globalaccount" { | ||
type = string | ||
description = "The globalaccount subdomain." | ||
default = "your globalaccount subdomain" | ||
} | ||
# subaccount | ||
variable "subaccount_name" { | ||
type = string | ||
description = "The subaccount name." | ||
default = "DC Mission 3252 - Get Started with SAP BTP, Kyma runtime creating a Hello-World Function" | ||
} | ||
# Region | ||
variable "region" { | ||
type = string | ||
description = "The region where the project account shall be created in." | ||
default = "eu30" | ||
} | ||
|
||
# CLI server | ||
variable "cli_server_url" { | ||
type = string | ||
description = "The BTP CLI server URL." | ||
default = "https://cpcli.cf.eu10.hana.ondemand.com" | ||
} | ||
|
||
variable "subaccount_admins" { | ||
type = list(string) | ||
description = "Defines the colleagues who are added to each subaccount as subaccount administrators." | ||
default = ["jane.doe@test.com", "john.doe@test.com"] | ||
} | ||
|
||
variable "subaccount_service_admins" { | ||
type = list(string) | ||
description = "Defines the colleagues who are added to each subaccount as subaccount service administrators." | ||
default = ["jane.doe@test.com", "john.doe@test.com"] | ||
} | ||
|
||
|
||
|
||
### | ||
# Entitlements | ||
### | ||
variable "entitlements" { | ||
type = list(object({ | ||
service_name = string | ||
plan_name = string | ||
type = string | ||
})) | ||
description = "The list of entitlements that shall be added to the subaccount." | ||
default = [ | ||
{ | ||
service_name = "destination" | ||
plan_name = "lite", | ||
type = "service" | ||
}, | ||
{ | ||
service_name = "xsuaa" | ||
plan_name = "application", | ||
type = "service" | ||
}, | ||
{ | ||
service_name = "integrationsuite" | ||
plan_name = "enterprise_agreement", | ||
type = "app" | ||
}, | ||
{ | ||
service_name = "sap-build-apps" | ||
plan_name = "standard" | ||
type = "service" | ||
}, | ||
{ | ||
service_name = "process-automation" | ||
plan_name = "standard", | ||
type = "app" | ||
}, | ||
{ | ||
service_name = "process-automation-service" | ||
plan_name = "standard", | ||
type = "service" | ||
}, | ||
{ | ||
service_name = "apimanagement-apiportal" | ||
plan_name = "apiportal-apiaccess", | ||
type = "service" | ||
}, | ||
{ | ||
service_name = "apimanagement-devportal" | ||
plan_name = "devportal-apiaccess", | ||
type = "service" | ||
} | ||
] | ||
} | ||
|
||
variable "kyma_instance" { | ||
type = object({ | ||
name = string | ||
region = string | ||
machine_type = string | ||
auto_scaler_min = number | ||
auto_scaler_max = number | ||
createtimeout = string | ||
updatetimeout = string | ||
deletetimeout = string | ||
}) | ||
description = "Your Kyma environment configuration" | ||
} | ||
|
||
variable "conn_dest_admin" { | ||
type = list(string) | ||
description = "Connectivity and Destination Administrator" | ||
default = ["jane.doe@test.com", "john.doe@test.com"] | ||
} | ||
|
||
variable "int_provisioner" { | ||
type = list(string) | ||
description = "Integration Provisioner" | ||
default = ["jane.doe@test.com", "john.doe@test.com"] | ||
} | ||
|
||
variable "users_BuildAppsAdmin" { | ||
type = list(string) | ||
description = "Defines the colleagues who have the role of 'BuildAppsAdmin' in SAP Build Apps." | ||
default = ["jane.doe@test.com", "john.doe@test.com"] | ||
} | ||
|
||
variable "users_BuildAppsDeveloper" { | ||
type = list(string) | ||
description = "Defines the colleagues who have the role of 'BuildAppsDeveloper' in SAP Build Apps." | ||
default = ["jane.doe@test.com", "john.doe@test.com"] | ||
} | ||
|
||
variable "users_RegistryAdmin" { | ||
type = list(string) | ||
description = "Defines the colleagues who have the role of 'RegistryAdmin' in SAP Build Apps." | ||
default = ["jane.doe@test.com", "john.doe@test.com"] | ||
} | ||
|
||
variable "users_RegistryDeveloper" { | ||
type = list(string) | ||
description = "Defines the colleagues who have the role of RegistryDeveloper' in SAP Build Apps." | ||
default = ["jane.doe@test.com", "john.doe@test.com"] | ||
} | ||
|
||
variable "ProcessAutomationAdmin" { | ||
type = list(string) | ||
description = "Defines the users who have the role of ProcessAutomationAdmin in SAP Build Process Automation" | ||
default = ["jane.doe@test.com", "john.doe@test.com"] | ||
} | ||
|
||
variable "ProcessAutomationDeveloper" { | ||
type = list(string) | ||
description = "Defines the users who have the role of ProcessAutomationDeveloper in SAP Build Process Automation" | ||
default = ["jane.doe@test.com", "john.doe@test.com"] | ||
} | ||
|
||
variable "ProcessAutomationParticipant" { | ||
type = list(string) | ||
description = "Defines the users who have the role of ProcessAutomationParticipant in SAP Build Process Automation" | ||
default = ["jane.doe@test.com", "john.doe@test.com"] | ||
} |