Configure Your Editor for Atmos
A properly configured editor can make working with Atmos configurations more intuitive and efficient. The right setup can improve readability, speed up your workflow, and even help you catch configuration errors as you go! Whether you’re setting up your editor for the first time or refining your current environment, we have some recommendations to get you started.
You will learn
- How to configure your VS Code editor to boost productivity
- Ensure your YAML files are validated against the Atmos schema to catch issues early and maintain compliance with best practices
- How to format your code automatically
To work effectively with Atmos, we recommend configuring your VS Code editor for the best developer experience. Alternatively, you can use a DevContainer configuration.
- Visual Studio Code
- DevContainer
Configure Visual Studio Code
You can manually configure your VS Code environment with the following settings.
Recommended Visual Studio Code Extensions
Install these extensions for enhanced productivity:
Visual Studio Code Settings
Update your VS Code settings to optimize the experience for working with Atmos. With these configurations, your VS Code editor will be fully optimized for working with Atmos.
Add the following to your settings.json
for your infrastructure repository (e.g. infra/.vscode/settings.json
)
{
"git.openRepositoryInParentFolders": "always",
"git.autofetch": true,
"git.showProgress": true,
"workbench.startupEditor": "readme",
"workbench.editor.autoLockGroups": {
"readme": "/welcome.md"
},
"workbench.editorAssociations": {
"*.md": "vscode.markdown.preview.editor"
},
"terminal.integrated.tabs.title": "Atmos (${process})",
"terminal.integrated.tabs.description": "${task}${separator}${local}${separator}${cwdFolder}",
"terminal.integrated.shell.linux": "/bin/zsh",
"terminal.integrated.allowWorkspaceConfiguration": true,
"yaml.schemaStore.enable": true,
"yaml.schemas": {
"https://atmos.tools/schemas/atmos/atmos-manifest/1.0/atmos-manifest.json": [
"**/stacks/**/*.yaml",
"!**/stacks/workflows/**/*.yaml",
"!**/stacks/schemas/**/*.yaml"
]
}
}
Terminal Configuration
Set your terminal to use Zsh for an improved command-line experience:
"terminal.integrated.shell.linux": "/bin/zsh"
YAML Schema Validation
Ensure your YAML files are validated against the Atmos schema:
"yaml.schemas": {
"https://atmos.tools/schemas/atmos/atmos-manifest/1.0/atmos-manifest.json": [
"**/stacks/**/*.yaml",
"!**/stacks/workflows/**/*.yaml",
"!**/stacks/schemas/**/*.yaml"
]
}
Use DevContainers with Atmos
When managing your infrastructure with Atmos, you can enhance your development experience by configuring your infrastructure repository with a dev containers. This ensures a consistent, isolated development environment tailored for working with Atmos and Terraform, integrated natively with your IDE.
Why Use a DevContainers?
- Consistent Environment: Ensures every developer uses the same tools and configurations.
- Pre-installed Tools: Includes Atmos, Terraform, and any additional utilities.
- Simplified Setup: Developers don’t need to manually install dependencies.
By adding this configuration to your infrastructure repository, you'll streamline collaboration and maintain consistency across your team.
Setting Up a DevContainer for Your Infrastructure Repository
Follow these steps to configure a DevContainer in your repository:
1. Create a .devcontainer
Directory
In the root of your infrastructure repository, create a .devcontainer
directory to store the configuration files:
mkdir .devcontainer
2. Add a devcontainer.json
File
Inside the .devcontainer
directory, create a devcontainer.json
file with the following content:
{
"name": "Atmos DevContainer",
"forwardPorts": [80, 443],
"portsAttributes": {
"80": { "label": "Ingress" },
"443": { "label": "Ingress (TLS)" }
},
"security.workspace.trust.emptyWindow": true,
"security.workspace.trust.untrustedFiles": "prompt",
"security.workspace.trust.domain": {
"*.github.com": true,
"*.app.github.dev": true,
"localhost": true
},
"build": {
"dockerfile": "Dockerfile",
"context": "."
},
"hostRequirements": {
"cpus": 4,
"memory": "8gb",
"storage": "16gb"
},
"runArgs": ["-v", "/var/run/docker.sock:/var/run/docker.sock"],
"postCreateCommand": "/workspace/.devcontainer/post-create.sh",
"features": {
"ghcr.io/devcontainers/features/docker-outside-of-docker": {}
},
"workspaceFolder": "/workspace",
"workspaceMount": "source=${localWorkspaceFolder},target=/workspace,type=bind",
"customizations": {
"vscode": {
"extensions": [
"ms-azuretools.vscode-docker",
"bierner.github-markdown-preview",
"tomasdahlqvist.markdown-admonitions",
"HashiCorp.terraform",
"redhat.vscode-yaml",
"casualjim.gotemplate",
"EditorConfig.EditorConfig"
],
"settings": {
"git.openRepositoryInParentFolders": "always",
"git.autofetch": true,
"workbench.startupEditor": "readme",
"yaml.schemas": {
"https://atmos.tools/schemas/atmos/atmos-manifest/1.0/atmos-manifest.json": [
"**/stacks/**/*.yaml",
"!**/stacks/workflows/**/*.yaml",
"!**/stacks/schemas/**/*.yaml"
]
}
}
}
}
}
3. Add a Dockerfile
In the .devcontainer
directory, create a Dockerfile
to define the environment. For Atmos and Terraform, use the following:
FROM mcr.microsoft.com/devcontainers/base:ubuntu
# Install dependencies
RUN apt-get update && \
apt-get install -y curl unzip git zsh && \
curl -Lo /tmp/terraform.zip https://releases.hashicorp.com/terraform/1.5.6/terraform_1.5.6_linux_amd64.zip && \
unzip /tmp/terraform.zip -d /usr/local/bin/ && \
rm /tmp/terraform.zip && \
curl -Lo /usr/local/bin/atmos https://github.com/cloudposse/atmos/releases/latest/download/atmos-linux-amd64 && \
chmod +x /usr/local/bin/atmos
# Install Zsh and set as default shell
RUN chsh -s /bin/zsh
4. (Optional) Add a Post-Create Script
If you need to run additional setup commands after creating the container, add a post-create.sh
script:
#!/bin/bash
# Example: Install custom tools or set up environment variables
echo "Post-create script running..."
Make it executable:
chmod +x .devcontainer/post-create.sh
5. Open Your Repository in the DevContainer
- Install the Dev Containers extension in VS Code:
- Open the infrastructure repository in VS Code.
- Click on the >< icon in the bottom-left corner and a menu appears.
- Select Reopen in Container.