home-cloud/k3s_cluster_v2/flux.tf

67 lines
1.7 KiB
Terraform
Raw Normal View History

2021-12-05 00:03:54 +01:00
provider "github" {
owner = var.github_owner
token = var.github_token
}
# SSH
locals {
known_hosts = "github.com ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBEmKSENjQEezOmxkZMy7opKgwFB9nkt5YRrYMjNuG5N87uRgg6CLrbo5wAdT/y6v0mKV0U2w0WZ2YB/++Tpockg="
}
resource "tls_private_key" "main" {
algorithm = "ECDSA"
ecdsa_curve = "P256"
}
# Flux
data "flux_install" "main" {
target_path = var.target_path
2022-06-19 14:04:18 +02:00
version = var.flux_version
2021-12-05 00:03:54 +01:00
}
data "flux_sync" "main" {
target_path = var.target_path
url = "ssh://git@github.com/${var.github_owner}/${var.repository_name}.git"
branch = var.branch
}
# GitHub
resource "github_repository" "main" {
name = var.repository_name
visibility = var.repository_visibility
auto_init = true
}
resource "github_branch_default" "main" {
repository = github_repository.main.name
branch = var.branch
}
resource "github_repository_deploy_key" "main" {
title = "staging-cluster"
repository = github_repository.main.name
key = tls_private_key.main.public_key_openssh
read_only = true
}
resource "github_repository_file" "install" {
repository = github_repository.main.name
file = data.flux_install.main.path
content = data.flux_install.main.content
branch = var.branch
}
resource "github_repository_file" "sync" {
repository = github_repository.main.name
file = data.flux_sync.main.path
content = data.flux_sync.main.content
branch = var.branch
}
resource "github_repository_file" "kustomize" {
repository = github_repository.main.name
file = data.flux_sync.main.kustomize_path
content = data.flux_sync.main.kustomize_content
branch = var.branch
}