-
Notifications
You must be signed in to change notification settings - Fork 12
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
Revamp Terraform template #13
Conversation
I know that this might fit the name of "terraform-basic", but there's no other "terraform-advanced" to need such differentiation. If/when such a template comes to exist, this can and SHOULD be named more specifically. However, in this context, it doesn't need to be "terraform-basic" and can instead be the shorter and more succinct "terraform".
This removes a LOT of the options that were there before. I have bumped the version to 2.0.0 since this is a breaking change. I don't know this is a good idea? Maybe it is? Ideally I think (OPINION) that the devcontainer templates should be as lean as possible in terms of config maybe with json comments on how to customize it.
NEED GitHub Pages site! Don't publish these changes unless a replacement is made!
This expands on the test-utils.sh file and brings in more content from https://github.com/devcontainers/templates/blob/main/test/test-utils/test-utils.sh
@danielbraun89 Waiting on your opinions before merging this. |
What is the main benefit you see from removing the options though? Is it to save clicks in the template creation phase? Do they require another click even if they have defaults? Thing is, the target user I have envisioned for this template was not a beginner but rather an experienced terraform user, for which it will save the time and hussle to search for all terraform features he expects, and serves as a one stop shop for the ecosystem of terraform development. This is a kind of user who might appreciate the ability to pinpoint versions of terraform tools, tools versioning is conservative and important in the gitops fields (mostly only upgrade a version if they have to) |
/re @danielbraun89
This is correct. Each option will prompt you, even if it has a default. This is good when it's a very high-level important option like "Which Python package manager do you want to use? Poetry, pip, or pdm?" but doesn't work so well when it's a supplementary option. In this particular instance: when I'm creating a project that uses Terraform, I don't need to choose a place to store Terraform logs. BUT in the devcontainer.json that gets generated, you could have a commented out section (kinda like the VS Code authored templates to now) which says something like: // 💡 Un-comment this if you want to store the Terraform logs to a file.
// "remoteEnv": {
// "TF_LOG": "...",
// "TF_LOG_PATH": "..."
// } Here's the thing I'm using as a reference from the VS Code devcontainer template for Python: // For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/python
{
"name": "Python 3",
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
"image": "mcr.microsoft.com/devcontainers/python:0-${templateOption:imageVariant}"
// Features to add to the dev container. More info: https://containers.dev/features.
// "features": {},
// Use 'forwardPorts' to make a list of ports inside the container available locally.
// "forwardPorts": [],
// Use 'postCreateCommand' to run commands after the container is created.
// "postCreateCommand": "pip3 install --user -r requirements.txt",
// Configure tool-specific properties.
// "customizations": {},
// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "root"
}
That's OK! Maybe a Thoughts? Comments? Ideas? |
Given that this organization seems to be just "danielbraun98's devcontainers stash" instead of a Community Devcontainers organization, I think that you're right, you are justified to keep the Terraform template as-is. This fits with to the discussion in https://github.com/devcontainers-contrib/features/issues/316 where it seemed to be indicated that this was "as though" it were danielbraun98/devcontainer-features. I assume that this is also designed as a for-you-by-you template to fit your particular use case. |
The Terraform template is now:
All of these things below are OPINIONS of @jcbhmr, not FACTS and don't necessarily represent all of @devcontainers-contrib
Why we should encourage changing the base image instead of piling on features
1. Build times
When you first build a devcontainer image (when you click "New codespace on main" in GitHub) if you have a base image, all it needs to do is copy files. When you have a feature, it needs to run shell commands to compile, install, download, move, etc. This is GOOD for things that are ADDONS, but not for CORE THINGS like Node.js that already have an image.
For instance:
vs
The python image one is way faster. It doesn't need to rebuild Python from source.
2. It makes more semantic sense
It seems like Terraform should be an addon. You have this Python or JS project, and you want to deploy it with infra. So what do you do: a) configure it yourself or b) add a terraform config and install terraform. That's an addon right there! It's a critical project addon, but an addon nonetheless.
Why we should use a GitHub Pages site for docs generation
See #10
Why I think it's a good idea to keep options to a minimum in the devcontainer-template.json
This section is very rant-like
Not knowing what the heck an option does isn't good UX
Even the official C++ template kinda has this issue. IDL what the CMake option even does!
Ideally you should be able to get started in a few clicks and be done. Even having the features popup every time is a bit daunting. I just want to create something from a one-click template lol!
At the very least, we need some defaults. The Terraform version prompt when you just hit enter (cause you don't know what it means) just cancels the whole thing. There's no like pattern, suggestions, etc. at all.
I think it's best if we just axe this for now and re-add it if we later deem it a good idea. So far, I have never really wanted to change the defaults. I just want to:
That's it. No "choose which version of CMake" well DUH I want the latest one, this is a new project! Sure, I might want to edit the file later and customize it, but I just want a one-click thing for now.
What's the deal with the
// 💡 Replace this image with your preferred base project image!
thing?Ideally, a user would use a Node project and then choose the Terraform feature in the features prompt
But most users don't do that. So we have a template for them! We default to the UNIVERSAL image to cover most cases, but encourage users to change it.
This is basically just me re-iterating what I said in "Why we should encourage changing the base image instead of piling on features"