Skip to content

Commit 0b5cc2d

Browse files
committed
move to github
1 parent 377d2b5 commit 0b5cc2d

11 files changed

Lines changed: 384 additions & 1 deletion

File tree

.github/release-drafter.yml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
---
2+
# Format and labels used aim to match those used by Ansible project
3+
name-template: '$RESOLVED_VERSION'
4+
tag-template: '$RESOLVED_VERSION'
5+
categories:
6+
- title: 'Major Changes'
7+
labels:
8+
- 'major' # c6476b
9+
- title: 'Minor Changes'
10+
labels:
11+
- 'feature' # 006b75
12+
- 'enhancement' # ededed
13+
- 'refactoring'
14+
- title: 'Bugfixes'
15+
labels:
16+
- 'bug' # fbca04
17+
- title: 'Deprecations'
18+
labels:
19+
- 'deprecated' # fef2c0
20+
exclude-labels:
21+
- 'skip-changelog'
22+
- 'duplicate'
23+
version-resolver:
24+
major:
25+
labels:
26+
- 'major'
27+
minor:
28+
labels:
29+
- 'minor'
30+
- 'feature'
31+
- 'enhancement'
32+
- 'refactoring'
33+
patch:
34+
labels:
35+
- 'patch'
36+
- 'bug'
37+
- 'deprecated'
38+
default: patch
39+
autolabeler:
40+
- label: 'skip-changelog'
41+
title: '/chore/i'
42+
- label: 'bug'
43+
title: '/fix/i'
44+
- label: 'enhancement'
45+
title: '/(enhance|improve)/i'
46+
- label: 'feature'
47+
title: '/feature/i'
48+
- label: 'dreprecated'
49+
title: '/deprecat/i'
50+
template: |
51+
$CHANGES
52+
Kudos goes to: $CONTRIBUTORS

.github/workflows/prettier-md.yml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
---
2+
# https://github.com/creyD/prettier_action
3+
name: Prettier markdown files
4+
5+
on:
6+
push:
7+
paths:
8+
- '**.md'
9+
10+
jobs:
11+
prettier-md:
12+
runs-on: ubuntu-latest
13+
timeout-minutes: 1
14+
15+
steps:
16+
- name: Git checkout
17+
uses: actions/checkout@v2
18+
with:
19+
ref: ${{ github.head_ref }}
20+
21+
- name: Prettify code
22+
uses: creyD/prettier_action@v3.1
23+
with:
24+
prettier_options: --write {**/*,*}.md

.github/workflows/release.yml

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
---
2+
name: New release
3+
4+
on: # yamllint disable-line rule:truthy
5+
workflow_dispatch:
6+
push:
7+
branches:
8+
- main
9+
10+
jobs:
11+
generate_changelog:
12+
runs-on: ubuntu-latest
13+
name: create release draft
14+
steps:
15+
- uses: actions/checkout@v2.3.4
16+
with:
17+
fetch-depth: 0
18+
19+
- name: 'Get Previous tag'
20+
id: previoustag
21+
uses: "WyriHaximus/github-action-get-previous-tag@master"
22+
env:
23+
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
24+
25+
- name: calculate next version
26+
id: version
27+
uses: patrickjahns/version-drafter-action@v1
28+
env:
29+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
30+
31+
- name: Generate changelog
32+
uses: charmixer/auto-changelog-action@v1
33+
with:
34+
token: ${{ secrets.GITHUB_TOKEN }}
35+
future_release: ${{ steps.version.outputs.next-version }}
36+
37+
- name: Generate readme
38+
uses: terraform-docs/gh-actions@main
39+
with:
40+
working-dir: .
41+
output-file: README.md
42+
output-method: inject
43+
44+
- name: push changelog and readme
45+
uses: github-actions-x/commit@v2.6
46+
with:
47+
github-token: ${{ secrets.GITHUB_TOKEN }}
48+
push-branch: 'main'
49+
commit-message: 'update changelog'
50+
force-add: 'true'
51+
files: CHANGELOG.md README.md
52+
name: T-Systems MMS
53+
email: frage@t-systems-mms.com
54+
55+
# do a second checkout to prevent race situation
56+
# changelog gets updated but action works on old commit id
57+
- uses: actions/checkout@v2.3.4
58+
with:
59+
ref: main
60+
61+
- name: Generate changelog for the release
62+
run: |
63+
sed '/## \[${{ steps.previoustag.outputs.tag }}\]/Q' CHANGELOG.md > CHANGELOGRELEASE.md
64+
- name: Read CHANGELOG.md
65+
id: package
66+
uses: juliangruber/read-file-action@v1
67+
with:
68+
path: ./CHANGELOGRELEASE.md
69+
70+
- name: Create Release draft
71+
id: create_release
72+
uses: actions/create-release@v1
73+
env:
74+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
75+
with:
76+
release_name: ${{ steps.version.outputs.next-version }}
77+
tag_name: ${{ steps.version.outputs.next-version }}
78+
body: |
79+
${{ steps.package.outputs.content }}
80+
draft: true
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
---
2+
name: Terraform Lint
3+
4+
on: [push, pull_request]
5+
6+
jobs:
7+
terraform-lint:
8+
runs-on: ubuntu-latest
9+
10+
steps:
11+
# Important: This sets up your GITHUB_WORKSPACE environment variable
12+
- uses: actions/checkout@v2
13+
- name: Lint Terraform
14+
# replace "master" with any valid ref
15+
uses: actionshub/terraform-lint@main

.terraform-docs.yml

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
formatter: template
2+
3+
sections:
4+
show:
5+
- header
6+
- requirements
7+
- providers
8+
- resources
9+
- modules
10+
- inputs
11+
- outputs
12+
- footer
13+
14+
content: |-
15+
{{ .Header }}
16+
17+
<-- This file is autogenerated, please do not change. -->
18+
19+
{{ .Requirements }}
20+
21+
{{ .Providers }}
22+
23+
{{ .Resources }}
24+
25+
{{ .Inputs }}
26+
27+
{{ .Outputs }}
28+
29+
## Examples
30+
31+
```hcl
32+
{{ include "examples/main.tf" }}
33+
```
34+
35+
sort:
36+
enabled: true
37+
by: required
38+
39+
settings:
40+
indent: 2
41+
hide-empty: true
42+
anchor: false
43+
escape: false
44+
required: true
45+
type: true
46+
read-comments: true

README.md

Lines changed: 0 additions & 1 deletion
This file was deleted.

examples/main.tf

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
module "dns_zone" {
2+
source = "../terraform-dns"
3+
resource_group_name = "service-infrastructure-rg"
4+
dns_zone = {
5+
domain_com = "domain.com"
6+
domain_de = "domain.de"
7+
}
8+
}

main.tf

Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
# DNS Zone
2+
resource "azurerm_dns_zone" "dns_zone" {
3+
for_each = local.dns_zone
4+
5+
name = each.value
6+
resource_group_name = var.resource_group_name
7+
8+
tags = {
9+
for tag in keys(local.tags) :
10+
tag => local.tags[tag]
11+
}
12+
}
13+
14+
resource "azurerm_private_dns_zone" "private_dns_zone" {
15+
for_each = local.private_dns_zone
16+
17+
name = each.value
18+
resource_group_name = var.resource_group_name
19+
20+
tags = {
21+
for tag in keys(local.tags) :
22+
tag => local.tags[tag]
23+
}
24+
}
25+
26+
# A Records
27+
resource "azurerm_dns_a_record" "dns_a_record" {
28+
for_each = local.dns_a_record
29+
30+
name = each.key
31+
resource_group_name = var.resource_group_name
32+
zone_name = local.dns_a_record[each.key].zone_name
33+
ttl = local.dns_a_record[each.key].ttl
34+
records = local.dns_a_record[each.key].records
35+
36+
tags = {
37+
for tag in keys(local.tags) :
38+
tag => local.tags[tag]
39+
}
40+
}
41+
# alias records to azure resources
42+
resource "azurerm_dns_a_record" "dns_a_target" {
43+
for_each = local.dns_a_target
44+
45+
name = each.key
46+
resource_group_name = var.resource_group_name
47+
zone_name = local.dns_a_target[each.key].zone_name
48+
ttl = local.dns_a_target[each.key].ttl
49+
target_resource_id = local.dns_a_target[each.key].target_resource_id
50+
51+
tags = {
52+
for tag in keys(local.tags) :
53+
tag => local.tags[tag]
54+
}
55+
}
56+
57+
# CNAME Records
58+
resource "azurerm_dns_cname_record" "dns_cname_record" {
59+
for_each = local.dns_cname_record
60+
61+
name = each.key
62+
resource_group_name = var.resource_group_name
63+
zone_name = local.dns_cname_record[each.key].zone_name
64+
ttl = local.dns_cname_record[each.key].ttl
65+
record = local.dns_cname_record[each.key].record
66+
67+
tags = {
68+
for tag in keys(local.tags) :
69+
tag => local.tags[tag]
70+
}
71+
}

providers.tf

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
provider "azurerm" {
2+
features {}
3+
}

variables.tf

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
variable "resource_group_name" {
2+
type = string
3+
description = "resource_group whitin the resource should be created"
4+
}
5+
variable "tags" {
6+
type = any
7+
default = {}
8+
description = "mapping of tags to assign, default settings are defined within locals and merged with var settings"
9+
}
10+
# resource definition
11+
variable "dns_zone" {
12+
type = any
13+
default = {}
14+
description = "resource definition, default settings are defined within locals and merged with var settings"
15+
}
16+
variable "private_dns_zone" {
17+
type = any
18+
default = {}
19+
description = "resource definition, default settings are defined within locals and merged with var settings"
20+
}
21+
variable "dns_a_record" {
22+
type = any
23+
default = {}
24+
description = "resource definition, default settings are defined within locals and merged with var settings"
25+
}
26+
variable "dns_a_target" {
27+
type = any
28+
default = {}
29+
description = "resource definition, default settings are defined within locals and merged with var settings"
30+
}
31+
variable "dns_cname_record" {
32+
type = any
33+
default = {}
34+
description = "resource definition, default settings are defined within locals and merged with var settings"
35+
}
36+
37+
locals {
38+
# default values
39+
default = {
40+
tags = {}
41+
# resource definition
42+
dns_zone = {}
43+
private_dns_zone = {}
44+
dns_a_record = {
45+
ttl = "900"
46+
}
47+
dns_a_target = {
48+
ttl = "900"
49+
}
50+
dns_cname_record = {
51+
ttl = "900"
52+
}
53+
}
54+
55+
# merge custom and default values
56+
tags = merge(local.default.tags, var.tags)
57+
dns_zone = merge(local.default.dns_zone, var.dns_zone)
58+
private_dns_zone = merge(local.default.private_dns_zone, var.private_dns_zone)
59+
60+
# deep merge
61+
dns_a_record = {
62+
# get all config
63+
for config in keys(var.dns_a_record) :
64+
config => merge(local.default.dns_a_record, var.dns_a_record[config])
65+
}
66+
dns_a_target = {
67+
# get all config
68+
for config in keys(var.dns_a_target) :
69+
config => merge(local.default.dns_a_target, var.dns_a_target[config])
70+
}
71+
dns_cname_record = {
72+
# get all config
73+
for config in keys(var.dns_cname_record) :
74+
config => merge(local.default.dns_cname_record, var.dns_cname_record[config])
75+
}
76+
}

0 commit comments

Comments
 (0)