Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: Add minimal terraform project #308

Merged
merged 5 commits into from
Feb 18, 2022

Conversation

bryphe-coder
Copy link
Contributor

I was thinking it might be nice to have some example projects (especially as we on-board new developers) to make it easy to create new projects.

This adds the most basic possible terraform module... just an output block. However, it's enough to run coder projects create and go through the whole lifecycle of creating a project and workspace (although, it's really boring since there are no parameters).

The folder structure I added looks like this:

  • examples
    • minimal-project

Open to ideas though - other possibilities:

  • We could keep these in a separate repo
  • We could keep them in a notion doc

@bryphe-coder bryphe-coder self-assigned this Feb 17, 2022
@codecov
Copy link

codecov bot commented Feb 17, 2022

Codecov Report

Merging #308 (4deb0ad) into main (e5db936) will increase coverage by 2.58%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #308      +/-   ##
==========================================
+ Coverage   64.81%   67.39%   +2.58%     
==========================================
  Files          67      140      +73     
  Lines         756     7407    +6651     
  Branches       74       77       +3     
==========================================
+ Hits          490     4992    +4502     
- Misses        251     1904    +1653     
- Partials       15      511     +496     
Flag Coverage Δ
unittest-go-macos-latest 66.24% <ø> (?)
unittest-go-ubuntu-latest 67.28% <ø> (?)
unittest-go-windows-latest 65.77% <ø> (?)
unittest-js 63.61% <ø> (-1.21%) ⬇️
Impacted Files Coverage Δ
site/components/SignIn/index.tsx 0.00% <0.00%> (ø)
provisionersdk/serve.go 35.13% <0.00%> (ø)
cryptorand/numbers.go 46.90% <0.00%> (ø)
coderd/projects.go 62.64% <0.00%> (ø)
coderd/coderd.go 95.28% <0.00%> (ø)
cryptorand/strings.go 80.64% <0.00%> (ø)
peerbroker/listen.go 84.80% <0.00%> (ø)
coderd/projectimport.go 59.39% <0.00%> (ø)
site/embed.go 83.14% <0.00%> (ø)
cli/projectplan.go 62.50% <0.00%> (ø)
... and 65 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e5db936...4deb0ad. Read the comment docs.

@@ -0,0 +1,8 @@
terraform {
required_version = ">= 0.12.26"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unrelated to your change, but this brings up a few questions for me:

  • Do we anticipate that we'll need to be able to handle multiple different versions of Terraform being co-installed? I don't know what their compatibility story is like
  • Do we expect that each project will have one (and only one) Terraform file? Of course it can include submodules, but if the amount of infrastructure managed by a given project grows too much, it can make things really slow

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good questions!

Do we anticipate that we'll need to be able to handle multiple different versions of Terraform being co-installed?

I believe our provisionerd will be tied to a certain version of terraform, but I could be wrong. We'll need to communicate out a requirement as to what terraform binary needs to be available. It'd be great to have a health-check, too, to verify that terraform is in the environment and at a supported version.

Do we expect that each project will have one (and only one) Terraform file? Of course it can include submodules, but if the amount of infrastructure managed by a given project grows too much, it can make things really slow

I suspect most projects will have more terraform files than in the example. The project create workflow zips up the entire folder into a tar.gz, and sends it as collateral for the command - so we support having more than just a single file.

@@ -10,7 +10,8 @@ This repository contains source code for Coder V2. Additional documentation:
## Directory Structure

- `.github/`: Settings for [Dependabot for updating dependencies](https://docs.github.com/en/code-security/supply-chain-security/customizing-dependency-updates) and [build/deploy pipelines with GitHub Actions](https://docs.github.com/en/actions/reference/workflow-syntax-for-github-actions).
- [`semantic.yaml`](./github/semantic.yaml): Configuration for [semantic pull requests](https://github.com/apps/semantic-pull-requests)
- [`semantic.yaml`](./github/semantic.yaml): Configuration for [semantic pull requests](https://github.com/apps/semantic-pull-requests)\
- `examples`: Example terraform project templates.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm thinking we'll eventually rename this to templates (once that product functionality exists), but this is great for now!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool! I'll switch it over as part of this PR, so we're closer to the ideal.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually I totally missed that we already have a templates folder (with a simple example like this PR has) - introduced here #246

That does the same job as this PR - so I'll close this out and use templates/null in my workflow

@bryphe-coder
Copy link
Contributor Author

Closing this because there is already templates/null/main.tf which does the same job as this PR

@bryphe-coder
Copy link
Contributor Author

From discussion in #318 (comment) - I'll bring this back and keep it in examples. As they mature, we can refine them and move them to a templates folder

@bryphe-coder bryphe-coder merged commit 4c71ff9 into main Feb 18, 2022
@bryphe-coder bryphe-coder deleted the bryphe/refactor/add-minimal-project-example branch February 18, 2022 05:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants