From a07bb97b52585111045a14039dcf00fb7e0892a0 Mon Sep 17 00:00:00 2001 From: RoseSecurity Date: Sat, 3 Aug 2024 20:27:57 -0500 Subject: [PATCH 01/20] Initial Devcontainers Testing --- .devcontainer/Dockerfile | 30 ++++++++++++ .devcontainer/devcontainer.json | 39 +++++++++++++++ .devcontainer/post_create.sh | 7 +++ .../rootfs/home/vscode/.config/starship.toml | 48 +++++++++++++++++++ .devcontainer/rootfs/home/vscode/.zshrc | 15 ++++++ Dockerfile | 5 +- README.md | 5 ++ docs/Getting_Started.md | 16 +++++++ 8 files changed, 164 insertions(+), 1 deletion(-) create mode 100644 .devcontainer/Dockerfile create mode 100644 .devcontainer/devcontainer.json create mode 100644 .devcontainer/post_create.sh create mode 100644 .devcontainer/rootfs/home/vscode/.config/starship.toml create mode 100644 .devcontainer/rootfs/home/vscode/.zshrc create mode 100644 docs/Getting_Started.md diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 0000000..ae92cf2 --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,30 @@ +FROM golang:alpine + +ARG TERRAFORM_VERSION=1.9.2 + +# Install necessary dependencies +RUN apk update && apk add --no-cache \ + bash \ + curl \ + git \ + unzip + +# Install Terraform +RUN curl -fsSL https://releases.hashicorp.com/terraform/${TERRAFORM_VERSION}/terraform_${TERRAFORM_VERSION}_linux_amd64.zip -o terraform.zip && \ + unzip terraform.zip && \ + mv terraform /usr/local/bin/ && \ + rm terraform.zip + +# Install the starship prompt +RUN curl -sS https://starship.rs/install.sh | sh -s -- -y + +# Install the rootfs/ configurations +COPY rootfs/ / + +# Copy the source code and build +COPY . . +RUN go mod download && go mod verify +RUN go build -v -o /usr/local/bin/terramaid main.go + +# Set the entrypoint and default command +ENTRYPOINT ["test"] diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000..3c3fef6 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,39 @@ +{ + "name": "Terramaid Demo", + "security.workspace.trust.emptyWindow": true, + "security.workspace.trust.untrustedFiles": "prompt", + "build": { + "dockerfile": "Dockerfile", + "context": "." + }, + "hostRequirements": { + "cpus": 8, + "memory": "16gb", + "storage": "32gb" + }, + "workspaceFolder": "test", + "postCreateCommand": "/workspace/.devcontainer/post_create.sh", + "customizations": { + "vscode": { + "extensions": [ + "bierner.github-markdown-preview", + "tomasdahlqvist.markdown-admonitions", + "HashiCorp.terraform", + "EditorConfig.EditorConfig" + ], + "settings": { + "git.openRepositoryInParentFolders": "always", + "git.autofetch": true, + "git.showProgress": true, + "workbench.editorAssociations": { + "*.md": "vscode.markdown.preview.editor" + }, + "terminal.integrated.tabs.title": "Terramaid (${process})", + "terminal.integrated.tabs.description": "${task}${separator}${local}${separator}${cwdFolder}", + "terminal.integrated.shell.linux": "/bin/zsh", + "terminal.integrated.allowWorkspaceConfiguration": true, + "terminal.integrated.commandsToSkipShell": [] + } + } + } +} diff --git a/.devcontainer/post_create.sh b/.devcontainer/post_create.sh new file mode 100644 index 0000000..6d76041 --- /dev/null +++ b/.devcontainer/post_create.sh @@ -0,0 +1,7 @@ +#!/usr/bin/env bash + +set +x + +# Set up documentation for learning +mv /workspace/docs/Getting_Started.md /workspace/test/README.md + diff --git a/.devcontainer/rootfs/home/vscode/.config/starship.toml b/.devcontainer/rootfs/home/vscode/.config/starship.toml new file mode 100644 index 0000000..00de8ee --- /dev/null +++ b/.devcontainer/rootfs/home/vscode/.config/starship.toml @@ -0,0 +1,48 @@ +format = """ +$username\ +$hostname\ +$directory\ +$git_branch\ +$git_state\ +$git_status\ +$cmd_duration\ +$line_break\ +$python\ +$character""" + +command_timeout = 2000 + +[directory] +style = "blue" + +[character] +success_symbol = "[❯](purple)" +error_symbol = "[❯](red)" +vimcmd_symbol = "[❮](green)" + +[git_branch] +format = "[$branch]($style)" +style = "bright-black" + +[git_status] +format = "[[(*$conflicted$untracked$modified$staged$renamed$deleted)](218) ($ahead_behind$stashed)]($style)" +style = "cyan" +conflicted = "​" +untracked = "​" +modified = "​" +staged = "​" +renamed = "​" +deleted = "​" +stashed = "≡" + +[git_state] +format = '\([$state( $progress_current/$progress_total)]($style)\) ' +style = "bright-black" + +[cmd_duration] +format = "[$duration]($style) " +style = "yellow" + +[python] +format = "[$virtualenv]($style) " +style = "bright-black" diff --git a/.devcontainer/rootfs/home/vscode/.zshrc b/.devcontainer/rootfs/home/vscode/.zshrc new file mode 100644 index 0000000..bffd944 --- /dev/null +++ b/.devcontainer/rootfs/home/vscode/.zshrc @@ -0,0 +1,15 @@ +# ZSH Auto Suggestions +export ZSH_AUTOSUGGEST_STRATEGY=(history completion) +source /usr/share/zsh-autosuggestions/zsh-autosuggestions.zsh + +autoload -Uz compinit +compinit + +# Enable Starship prompt +eval "$(starship init zsh)" + +# Install terramaid completion +eval $(terramaid completion zsh) + +# Show Terramaid version +terramaid version diff --git a/Dockerfile b/Dockerfile index d3c4dc1..ab413a4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,8 @@ FROM golang:alpine +# Terraform version +ARG TERRAFORM_VERSION=1.9.2 + # Install necessary dependencies RUN apk update && apk add --no-cache \ bash \ @@ -8,7 +11,7 @@ RUN apk update && apk add --no-cache \ unzip # Install Terraform -RUN curl -fsSL https://releases.hashicorp.com/terraform/1.9.2/terraform_1.9.2_linux_amd64.zip -o terraform.zip && \ +RUN curl -fsSL https://releases.hashicorp.com/terraform/${TERRAFORM_VERSION}/terraform_${TERRAFORM_VERSION}_linux_amd64.zip -o terraform.zip && \ unzip terraform.zip && \ mv terraform /usr/local/bin/ && \ rm terraform.zip diff --git a/README.md b/README.md index 849a957..060ba5b 100644 --- a/README.md +++ b/README.md @@ -36,6 +36,11 @@ flowchart TD end ``` +> [!TIP] +> ### You can try out `terramaid` directly in your browser using GitHub Codespaces +> +> [![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://github.com/codespaces/new?hide_repo_select=true&ref=main&repo=rosesecurity/terramaid&skip_quickstart=true) + ## Installation Homebrew installation: diff --git a/docs/Getting_Started.md b/docs/Getting_Started.md new file mode 100644 index 0000000..b2dba2e --- /dev/null +++ b/docs/Getting_Started.md @@ -0,0 +1,16 @@ +# Getting Started + +This is a guide to help you get started with Terramaid! In this directory, you will find a few Terraform files that can be visualized using Terramaid. To kick the tires, try running the following commands: + +```sh +terramaid -h +``` + +```sh +terramaid --subgraph-name Demo --direction LR --output Terramaid_Demo.md +``` + +```sh +cat Terramaid_Demo.md +``` + From d530b72e360a7e3aad462a3f14d7cee66c0547ac Mon Sep 17 00:00:00 2001 From: RoseSecurity Date: Sat, 3 Aug 2024 20:42:51 -0500 Subject: [PATCH 02/20] Devcontainers Testing --- .devcontainer/Dockerfile | 24 ++++++++----------- .../rootfs/home/vscode/.config/starship.toml | 1 + 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index ae92cf2..30b4516 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -1,13 +1,16 @@ -FROM golang:alpine +FROM golang:1.22 ARG TERRAFORM_VERSION=1.9.2 -# Install necessary dependencies -RUN apk update && apk add --no-cache \ - bash \ - curl \ - git \ - unzip +# Install Terramaid +go install github.com/RoseSecurity/terramaid@latest + +# Install required packages +RUN apt-get update && \ + apt-get install -y zsh-autosuggestions zsh + +# Change shell to zsh +RUN chsh -s /bin/zsh # Install Terraform RUN curl -fsSL https://releases.hashicorp.com/terraform/${TERRAFORM_VERSION}/terraform_${TERRAFORM_VERSION}_linux_amd64.zip -o terraform.zip && \ @@ -21,10 +24,3 @@ RUN curl -sS https://starship.rs/install.sh | sh -s -- -y # Install the rootfs/ configurations COPY rootfs/ / -# Copy the source code and build -COPY . . -RUN go mod download && go mod verify -RUN go build -v -o /usr/local/bin/terramaid main.go - -# Set the entrypoint and default command -ENTRYPOINT ["test"] diff --git a/.devcontainer/rootfs/home/vscode/.config/starship.toml b/.devcontainer/rootfs/home/vscode/.config/starship.toml index 00de8ee..f5f3bfd 100644 --- a/.devcontainer/rootfs/home/vscode/.config/starship.toml +++ b/.devcontainer/rootfs/home/vscode/.config/starship.toml @@ -46,3 +46,4 @@ style = "yellow" [python] format = "[$virtualenv]($style) " style = "bright-black" + From 9ae7ec4a51b375888455e505d428ac0af50d2767 Mon Sep 17 00:00:00 2001 From: RoseSecurity Date: Sat, 3 Aug 2024 20:55:31 -0500 Subject: [PATCH 03/20] Devcontainers Testing --- .devcontainer/Dockerfile | 6 +++--- .devcontainer/devcontainer.json | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 30b4516..e428f38 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -1,4 +1,4 @@ -FROM golang:1.22 +FROM golang:1.22 AS terramaid ARG TERRAFORM_VERSION=1.9.2 @@ -7,10 +7,10 @@ go install github.com/RoseSecurity/terramaid@latest # Install required packages RUN apt-get update && \ - apt-get install -y zsh-autosuggestions zsh + apt-get install -y zsh-autosuggestions # Change shell to zsh -RUN chsh -s /bin/zsh +RUN chsh -s /bin/zsh vscode # Install Terraform RUN curl -fsSL https://releases.hashicorp.com/terraform/${TERRAFORM_VERSION}/terraform_${TERRAFORM_VERSION}_linux_amd64.zip -o terraform.zip && \ diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 3c3fef6..891ec1a 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -11,8 +11,8 @@ "memory": "16gb", "storage": "32gb" }, - "workspaceFolder": "test", - "postCreateCommand": "/workspace/.devcontainer/post_create.sh", + "workspaceFolder": "Terramaid", + "postCreateCommand": "/workspaces/Terramaid/.devcontainer/post_create.sh", "customizations": { "vscode": { "extensions": [ From c65e0c2975fd32eb49d01d116af2e976db6e2a42 Mon Sep 17 00:00:00 2001 From: RoseSecurity Date: Sat, 3 Aug 2024 21:07:04 -0500 Subject: [PATCH 04/20] Devcontainers Testing --- .devcontainer/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index e428f38..2995e2e 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -3,7 +3,7 @@ FROM golang:1.22 AS terramaid ARG TERRAFORM_VERSION=1.9.2 # Install Terramaid -go install github.com/RoseSecurity/terramaid@latest +RUN go install github.com/RoseSecurity/terramaid@latest # Install required packages RUN apt-get update && \ From dcfbf16473251697d4dc8043568c23052d26950d Mon Sep 17 00:00:00 2001 From: RoseSecurity Date: Sat, 3 Aug 2024 21:29:38 -0500 Subject: [PATCH 05/20] Devcontainers Testing --- .devcontainer/Dockerfile | 4 +- .devcontainer/devcontainer.json | 87 ++++++++++++++++++++------------- .devcontainer/post_create.sh | 2 +- 3 files changed, 56 insertions(+), 37 deletions(-) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 2995e2e..0591bd7 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -5,9 +5,11 @@ ARG TERRAFORM_VERSION=1.9.2 # Install Terramaid RUN go install github.com/RoseSecurity/terramaid@latest +FROM mcr.microsoft.com/vscode/devcontainers/base:debian + # Install required packages RUN apt-get update && \ - apt-get install -y zsh-autosuggestions + apt-get install -y apt-utils ca-certificates curl unzip zsh-autosuggestions # Change shell to zsh RUN chsh -s /bin/zsh vscode diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 891ec1a..afbd517 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,39 +1,56 @@ { - "name": "Terramaid Demo", - "security.workspace.trust.emptyWindow": true, - "security.workspace.trust.untrustedFiles": "prompt", - "build": { - "dockerfile": "Dockerfile", - "context": "." - }, - "hostRequirements": { - "cpus": 8, - "memory": "16gb", - "storage": "32gb" - }, - "workspaceFolder": "Terramaid", - "postCreateCommand": "/workspaces/Terramaid/.devcontainer/post_create.sh", - "customizations": { - "vscode": { - "extensions": [ - "bierner.github-markdown-preview", - "tomasdahlqvist.markdown-admonitions", - "HashiCorp.terraform", - "EditorConfig.EditorConfig" - ], - "settings": { - "git.openRepositoryInParentFolders": "always", - "git.autofetch": true, - "git.showProgress": true, - "workbench.editorAssociations": { - "*.md": "vscode.markdown.preview.editor" - }, - "terminal.integrated.tabs.title": "Terramaid (${process})", - "terminal.integrated.tabs.description": "${task}${separator}${local}${separator}${cwdFolder}", - "terminal.integrated.shell.linux": "/bin/zsh", - "terminal.integrated.allowWorkspaceConfiguration": true, - "terminal.integrated.commandsToSkipShell": [] + "name": "Terramaid Demo", + "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": 8, + "memory": "16gb", + "storage": "32gb" + }, + "postCreateCommand": "/workspace/.devcontainer/post_create.sh", + "features": { + /*"ghcr.io/devcontainers/features/go:1": { + "version": "1.22" + },*/ + }, + "workspaceFolder": "/workspace/test", + "workspaceMount": "source=${localWorkspaceFolder},target=/workspace,type=bind", + + "customizations": { + "vscode": { + "extensions": [ + "bierner.github-markdown-preview", + "tomasdahlqvist.markdown-admonitions", + "HashiCorp.terraform", + "EditorConfig.EditorConfig" + ], + "settings": { + "git.openRepositoryInParentFolders": "always", + "git.autofetch": true, + "git.showProgress": true, + "workbench.startupEditor": "readme", + "workbench.editor.autoLockGroups": { + "readme": "/Getting_Started.md" + }, + "workbench.editorAssociations": { + "*.md": "vscode.markdown.preview.editor" + }, + "terminal.integrated.tabs.title": "Terramaid (${process})", + "terminal.integrated.tabs.description": "${task}${separator}${local}${separator}${cwdFolder}", + "terminal.integrated.shell.linux": "/bin/zsh", + "terminal.integrated.allowWorkspaceConfiguration": true, + "terminal.integrated.commandsToSkipShell": [], + } + } } } } -} diff --git a/.devcontainer/post_create.sh b/.devcontainer/post_create.sh index 6d76041..fea0c46 100644 --- a/.devcontainer/post_create.sh +++ b/.devcontainer/post_create.sh @@ -1,4 +1,4 @@ -#!/usr/bin/env bash +#!/usr/bin/env zsh set +x From 2f1e9a2b14e111bdb60e592fb4efc3ff2489174b Mon Sep 17 00:00:00 2001 From: RoseSecurity Date: Sat, 3 Aug 2024 21:33:27 -0500 Subject: [PATCH 06/20] Devcontainers Testing --- .devcontainer/devcontainer.json | 103 ++++++++++++++++---------------- 1 file changed, 51 insertions(+), 52 deletions(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index afbd517..0b950eb 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,56 +1,55 @@ { - "name": "Terramaid Demo", - "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": 8, - "memory": "16gb", - "storage": "32gb" - }, - "postCreateCommand": "/workspace/.devcontainer/post_create.sh", - "features": { - /*"ghcr.io/devcontainers/features/go:1": { - "version": "1.22" - },*/ - }, - "workspaceFolder": "/workspace/test", - "workspaceMount": "source=${localWorkspaceFolder},target=/workspace,type=bind", - - "customizations": { - "vscode": { - "extensions": [ - "bierner.github-markdown-preview", - "tomasdahlqvist.markdown-admonitions", - "HashiCorp.terraform", - "EditorConfig.EditorConfig" - ], - "settings": { - "git.openRepositoryInParentFolders": "always", - "git.autofetch": true, - "git.showProgress": true, - "workbench.startupEditor": "readme", - "workbench.editor.autoLockGroups": { - "readme": "/Getting_Started.md" - }, - "workbench.editorAssociations": { - "*.md": "vscode.markdown.preview.editor" - }, - "terminal.integrated.tabs.title": "Terramaid (${process})", - "terminal.integrated.tabs.description": "${task}${separator}${local}${separator}${cwdFolder}", - "terminal.integrated.shell.linux": "/bin/zsh", - "terminal.integrated.allowWorkspaceConfiguration": true, - "terminal.integrated.commandsToSkipShell": [], - } - } + "name": "Terramaid Demo", + "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": 8, + "memory": "16gb", + "storage": "32gb" + }, + "postCreateCommand": "/workspace/.devcontainer/post_create.sh", + "features": { + /*"ghcr.io/devcontainers/features/go:1": { + "version": "1.22" + }*/ + }, + "workspaceFolder": "/workspace/test", + "workspaceMount": "source=${localWorkspaceFolder},target=/workspace,type=bind", + "customizations": { + "vscode": { + "extensions": [ + "bierner.github-markdown-preview", + "tomasdahlqvist.markdown-admonitions", + "HashiCorp.terraform", + "EditorConfig.EditorConfig" + ], + "settings": { + "git.openRepositoryInParentFolders": "always", + "git.autofetch": true, + "git.showProgress": true, + "workbench.startupEditor": "readme", + "workbench.editor.autoLockGroups": { + "readme": "/Getting_Started.md" + }, + "workbench.editorAssociations": { + "*.md": "vscode.markdown.preview.editor" + }, + "terminal.integrated.tabs.title": "Terramaid (${process})", + "terminal.integrated.tabs.description": "${task}${separator}${local}${separator}${cwdFolder}", + "terminal.integrated.shell.linux": "/bin/zsh", + "terminal.integrated.allowWorkspaceConfiguration": true, + "terminal.integrated.commandsToSkipShell": [] } } } +} + From 21365cf54f38e289ae8e3476ddcdb947403a597d Mon Sep 17 00:00:00 2001 From: RoseSecurity Date: Sat, 3 Aug 2024 21:55:55 -0500 Subject: [PATCH 07/20] Devcontainers Fix --- .devcontainer/Dockerfile | 1 + .devcontainer/devcontainer.json | 15 ++------------- 2 files changed, 3 insertions(+), 13 deletions(-) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 0591bd7..769f5b7 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -26,3 +26,4 @@ RUN curl -sS https://starship.rs/install.sh | sh -s -- -y # Install the rootfs/ configurations COPY rootfs/ / + diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 0b950eb..7807985 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -1,12 +1,5 @@ { "name": "Terramaid Demo", - "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": "." @@ -16,13 +9,10 @@ "memory": "16gb", "storage": "32gb" }, - "postCreateCommand": "/workspace/.devcontainer/post_create.sh", + "postCreateCommand": "/workspace/Terramaid/.devcontainer/post_create.sh", "features": { - /*"ghcr.io/devcontainers/features/go:1": { - "version": "1.22" - }*/ }, - "workspaceFolder": "/workspace/test", + "workspaceFolder": "/workspace/Terramaid/test", "workspaceMount": "source=${localWorkspaceFolder},target=/workspace,type=bind", "customizations": { "vscode": { @@ -52,4 +42,3 @@ } } } - From 6a5f6d8f547b298f72a7866300dde6a51c692a9d Mon Sep 17 00:00:00 2001 From: RoseSecurity Date: Sat, 3 Aug 2024 22:07:44 -0500 Subject: [PATCH 08/20] Devcontainers Fix --- .devcontainer/Dockerfile | 4 +++- .devcontainer/devcontainer.json | 3 --- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 769f5b7..bc460b8 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -23,7 +23,9 @@ RUN curl -fsSL https://releases.hashicorp.com/terraform/${TERRAFORM_VERSION}/ter # Install the starship prompt RUN curl -sS https://starship.rs/install.sh | sh -s -- -y +# Copy Terramaid binary from the build stage +COPY --from=build /go/bin/terramaid /usr/local/bin/terramaid + # Install the rootfs/ configurations COPY rootfs/ / - diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 7807985..2abe093 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -27,9 +27,6 @@ "git.autofetch": true, "git.showProgress": true, "workbench.startupEditor": "readme", - "workbench.editor.autoLockGroups": { - "readme": "/Getting_Started.md" - }, "workbench.editorAssociations": { "*.md": "vscode.markdown.preview.editor" }, From 0a7a29fc596928e329524e24faed2724a1599cbf Mon Sep 17 00:00:00 2001 From: RoseSecurity Date: Sat, 3 Aug 2024 22:10:37 -0500 Subject: [PATCH 09/20] Devcontainers Fix --- .devcontainer/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index bc460b8..2940339 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -1,4 +1,4 @@ -FROM golang:1.22 AS terramaid +FROM golang:1.22 AS build ARG TERRAFORM_VERSION=1.9.2 From 685a9f1625f22f17257f307b4ec6554e264f61c4 Mon Sep 17 00:00:00 2001 From: RoseSecurity Date: Sat, 3 Aug 2024 22:14:03 -0500 Subject: [PATCH 10/20] Devcontainers Fix: Terraform --- .devcontainer/Dockerfile | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile index 2940339..4b4d105 100644 --- a/.devcontainer/Dockerfile +++ b/.devcontainer/Dockerfile @@ -1,7 +1,5 @@ FROM golang:1.22 AS build -ARG TERRAFORM_VERSION=1.9.2 - # Install Terramaid RUN go install github.com/RoseSecurity/terramaid@latest @@ -15,6 +13,7 @@ RUN apt-get update && \ RUN chsh -s /bin/zsh vscode # Install Terraform +ARG TERRAFORM_VERSION=1.9.2 RUN curl -fsSL https://releases.hashicorp.com/terraform/${TERRAFORM_VERSION}/terraform_${TERRAFORM_VERSION}_linux_amd64.zip -o terraform.zip && \ unzip terraform.zip && \ mv terraform /usr/local/bin/ && \ From 839d0bb6f0a60a056a182a723633a8e19318f127 Mon Sep 17 00:00:00 2001 From: RoseSecurity Date: Sat, 3 Aug 2024 22:19:24 -0500 Subject: [PATCH 11/20] Devcontainers Fix --- .devcontainer/devcontainer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 2abe093..8c36274 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -12,7 +12,7 @@ "postCreateCommand": "/workspace/Terramaid/.devcontainer/post_create.sh", "features": { }, - "workspaceFolder": "/workspace/Terramaid/test", + "workspaceFolder": "/workspace", "workspaceMount": "source=${localWorkspaceFolder},target=/workspace,type=bind", "customizations": { "vscode": { From 43b7720220a59f8c3427112983f26aa2d2501d19 Mon Sep 17 00:00:00 2001 From: RoseSecurity Date: Sun, 4 Aug 2024 00:04:15 -0500 Subject: [PATCH 12/20] Devcontainers Fix --- .devcontainer/devcontainer.json | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 8c36274..9b482c0 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -12,9 +12,14 @@ "postCreateCommand": "/workspace/Terramaid/.devcontainer/post_create.sh", "features": { }, - "workspaceFolder": "/workspace", + "workspaceFolder": "/workspace/Terramaid", "workspaceMount": "source=${localWorkspaceFolder},target=/workspace,type=bind", "customizations": { + "codespaces": { + "openFiles": [ + "/workspace/Terramaid/docs/Getting_Started.md" + ] + }, "vscode": { "extensions": [ "bierner.github-markdown-preview", From cbde1338d88fb76df54c447950b13ac1ccc90bde Mon Sep 17 00:00:00 2001 From: RoseSecurity Date: Sun, 4 Aug 2024 00:08:06 -0500 Subject: [PATCH 13/20] Devcontainers Fix --- .devcontainer/devcontainer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 9b482c0..bade349 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -12,7 +12,7 @@ "postCreateCommand": "/workspace/Terramaid/.devcontainer/post_create.sh", "features": { }, - "workspaceFolder": "/workspace/Terramaid", + "workspaceFolder": "/workspace", "workspaceMount": "source=${localWorkspaceFolder},target=/workspace,type=bind", "customizations": { "codespaces": { From 31a9136d25dabd6da86d953ce8a3b5df2d7a5014 Mon Sep 17 00:00:00 2001 From: RoseSecurity Date: Sun, 4 Aug 2024 00:10:06 -0500 Subject: [PATCH 14/20] Devcontainers Fix --- .devcontainer/devcontainer.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index bade349..12d1b2a 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -9,7 +9,7 @@ "memory": "16gb", "storage": "32gb" }, - "postCreateCommand": "/workspace/Terramaid/.devcontainer/post_create.sh", + "postCreateCommand": "/workspace/.devcontainer/post_create.sh", "features": { }, "workspaceFolder": "/workspace", @@ -17,7 +17,7 @@ "customizations": { "codespaces": { "openFiles": [ - "/workspace/Terramaid/docs/Getting_Started.md" + "/workspace/docs/Getting_Started.md" ] }, "vscode": { From 031f6b48cbe8448ad1bf6e26563e790567ba5661 Mon Sep 17 00:00:00 2001 From: RoseSecurity Date: Sun, 4 Aug 2024 00:20:03 -0500 Subject: [PATCH 15/20] Devcontainers Fix docs --- .devcontainer/devcontainer.json | 2 +- docs/Getting_Started.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index 12d1b2a..a95871a 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -17,7 +17,7 @@ "customizations": { "codespaces": { "openFiles": [ - "/workspace/docs/Getting_Started.md" + "docs/Getting_Started.md" ] }, "vscode": { diff --git a/docs/Getting_Started.md b/docs/Getting_Started.md index b2dba2e..2db340b 100644 --- a/docs/Getting_Started.md +++ b/docs/Getting_Started.md @@ -3,7 +3,7 @@ This is a guide to help you get started with Terramaid! In this directory, you will find a few Terraform files that can be visualized using Terramaid. To kick the tires, try running the following commands: ```sh -terramaid -h +cd test && terramaid -h ``` ```sh From aa767fe64ab2c5f19431c1db6e934ec3f21a2bdf Mon Sep 17 00:00:00 2001 From: RoseSecurity Date: Sun, 4 Aug 2024 00:25:42 -0500 Subject: [PATCH 16/20] remove post_create --- .devcontainer/devcontainer.json | 1 - .devcontainer/post_create.sh | 7 ------- 2 files changed, 8 deletions(-) delete mode 100644 .devcontainer/post_create.sh diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index a95871a..1224d97 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -9,7 +9,6 @@ "memory": "16gb", "storage": "32gb" }, - "postCreateCommand": "/workspace/.devcontainer/post_create.sh", "features": { }, "workspaceFolder": "/workspace", diff --git a/.devcontainer/post_create.sh b/.devcontainer/post_create.sh deleted file mode 100644 index fea0c46..0000000 --- a/.devcontainer/post_create.sh +++ /dev/null @@ -1,7 +0,0 @@ -#!/usr/bin/env zsh - -set +x - -# Set up documentation for learning -mv /workspace/docs/Getting_Started.md /workspace/test/README.md - From 1ecfd9c203231c5e8c7c45858452852ae68fcbe3 Mon Sep 17 00:00:00 2001 From: RoseSecurity Date: Sun, 4 Aug 2024 00:38:29 -0500 Subject: [PATCH 17/20] update tests --- test/outputs.tf | 16 ++++++++++++++++ test/providers.tf | 4 ++++ 2 files changed, 20 insertions(+) create mode 100644 test/outputs.tf create mode 100644 test/providers.tf diff --git a/test/outputs.tf b/test/outputs.tf new file mode 100644 index 0000000..324f075 --- /dev/null +++ b/test/outputs.tf @@ -0,0 +1,16 @@ +output "logs_bucket_id" { + value = aws_s3_bucket.logs.id +} + +output "test_bucket_id" { + value = aws_s3_bucket.test.id +} + +output "instance_id" { + value = aws_instance.example_instance.id +} + +output "db_instance_id" { + value = aws_db_instance.example_db.id +} + diff --git a/test/providers.tf b/test/providers.tf new file mode 100644 index 0000000..3e35058 --- /dev/null +++ b/test/providers.tf @@ -0,0 +1,4 @@ +provider "aws" { + region = "us-west-2" +} + From 3f299ddb4713d089ec35f8d96de9db17cc4cad1f Mon Sep 17 00:00:00 2001 From: RoseSecurity Date: Sun, 4 Aug 2024 00:53:00 -0500 Subject: [PATCH 18/20] fix version command --- cmd/root.go | 2 +- cmd/version.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cmd/root.go b/cmd/root.go index 8ca8bfc..49731f1 100644 --- a/cmd/root.go +++ b/cmd/root.go @@ -104,7 +104,7 @@ func TerramaidCmd() *cobra.Command { cmd.Flags().StringVarP(&options.TFBinary, "tf-binary", "b", options.TFBinary, "Path to Terraform binary (env: TERRAMAID_TF_BINARY)") cmd.Flags().StringVarP(&options.WorkingDir, "working-dir", "w", options.WorkingDir, "Working directory for Terraform (env: TERRAMAID_WORKING_DIR)") - cmd.AddCommand(docsCmd(), versionCmd()) + cmd.AddCommand(docsCmd(), versionCmd(Version)) return cmd } diff --git a/cmd/version.go b/cmd/version.go index 2dcf71e..e0a836b 100644 --- a/cmd/version.go +++ b/cmd/version.go @@ -15,7 +15,7 @@ type Release struct { TagName string `json:"tag_name"` } -func versionCmd() *cobra.Command { +func versionCmd(Version string) *cobra.Command { cmd := &cobra.Command{ Use: "version", Short: "Print the CLI version", From fcefe867c651f9fecbc2224e6bf34b0a92916b18 Mon Sep 17 00:00:00 2001 From: RoseSecurity Date: Sun, 4 Aug 2024 00:54:25 -0500 Subject: [PATCH 19/20] update readme --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 060ba5b..93d1d85 100644 --- a/README.md +++ b/README.md @@ -40,6 +40,7 @@ flowchart TD > ### You can try out `terramaid` directly in your browser using GitHub Codespaces > > [![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://github.com/codespaces/new?hide_repo_select=true&ref=main&repo=rosesecurity/terramaid&skip_quickstart=true) +> ## Installation From 95da9ffd20b0c199c3a277364c6982cb29106865 Mon Sep 17 00:00:00 2001 From: RoseSecurity Date: Sun, 4 Aug 2024 00:55:02 -0500 Subject: [PATCH 20/20] update readme --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 93d1d85..46f974f 100644 --- a/README.md +++ b/README.md @@ -41,6 +41,7 @@ flowchart TD > > [![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://github.com/codespaces/new?hide_repo_select=true&ref=main&repo=rosesecurity/terramaid&skip_quickstart=true) > +> ## Installation