Skip to content

Commit 8f92a62

Browse files
authored
Add Terraform deployment for StackIt project team-iac-test01 (#1)
* Update gitignore Signed-off-by: Roman Schwarz <rs@cloudeteer.de> * Add initial Terraform code for test deployment on team-iac-test01 project Signed-off-by: Roman Schwarz <rs@cloudeteer.de> * Add GitHub workflow for test deployment on team-iac-test01 project Signed-off-by: Roman Schwarz <rs@cloudeteer.de> * Add example network Signed-off-by: Roman Schwarz <rs@cloudeteer.de> --------- Signed-off-by: Roman Schwarz <rs@cloudeteer.de>
1 parent 70594c6 commit 8f92a62

7 files changed

Lines changed: 153 additions & 2 deletions

File tree

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: prod-stackit-terraform-team-iac-test01
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
terraform-force-unlock:
7+
default: false
8+
description: Terraform force unlock
9+
required: false
10+
type: boolean
11+
terraform-force-unlock-id:
12+
description: Terraform LOCK_ID
13+
required: false
14+
type: string
15+
pull_request:
16+
paths:
17+
- prod-stackit/terraform/team-iac-test01/**
18+
- .github/workflows/prod-stackit-terraform-team-iac-test01.yaml
19+
20+
permissions:
21+
contents: read
22+
id-token: write
23+
24+
jobs:
25+
terraform:
26+
name: Terraform
27+
uses: cloudeteer/iac-deployment-framework/.github/workflows/terraform-deploy-stackit.yaml@wip/stackit
28+
with:
29+
directory: prod-stackit/terraform/team-iac-test01
30+
terraform-force-unlock-id: ${{ github.event_name == 'workflow_dispatch' && inputs.terraform-force-unlock == true && inputs.terraform-force-unlock-id }}
31+
terraform-force-unlock: ${{ github.event_name == 'workflow_dispatch' && inputs.terraform-force-unlock == true && inputs.terraform-force-unlock }}
32+
secrets:
33+
stackit_service_account_key: ${{ secrets.CDT_IAC_STACKIT_SERVICE_ACCOUNT_KEY_TEAM_IAC_TEST01 }}
34+
backend_s3_secret_key: ${{ secrets.CDT_IAC_STACKIT_BACKEND_S3_SECRET_KEY_TEAM_IAC_TEST01 }}
35+
backend_s3_access_key: ${{ secrets.CDT_IAC_STACKIT_BACKEND_S3_ACCESS_KEY_TEAM_IAC_TEST01 }}

.gitignore

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ crash.log
1010
crash.*.log
1111

1212
# Exclude all .tfvars files, which are likely to contain sensitive data, such as
13-
# password, private keys, and other secrets. These should not be part of version
14-
# control as they are data points which are potentially sensitive and subject
13+
# password, private keys, and other secrets. These should not be part of version
14+
# control as they are data points which are potentially sensitive and subject
1515
# to change depending on the environment.
1616
*.tfvars
1717
*.tfvars.json
@@ -35,3 +35,6 @@ override.tf.json
3535
# Ignore CLI configuration files
3636
.terraformrc
3737
terraform.rc
38+
39+
# Ignore lokal direnv configuration file
40+
.envrc

prod-stackit/terraform/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# /prod-stackit/terraform
2+
3+
Create a subdirectory for each StackIT project

prod-stackit/terraform/team-iac-test01/.terraform.lock.hcl

Lines changed: 28 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Terraform: team-iac-test01
2+
3+
## Getting started
4+
5+
### Create Object Store
6+
7+
```shell
8+
brew tap stackitcloud/tap
9+
brew install stackit
10+
```
11+
12+
```shell
13+
stackit auth login
14+
stackit config set --project-id 341539db-8c67-43cf-ba1f-fd14157a0a5b # team-iac-test01
15+
stackit object-storage enable
16+
```
17+
18+
```shell
19+
stackit object-storage bucket create team-iac-test01-tfstate
20+
```
21+
22+
```shell
23+
# Get object ID
24+
credential_group_id=$(stackit object-storage credentials-group list --output-format json |
25+
jq -r '.[] | select(.displayName == "default") | .credentialsGroupId)
26+
27+
# Create access key
28+
stackit object-storage credentials create --credentials-group-id "$credential_group_id"
29+
```
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
terraform {
2+
required_providers {
3+
stackit = {
4+
source = "stackitcloud/stackit"
5+
version = "0.43.3"
6+
}
7+
}
8+
9+
backend "s3" {
10+
bucket = "team-iac-test01-tfstate"
11+
key = "terraform.tfstate"
12+
endpoints = {
13+
s3 = "https://object.storage.eu01.onstackit.cloud"
14+
}
15+
region = "eu01"
16+
skip_credentials_validation = true
17+
skip_region_validation = true
18+
skip_s3_checksum = true
19+
skip_requesting_account_id = true
20+
21+
# secret_key = null # Set by ENV AWS_SECRET_ACCESS_KEY
22+
# access_key = null # Set by ENV AWS_ACCESS_KEY_ID
23+
}
24+
}
25+
26+
provider "stackit" {
27+
region = "eu01"
28+
29+
# Note: There are no environment variables available for these parameters.
30+
# Instead, we use TF_VAR_service_account_key and TF_VAR_private_key.
31+
service_account_key = var.service_account_key
32+
private_key = var.private_key
33+
}
34+
35+
data "stackit_resourcemanager_project" "team_iac_test01" {
36+
project_id = "341539db-8c67-43cf-ba1f-fd14157a0a5b"
37+
container_id = "team-iac-test01"
38+
}
39+
40+
output "project_name" {
41+
value = data.stackit_resourcemanager_project.team_iac_test01.name
42+
}
43+
44+
resource "stackit_network" "example_with_name" {
45+
project_id = data.stackit_resourcemanager_project.team_iac_test01.project_id
46+
name = "example-network"
47+
}
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
variable "service_account_key" {
2+
}
3+
4+
variable "private_key" {
5+
default = null
6+
}

0 commit comments

Comments
 (0)