Skip to content

Commit

Permalink
initial version
Browse files Browse the repository at this point in the history
  • Loading branch information
lechnerc77 committed Jun 10, 2024
0 parents commit a754d20
Show file tree
Hide file tree
Showing 16 changed files with 660 additions and 0 deletions.
24 changes: 24 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"name": "Terraform provider for SAP BTP - Default",
"image": "mcr.microsoft.com/devcontainers/base:debian",
// Features to add to the dev container. More info: https://containers.dev/features.
"features": {
"ghcr.io/devcontainers/features/terraform:1": {},
"ghcr.io/devcontainers/features/github-cli:1": {}
},
"customizations": {
"vscode": {
"settings": {},
"extensions": [
"HashiCorp.terraform"
]
},
"codespaces": {}
},
"hostRequirements": {
"memory": "4gb"
},
// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],
"remoteUser": "vscode"
}
32 changes: 32 additions & 0 deletions .devcontainer/withenvfile/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"name": "Terraform provider for SAP BTP - with env file",
"image": "mcr.microsoft.com/devcontainers/base:debian",
// Features to add to the dev container. More info: https://containers.dev/features.
"features": {
"ghcr.io/devcontainers/features/terraform:1": {},
"ghcr.io/devcontainers/features/github-cli:1": {}
},
"customizations": {
"vscode": {
"settings": {},
"extensions": [
"HashiCorp.terraform"
]
},
"codespaces": {}
},
"hostRequirements": {
"memory": "4gb"
},
// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],
"remoteUser": "vscode",
// This devcontainer expects a file named .devcontainer/devcontainer.env to exist.
// you should place the following environment variables in that file:
// - BTP_USERNAME
// - BTP_PASSWORD
"runArgs": [
"--env-file",
".devcontainer/devcontainer.env"
]
}
10 changes: 10 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
- package-ecosystem: "terraform"
directory: "/"
schedule:
interval: "weekly"
41 changes: 41 additions & 0 deletions .github/workflows/terraform_format_check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Terraform Format Check

on:
pull_request:
types:
- opened
- reopened
- synchronize
- ready_for_review

jobs:
terraform-fmt:
name: Validate Format of Terraform Files
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup Terraform
uses: hashicorp/setup-terraform@v3
with:
terraform_wrapper: false

- name: Get changed directories
id: changed-files
uses: tj-actions/changed-files@v44
with:
dir_names: 'true'

- name: Validate Terraform format
if: steps.changed-files.outputs.any_changed == 'true'
env:
ALL_CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }}
shell: bash
run: |
EXIT_CODE=0
for file in ${ALL_CHANGED_FILES}; do
echo "Checking format of $file with terraform fmt"
terraform fmt -check -recursive "$file" || EXIT_CODE=$?
done
exit $EXIT_CODE
31 changes: 31 additions & 0 deletions .github/workflows/terraform_unit_test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Terraform Unit Tests

on:
pull_request:
types:
- opened
- reopened
- synchronize
- ready_for_review
workflow_dispatch:

jobs:
terraform-validate:
name: Validate Syntax of Terraform Files
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup Terraform
uses: hashicorp/setup-terraform@v3
with:
terraform_wrapper: false

- name: Execute Unit Tests
shell: bash
run: |
cd ./infra
terraform init -backend=false
terraform test -test-directory=unit-tests
45 changes: 45 additions & 0 deletions .github/workflows/terraform_validate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Terraform Validation Check

on:
pull_request:
types:
- opened
- reopened
- synchronize
- ready_for_review

jobs:
terraform-validate:
name: Validate Syntax of Terraform Files
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup Terraform
uses: hashicorp/setup-terraform@v3
with:
terraform_wrapper: false

- name: Get changed directories
id: changed-files
uses: tj-actions/changed-files@v44
with:
dir_names: 'true'

- name: Validate Terraform sytnax
if: steps.changed-files.outputs.any_changed == 'true'
env:
ALL_CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }}
shell: bash
run: |
EXIT_CODE=0
for file in ${ALL_CHANGED_FILES}; do
echo "Validating Terraform files in $file with terraform validate"
cd $file
terraform init -backend=false || EXIT_CODE=$?
terraform validate || EXIT_CODE=$?
rm -rf .terraform/
cd ${{ github.workspace }}
done
exit $EXIT_CODE
38 changes: 38 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Local .terraform directories
**/.terraform/*
**/.terraform.lock.hcl

# .tfstate files
*.tfstate
*.tfstate.*

# Crash log files
crash.log
crash.*.log

# Exclude all .tfvars files, which are likely to contain sensitive data, such as
# password, private keys, and other secrets. These should not be part of version
# control as they are data points which are potentially sensitive and subject
# to change depending on the environment.
*.tfvars
*.tfvars.json

# Ignore override files as they are usually used to override resources locally and so
# are not checked in
override.tf
override.tf.json
*_override.tf
*_override.tf.json

# Include override files you do wish to add to version control using negated pattern
# !example_override.tf

# Include tfplan files to ignore the plan output of command: terraform plan -out=tfplan
# example: *tfplan*

# Ignore CLI configuration files
.terraformrc
terraform.rc

# Ignore .env
*.env
Loading

0 comments on commit a754d20

Please sign in to comment.