File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -14,26 +14,31 @@ terraform {
1414}
1515
1616resource "github_repository" "dbt_repo" {
17- name = " dbt_${ var . project_slug } "
18- description = " Code for the dbt project ${ var . project_name } "
17+ name = " dbt_${ var . project_slug } "
18+ description = " Code for the dbt project ${ var . project_name } "
1919
20- visibility = " public"
21- auto_init = false
20+ visibility = " public"
21+ auto_init = false
2222}
2323
2424
2525resource "github_branch_protection" "dbt_repo" {
26- repository_id = github_repository. dbt_repo . node_id
27- pattern = " main"
28- enforce_admins = false
26+ repository_id = github_repository. dbt_repo . node_id
27+ pattern = " main"
28+ enforce_admins = false
2929
3030 required_pull_request_reviews {
31- restrict_dismissals = false
31+ restrict_dismissals = false
3232 required_approving_review_count = 1
3333
3434 }
3535}
3636
37+ locals {
38+ https_url = github_repository. dbt_repo . http_clone_url
39+ https_url_with_pat = replace (local. https_url , " https://" , " https://${ var . github_token } @" )
40+ }
41+
3742# this will happen only when the repo is created
3843resource "null_resource" "post_repo_creation" {
3944 provisioner "local-exec" {
@@ -51,7 +56,7 @@ resource "null_resource" "post_repo_creation" {
5156 git add *
5257 git commit -m "Initial commit from Terraform and cruft"
5358 git branch -M main
54- git remote add origin ${ github_repository . dbt_repo . http_clone_url }
59+ git remote add origin ${ local . https_url_with_pat }
5560 git push -u origin main
5661 cd ../..
5762 rm -rf cruft-template
Original file line number Diff line number Diff line change 11output "github_repo_remote_url" {
2- value = github_repository. dbt_repo . ssh_clone_url
2+ value = github_repository. dbt_repo . ssh_clone_url
33}
Original file line number Diff line number Diff line change 11variable "github_token" {
2- description = " GitHub token to crate repos"
3- type = string
2+ description = " GitHub token to crate repos"
3+ type = string
44}
55
66variable "project_slug" {
7- description = " Slug for the project"
8- type = string
7+ description = " Slug for the project"
8+ type = string
99}
1010
1111variable "project_name" {
12- description = " Project Name"
13- type = string
12+ description = " Project Name"
13+ type = string
1414}
1515
1616variable "cruft_template_url" {
17- description = " URL for the Cruft template"
18- type = string
17+ description = " URL for the Cruft template"
18+ type = string
1919}
You can’t perform that action at this time.
0 commit comments