Source
yaml
id: create-repository
namespace: company.team
inputs:
- id: repository_name
type: STRING
- id: description
type: STRING
tasks:
- id: terraform
type: io.kestra.plugin.terraform.cli.TerraformCLI
inputFiles:
main.tf: |
terraform {
required_providers {
github = {
source = "integrations/github"
version = "~> 6.0"
}
}
}
provider "github" {
token = "{{ secret('GITHUB_TOKEN') }}"
}
resource "github_repository" "{{inputs.repository_name}}" {
name = "{{inputs.repository_name}}"
description = "{{ inputs.description }}"
auto_init = true
visibility = "public"
}
beforeCommands:
- terraform init
commands:
- terraform plan 2>&1 | tee plan_output.txt
- terraform apply -auto-approve 2>&1 | tee apply_output.txt
outputFiles:
- "*.txt"
About this blueprint
DevOps Git
This blueprint showcase how to create a GitHub repository using Terraform GitHub provider.
Note: here we don't provide any Terraform state backend. Therefore, state won't be persisted and the flow can only act as a one-off execution. Make sure to configure the Terraform backend to persist the Terrafom state. This blueprint is still useful if you want to quickly create a GitHub repository.
You will need a GitHub API token to authenticate with GitHub. Check the corresponding documentation on how to create a Personal GitHub Token.
More Related Blueprints