Skip to content

Commit 1a552f3

Browse files
chore: sample for S3 as terraform backend (#293)
* chore: sample for S3 as terraform backend * chore: Update documentation fixes * fix: fixes for fmt errors --------- Co-authored-by: Christian Lechner <[email protected]>
1 parent ce0a6bb commit 1a552f3

File tree

6 files changed

+93
-1
lines changed

6 files changed

+93
-1
lines changed

released/terraform-be/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@ As mentioned the default backend stores state as a local file on disk. It is sui
1818

1919
### Kubernetes Backend
2020

21-
The [Kubernetes backend](https://developer.hashicorp.com/terraform/language/settings/backends/kubernetes) stores state in a Kubernetes secret and supports state locking using a Lease resource. It allows for secure and collaborative state management in Kubernetes environments. You find a sample technical setup in the directory [k8sasbackend](./k8sasbackend/README.md)
21+
The [Kubernetes backend](https://developer.hashicorp.com/terraform/language/settings/backends/kubernetes) stores state in a Kubernetes secret and supports state locking using a Lease resource. It allows for secure and collaborative state management in Kubernetes environments. You find a sample technical setup in the directory [k8sasbackend](./k8sasbackend/README.md)
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Backend as S3
2+
3+
The Terraform S3 [backend](https://developer.hashicorp.com/terraform/language/settings/backends/s3) allows you to store the Terraform state files in an Amazon S3 bucket, providing a centralized, reliable, and durable storage solution.
4+
5+
## Example Configuration
6+
7+
```terraform
8+
terraform {
9+
backend "s3" {
10+
bucket = "<Name of your S3 bucket>"
11+
key = "terraform/state"
12+
region = "<Region>"
13+
encrypt = true
14+
acl = "bucket-owner-full-control"
15+
}
16+
}
17+
```
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
terraform {
2+
backend "s3" {
3+
bucket = "btpterraformbackend"
4+
key = "terraform/state"
5+
region = "eu-north-1"
6+
encrypt = true
7+
acl = "bucket-owner-full-control"
8+
}
9+
}
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
###############################################################################################
2+
# Creation of subaccount
3+
###############################################################################################
4+
resource "random_uuid" "uuid" {}
5+
6+
resource "btp_subaccount" "project" {
7+
name = var.subaccount_name
8+
subdomain = "${var.subaccount_name}-${random_uuid.uuid.result}"
9+
region = lower(var.region)
10+
}
11+
12+
######################################################################
13+
# Add entitlement for BAS, Subscribe BAS and add roles
14+
######################################################################
15+
resource "btp_subaccount_entitlement" "bas" {
16+
subaccount_id = btp_subaccount.project.id
17+
service_name = "sapappstudio"
18+
plan_name = var.bas_plan_name
19+
}
20+
21+
resource "btp_subaccount_subscription" "bas-subscribe" {
22+
subaccount_id = btp_subaccount.project.id
23+
app_name = "sapappstudio"
24+
plan_name = var.bas_plan_name
25+
depends_on = [btp_subaccount_entitlement.bas]
26+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
terraform {
2+
required_providers {
3+
btp = {
4+
source = "sap/btp"
5+
version = "~> 1.5.0"
6+
}
7+
}
8+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
######################################################################
2+
# Customer account setup
3+
######################################################################
4+
# subaccount
5+
variable "globalaccount" {
6+
type = string
7+
description = "The globalaccount subdomain."
8+
}
9+
# subaccount
10+
variable "subaccount_name" {
11+
type = string
12+
description = "The subaccount name."
13+
}
14+
# Region
15+
variable "region" {
16+
type = string
17+
description = "The region where the project account shall be created in."
18+
default = "us10"
19+
}
20+
# CLI server
21+
variable "cli_server_url" {
22+
type = string
23+
description = "The BTP CLI server URL."
24+
default = "https://cli.btp.cloud.sap"
25+
}
26+
27+
# Plan_name update
28+
variable "bas_plan_name" {
29+
description = "BAS plan"
30+
type = string
31+
default = "standard-edition" #For production use of Business Application Studio, upgrade the plan from the `free-tier` to the appropriate plan e.g standard-edition
32+
}

0 commit comments

Comments
 (0)