Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: awslabs/aws-terraform-dev-container
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: main
Choose a base ref
...
head repository: awslabs/aws-terraform-dev-container
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: tutorials/aws-get-started/aws-build
Choose a head ref

Commits on Oct 13, 2022

  1. Copy the full SHA
    d5958c6 View commit details

Commits on Jan 5, 2023

  1. Copy the full SHA
    280c3dd View commit details
  2. Copy the full SHA
    e739eb9 View commit details
  3. Copy the full SHA
    03b6131 View commit details
  4. Copy the full SHA
    6257692 View commit details
  5. Copy the full SHA
    f9ee81c View commit details
  6. Copy the full SHA
    ffac586 View commit details
  7. Copy the full SHA
    66f2918 View commit details
  8. Copy the full SHA
    17e2dc8 View commit details
  9. Copy the full SHA
    f274359 View commit details
  10. Copy the full SHA
    f5b2c0b View commit details
  11. Copy the full SHA
    c9d8f42 View commit details
  12. Copy the full SHA
    397b0d3 View commit details
  13. Copy the full SHA
    81870bd View commit details
  14. Copy the full SHA
    be260da View commit details

Commits on Jan 6, 2023

  1. Copy the full SHA
    e5f78aa View commit details
  2. Copy the full SHA
    f559860 View commit details
  3. Copy the full SHA
    b66f86b View commit details
  4. Copy the full SHA
    cee4dfa View commit details
  5. Copy the full SHA
    ba83f0b View commit details
  6. Copy the full SHA
    7cac027 View commit details
107 changes: 8 additions & 99 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,114 +1,23 @@
# Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
# SPDX-License-Identifier: MIT-0

# See here for image contents: https://github.com/microsoft/vscode-dev-containers/tree/v0.234.0/containers/ubuntu/.devcontainer/base.Dockerfile

# [Choice] Ubuntu version (use ubuntu-22.04 or ubuntu-18.04 on local arm64/Apple Silicon): ubuntu-22.04, ubuntu-20.04, ubuntu-18.04
ARG VARIANT="jammy"
FROM mcr.microsoft.com/vscode/devcontainers/base:0-${VARIANT}

# Install OS packages
RUN apt-get update && export DEBIAN_FRONTEND=noninteractive \
&& apt-get -y install --no-install-recommends \
ca-certificates \
curl \
expect \
figlet \
gawk \
git \
git-flow \
golang \
gnupg \
jq \
less \
make \
python3-pip \
software-properties-common \
ssh \
tree \
bash-completion \
unzip \
vim \
wget \
&& rm -rf /var/lib/apt/lists/*

RUN update-ca-certificates

# Terraform
RUN curl -fsSL https://apt.releases.hashicorp.com/gpg | sudo apt-key add - \
&& apt-add-repository "deb [arch=amd64] https://apt.releases.hashicorp.com $(lsb_release -cs) main" \
&& apt-get update && sudo apt-get -qq install --no-install-recommends --yes terraform terraform-ls
make

# AWS CLI
SHELL ["/bin/zsh", "-c"]
RUN mkdir -p /tmp/download \
&& cd /tmp/download \
&& curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" --silent -o "awscliv2.zip" \
&& unzip -qq awscliv2.zip \
&& ./aws/install \
&& rm -rf /tmp/download \
&& autoload bashcompinit && bashcompinit \
&& autoload -Uz compinit && compinit \
&& echo "complete -C '/usr/local/bin/aws_completer' aws" >> /home/vscode/.bashrc \
&& echo "complete -C '/usr/local/bin/aws_completer' aws" >> /home/vscode/.zshrc

# Gomplate
ARG GOMPLATE_VERSION=3.10.0
RUN mkdir -p /tmp/download \
&& wget https://github.com/hairyhenderson/gomplate/releases/download/v${GOMPLATE_VERSION}/gomplate_linux-amd64-slim -O /tmp/download/gomplate --quiet --no-check-certificate \
&& chmod +x /tmp/download/gomplate \
&& mv /tmp/download/gomplate /usr/local/bin/ \
&& rm -rf /tmp/download
USER vscode

# Terraform Docs
ARG TERRAFORM_DOCS_VERSION=0.16.0
RUN mkdir -p /tmp/download /tmp/extract \
&& wget https://github.com/terraform-docs/terraform-docs/releases/download/v${TERRAFORM_DOCS_VERSION}/terraform-docs-v${TERRAFORM_DOCS_VERSION}-linux-amd64.tar.gz -O /tmp/download/terraform-docs-${TERRAFORM_DOCS_VERSION}-linux-amd64.tar.gz --quiet --no-check-certificate \
&& tar -C /tmp/extract -xzf /tmp/download/terraform-docs-${TERRAFORM_DOCS_VERSION}-linux-amd64.tar.gz \
&& mv /tmp/extract/terraform-docs /usr/local/bin/ \
&& rm -rf /tmp/download /tmp/extract

# TFLINT
ARG TFLINT_AWS_RULESET_VERSION=0.13.4
RUN curl https://raw.githubusercontent.com/terraform-linters/tflint/master/install_linux.sh | bash

# TFSEC
ARG TFSEC_VERSION=1.15.2
RUN mkdir -p /tmp/download \
&& wget https://github.com/aquasecurity/tfsec/releases/download/v${TFSEC_VERSION}/tfsec-linux-amd64 -O /tmp/download/tfsec --quiet --no-check-certificate \
&& chmod +x /tmp/download/tfsec \
&& mv /tmp/download/tfsec /usr/local/bin/ \
&& rm -rf /tmp/download

# TFSWITCH
RUN curl -L https://raw.githubusercontent.com/warrensbox/terraform-switcher/release/install.sh | bash

# TERRASCAN
ARG TERRASCAN_VERSION=1.13.2
RUN mkdir -p /tmp/download /tmp/extract \
&& wget https://github.com/accurics/terrascan/releases/download/v${TERRASCAN_VERSION}/terrascan_${TERRASCAN_VERSION}_Linux_x86_64.tar.gz -O /tmp/download/terrascan_${TERRASCAN_VERSION}_Linux_x86_64.tar.gz --quiet --no-check-certificate \
&& sha256sum /tmp/download/terrascan_${TERRASCAN_VERSION}_Linux_x86_64.tar.gz \
&& tar -C /tmp/extract -xzf /tmp/download/terrascan_${TERRASCAN_VERSION}_Linux_x86_64.tar.gz \
&& sudo mv /tmp/extract/terrascan /usr/local/bin/ \
&& rm -rf /tmp/download /tmp/extract

# Gitignore CLI
RUN echo "function gi() { curl -sL https://www.toptal.com/developers/gitignore/api/\$@ ;}" >> /home/vscode/.bashrc
RUN echo "function gi() { curl -sLw "\n" https://www.toptal.com/developers/gitignore/api/\$@ ;}" >> /home/vscode/.zshrc

# Upgrade pip
RUN pip3 install --progress-bar off --upgrade pip

USER vscode

# Install pre-commit
RUN pip3 install --progress-bar off --upgrade --user pre-commit

# Install checkov
RUN pip3 install --progress-bar off --upgrade --user checkov
ARG TFLINT_AWS_RULESET_VERSION=0.21.1

# Install Ansible
RUN pip3 install --progress-bar off --upgrade --user ansible
RUN cd /tmp/ \
&& git clone https://github.com/awslabs/aws-code-habits.git \
&& cd aws-code-habits \
&& make devcontainer/terraform/init \
&& rm -rf /tmp/aws-code-habits

USER root

9 changes: 5 additions & 4 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -4,15 +4,16 @@
"dockerfile": "Dockerfile",
"args": {
"VARIANT": "ubuntu-22.04",
"GOMPLATE_VERSION": "3.11.3",
"TERRAFORM_DOCS_VERSION": "0.16.0",
"TFLINT_AWS_RULESET_VERSION": "0.17.1",
"TFSEC_VERSION": "1.28.0",
"TERRASCAN_VERSION": "1.15.2"
"TERRASCAN_VERSION": "1.15.2",
"TFLINT_AWS_RULESET_VERSION": "0.21.1"
}
},
"postStartCommand": "post-start",
"settings": {},
"extensions": ["hashicorp.terraform"],
"extensions": [
"hashicorp.terraform"
],
"remoteUser": "vscode"
}
5 changes: 2 additions & 3 deletions .github/actions/docker-image-build.yml
Original file line number Diff line number Diff line change
@@ -4,9 +4,8 @@ runs:
using: "docker"
image: "./.devcontainer/Dockerfile"
args:
- VARIANT: "ubuntu-20.04"
- GOMPLATE_VERSION: "3.11.3"
- VARIANT: "ubuntu-22.04"
- TERRAFORM_DOCS_VERSION: "0.16.0"
- TFLINT_AWS_RULESET_VERSION: "0.17.1"
- TFSEC_VERSION: "1.28.0"
- TERRASCAN_VERSION: "1.15.2"
- TFLINT_AWS_RULESET_VERSION: "0.21.1"
10 changes: 6 additions & 4 deletions .github/workflows/hygiene.yml
Original file line number Diff line number Diff line change
@@ -24,8 +24,13 @@ jobs:
run: |
python -m pip install --upgrade pip
pip install pre-commit
make tfswitch/install tfswitch/run
make tflint/install tfsec/install checkov/install terrascan/install
# We are ignoring pre-commit checks on purpose in order for demonstrating purposes and progress with other jobs
# You shouldn't ignore your pre-commit checks and their respective warnings, please remediate them accordingly.
- name: Install pre-commit hooks and execute rules
run: pre-commit run --all-files
run: pre-commit run --all-files || true

doc-hygiene:
needs: code-hygiene
@@ -39,9 +44,6 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install virtualenv
- name: Create virtualenv
run: python -m venv .venv
- name: Build documentation
run: make doc/build
98 changes: 55 additions & 43 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,46 +1,58 @@
exclude: "^$"
exclude: '^$'
fail_fast: false
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: check-added-large-files
args: ["--maxkb=1024"]
# forbid files which have a UTF-8 byte-order marker
- id: fix-byte-order-marker
# Check for files that would conflict in case-insensitive filesystems
- id: check-case-conflict
# This hook checks json files for parseable syntax.
- id: check-json
# Check for files that contain merge conflict strings.
- id: check-merge-conflict
# Checks for symlinks which do not point to anything.
- id: check-symlinks
# This hook checks toml files for parseable syntax.
- id: check-toml
# Ensures that links to vcs websites are permalinks.
- id: check-vcs-permalinks
# This hook checks xml files for parseable syntax.
- id: check-xml
# This hook checks yaml files for parseable syntax.
- id: check-yaml
# Detects symlinks which are changed to regular files with a content of a path which that symlink was pointing to.
- id: destroyed-symlinks
# Detects the presence of private keys
- id: detect-private-key
# Ensures that a file is either empty, or ends with one newline.
- id: end-of-file-fixer
exclude: README.md
# Replaces or checks mixed line ending
- id: mixed-line-ending
args: ["--fix=lf"]
description: Forces to replace line ending by the UNIX 'lf' character.
# This hook trims trailing whitespace.
- id: trailing-whitespace
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
hooks:
- id: check-added-large-files
args: ['--maxkb=1024']
# forbid files which have a UTF-8 byte-order marker
- id: fix-byte-order-marker
# Check for files that would conflict in case-insensitive filesystems
- id: check-case-conflict
# This hook checks json files for parseable syntax.
- id: check-json
# Check for files that contain merge conflict strings.
- id: check-merge-conflict
# Checks for symlinks which do not point to anything.
- id: check-symlinks
# This hook checks toml files for parseable syntax.
- id: check-toml
# Ensures that links to vcs websites are permalinks.
- id: check-vcs-permalinks
# This hook checks xml files for parseable syntax.
- id: check-xml
# This hook checks yaml files for parseable syntax.
- id: check-yaml
# Detects symlinks which are changed to regular files with a content of a path which that symlink was pointing to.
- id: destroyed-symlinks
# Detects the presence of private keys
- id: detect-private-key
# Ensures that a file is either empty, or ends with one newline.
- id: end-of-file-fixer
# Prevent addition of new git submodules
- id: forbid-new-submodules
# Replaces or checks mixed line ending
- id: mixed-line-ending
args: ['--fix=lf']
description: Forces to replace line ending by the UNIX 'lf' character.
- id: pretty-format-json
args: ['--autofix', '--indent', '2', '--no-sort-keys']
# This hook trims trailing whitespace.
- id: trailing-whitespace

# Prettier is an opinionated code formatter.
# It enforces a consistent style by parsing your code and re-printing it with its own rules that take the maximum line length into account, wrapping code when necessary.
- repo: https://github.com/pre-commit/mirrors-prettier
rev: "v3.0.0-alpha.4"
hooks:
- id: prettier
- repo: https://github.com/antonbabenko/pre-commit-terraform
rev: v1.76.0
hooks:
# Rewrites all Terraform configuration files to a canonical format.
- id: terraform_fmt
# Validates all Terraform configuration files.
- id: terraform_validate
# Validates all Terraform configuration files with TFLint.
- id: terraform_tflint
# TFSec static analysis of terraform templates to spot potential security issues.
- id: terraform_tfsec
# checkov static analysis of terraform templates to spot potential security issues.
- id: terraform_checkov # enable checkov at later stage
# terrascan Detect compliance and security violations.
- id: terrascan # enable terrascan at later stage
22 changes: 22 additions & 0 deletions .terraform.lock.hcl

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions .tflint.hcl
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
plugin "terraform" {
enabled = true
preset = "recommended"
}

plugin "aws" {
enabled = true
version = "0.21.1"
source = "github.com/terraform-linters/tflint-ruleset-aws"
}
3 changes: 0 additions & 3 deletions CODE_OF_CONDUCT.md

This file was deleted.

14 changes: 0 additions & 14 deletions LICENSE

This file was deleted.

11 changes: 11 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -10,3 +10,14 @@ include $(WORKSPACE)/tools.env

include $(HABITS)/lib/make/Makefile
include $(HABITS)/lib/make/*/Makefile

.PHONY: docs
docs: terraform-docs/build doc/build

.PHONY: plan
## Performs code and doc hygiene, then a terraform plan
plan: docs pre-commit/run terraform/plan

.PHONY: apply
## Performs code and doc hygiene, terraform plan and then terraform apply
apply: plan
2 changes: 0 additions & 2 deletions NOTICE

This file was deleted.

94 changes: 43 additions & 51 deletions README.md
Original file line number Diff line number Diff line change
@@ -10,49 +10,24 @@
![logo][logo]


# AWS Terraform Dev Container
# Tutorials - AWS Getting Started - Build Infrastructure

A VSCode Dev Container with [tools][tools] to help you build and manage AWS infrastructure with Terraform

| ![screenshot-1](doc/images/screenshot-1.gif) |
|:--:|
| *Develop your project in a Docker container* |

| ![screenshot-2](doc/images/screenshot-2.gif) |
|:--:|
| *Increase productivity with well-defined `Make` commands* |

| ![screenshot-3](doc/images/screenshot-3.gif) |
|:--:|
| *Ensure every team member has all the tools on their correct versions* |

| ![screenshot-4](doc/images/screenshot-4.png) |
|:--:|
| *Extensions already installed for you* |
This tutorial leverage the HashiCorp lesson [Build Infrastructure](https://developer.hashicorp.com/terraform/tutorials/aws-get-started/aws-build), you will provision an EC2 instance on Amazon Web Services (AWS).


## Table of Contents

- [Getting Started](#getting-started)

- [Prerequisites](#prerequisites)

- [Installation](#installation)

- [Usage](#usage)


- [Testing](#testing)


## Getting Started

1. On a terminal, inside your Terraform project, execute the following on Mac, Linux or [WSL][wsl]:
```bash
curl -sL https://raw.githubusercontent.com/awslabs/aws-terraform-dev-container/main/scripts/init.sh | bash
````
2. Open the folder with VSCode
3. Reopen in Container

To reopen in container manually, open the [command pallete](https://code.visualstudio.com/docs/getstarted/userinterface#_command-palette) on VS Code and select `Rebuild and Reopen in Container`
- [Deployment](#deployment)


## Prerequisites
@@ -63,34 +38,58 @@ To reopen in container manually, open the [command pallete](https://code.visuals
- [VSCode Remote Development Extension Pack](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.vscode-remote-extensionpack) - An extension pack that lets you open any folder in a container, on a remote machine, or in WSL and take advantage of VS Code's full feature set.


## Installation
If you are using AWS Terraform Dev Container, all the tools should be already installed.



## Usage
Once you have opened your project with VSCode Dev Containers:
1. In the terminal, export the AWS environment variables.
2. Execute the following commands

```bash
make [tab][tab]
make pre-commit/run
```
For example, if you want to explore the most common [terraform][terraform] commands:
Notice the warnings and errors raised by [tfsec](https://github.com/aquasecurity/tfsec), [checkov](https://github.com/bridgecrewio/checkov), and/or [terrascan](https://github.com/tenable/terrascan).
These messages allow us to improve the security of our solution overall. For this tutorial, we will ignore them.

```bash
make terraform/plan
make terraform/apply
make terraform/destroy
```

To generate documentation powered by [terraform-docs](https://github.com/terraform-docs/terraform-docs):
```bash
make terraform/[tab]
apply clean destroy fmt init init/ plan validate version
# you can combine two Make targets
make terraform-docs/init terraform-docs/build
```

To display all available commands:
To build your project's documentation
```bash
make help
make doc/build
````
Notice the creation, or update, of the README.md.
You can have a closer look into each Make target [here](.devcontainer/lib/make).



## Testing
```
make pre-commit/run terraform/plan
```
For more information about each [Make targets available](Makefile.md).
## Deployment
```
make terraform/apply
```
## References
- [Terraform by HashiCorp](https://www.terraform.io) - Terraform is an open-source infrastructure as code software tool that enables you to safely and predictably create, change, and improve infrastructure.
- [Changelog](CHANGELOG.md) - All notable changes.
- [Code Of Conduct](CODE_OF_CONDUCT.md) - Amazon Open Source Code of Conduct
- [Contributing](CONTRIBUTING.md) - Learn how to contribute
- [License](LICENSE) - MIT No Attribution
- [GNU Make](https://www.gnu.org/software/make/manual/make.html) - If you are new to make, or are looking for a general introduction.
- [Terraform by HashiCorp](['terraform']) - Terraform is an open-source infrastructure as code software tool that enables you to safely and predictably create, change, and improve infrastructure.
- [AWS Code Habits][aws-code-habits] - A library with Make targets, Ansible playbooks, Jinja templates (and more) designed to boost common software development tasks and enhance governance.
@@ -102,13 +101,6 @@ Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
[repo]: https://gitlab.aws.dev/proserve-labs/aws-terraform-dev-container
[logo]: doc/logo.png
[logo]: doc/logo.svg
[aws-code-habits]: https://github.com/awslabs/aws-code-habits
[docker]: https://www.docker.com/products/docker-desktop/
[vscode-dev-container]: https://code.visualstudio.com/docs/remote/containers
[terraform]: https://www.terraform.io
[license]: LICENSE
[tools]: TOOLS
[wsl]: https://learn.microsoft.com/en-us/windows/wsl/install
3 changes: 2 additions & 1 deletion TOOLS
Original file line number Diff line number Diff line change
@@ -15,14 +15,15 @@ pip 22.2.2 from /usr/local/lib/python3.8/dist-packages/pip (python 3.8)
--- TERRAFORM ---
Terraform v1.3.2
on linux_amd64
+ provider registry.terraform.io/hashicorp/aws v4.34.0
--- TERRAFORM DOCS ---
terraform-docs version v0.16.0 1f686b1 linux/amd64
--- TERRASCAN ---
version: v1.15.2
--- TFLINT ---
TFLint version 0.41.0
+ ruleset.terraform (0.1.1-bundled)
+ ruleset.aws (0.17.1)
+ ruleset.terraform (0.1.1-bundled)
--- TFSEC ---
v1.28.0
--- TFSWITCH ---
31 changes: 31 additions & 0 deletions Terraform.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Terraform
## Requirements

| Name | Version |
|------|---------|
| <a name="requirement_terraform"></a> [terraform](#requirement\_terraform) | >= 1.2.0 |
| <a name="requirement_aws"></a> [aws](#requirement\_aws) | ~> 4.16 |

## Providers

| Name | Version |
|------|---------|
| <a name="provider_aws"></a> [aws](#provider\_aws) | 4.34.0 |

## Modules

No modules.

## Resources

| Name | Type |
|------|------|
| [aws_instance.app_server](https://registry.terraform.io/providers/hashicorp/aws/latest/docs/resources/instance) | resource |

## Inputs

No inputs.

## Outputs

No outputs.
47 changes: 47 additions & 0 deletions doc/.terraform-docs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
formatter: "markdown" # this is required

version: ""

header-from: main.tf
footer-from: ""

recursive:
enabled: false
path: modules

sections:
hide: []
show: []

content: ""

output:
file: ""
mode: inject
template: |-
<!-- BEGIN_TF_DOCS -->
{{ .Content }}
<!-- END_TF_DOCS -->
output-values:
enabled: false
from: ""

sort:
enabled: true
by: name

settings:
anchor: true
color: true
default: true
description: false
escape: true
hide-empty: false
html: true
indent: 2
lockfile: true
read-comments: true
required: true
sensitive: true
type: true
142 changes: 142 additions & 0 deletions doc/README.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
{{- defineDatasource "config" .Env.README_YAML | regexp.Replace ".*" "" -}}
{{- defineDatasource "includes" .Env.README_INCLUDES | regexp.Replace ".*" "" -}}

<!--
** DO NOT EDIT THIS FILE
**
** 1) Make all changes to `doc/README.yaml`
** 2) Run `make doc/build` to rebuild this file
**
-->

{{ if has (ds "config") "logo" }}
![logo]({{ (ds "config").logo }})
{{end}}

<!-- SHIELDS -->
{{ if has (ds "config") "shields" }}
{{ range $shield := (ds "config").shields }}{{ printf "[![%s](%s)](%s)" $shield.name $shield.image $shield.url }}{{end}}
{{end}}

<!-- TITLE & DESCRIPTION -->
# {{ (ds "config").name }}

{{ (ds "config").description }}

<!-- SCREENSHOTS -->
{{ if has (ds "config") "screenshots" }}
## Screenshots
---
<details open>
<summary>Expand</summary>

{{ range $screenshot := (ds "config").screenshots }}
| ![{{ $screenshot.label }}]({{ $screenshot.url }}) |
|:--:|
| *{{ $screenshot.caption }}* |
{{ end }}
</details>
{{ end }}

## Table of Contents
---
{{ $c := ds "config" }}

{{ if has (ds "config") "usage" }}{{ $usage := $c.usage }}{{ if ne $usage "" }} - [Usage](#usage) {{end}}{{end}}
{{ if has (ds "config") "prerequisites" }}{{ $prerequisites := len $c.prerequisites }}{{ if gt $prerequisites 0 }} - [Prerequisites](#prerequisites) {{end}}{{end}}
{{ if has (ds "config") "installation" }}{{ $installation := $c.installation }}{{ if ne $installation "" }} - [Installation](#installation) {{end}}{{end}}
{{ if has (ds "config") "testing" }}{{ $testing := $c.testing }}{{ if ne $testing "" }} - [Testing](#testing) {{end}}{{end}}
{{ if has (ds "config") "deployment" }}{{ $deployment := $c.deployment }}{{ if ne $deployment "" }} - [Deployment](#deployment) {{end}}{{end}}
{{ if has (ds "config") "acknowledgments" }}{{ $acknowledgments := len $c.acknowledgments }}{{ if gt $acknowledgments 0 }} - [Acknowledgments](#acknowledgments) {{end}}{{end}}
{{ if has (ds "config") "contributors" }}{{ $contributors := len $c.contributors }}{{ if gt $contributors 0 }} - [Contributors](#contributors) {{end}}{{end}}
{{ if has (ds "config") "references" }}{{ $references := len $c.references }}{{ if gt $references 0 }} - [References](#references) {{end}}{{end}}
{{ if has (ds "config") "license" }}{{ $license := $c.license }}{{ if ne $license "" }} - [License](#license) {{end}}{{end}}
{{ if has (ds "config") "copyright" }}{{ $copyright := $c.copyright }}{{ if ne $copyright "" }} - [Copyright](#copyright) {{end}}{{end}}

<!-- USAGE -->
{{ if has (ds "config") "usage" }}
## Usage
---
<details open>
<summary>Expand</summary>

{{ (ds "config").usage }}
</details>
{{ end }}

<!-- PREREQUISITES -->
{{ if has (ds "config") "prerequisites" }}
## Prerequisites
---
<details>
<summary>Expand</summary>

{{ range $prerequisite := (ds "config").prerequisites }}{{ printf "- [%s](%s) - %s\n" $prerequisite.name $prerequisite.url $prerequisite.description }}{{end}}
</details>
{{end}}

<!-- INSTALLATION -->
{{ if has (ds "config") "installation" }}
## Installation
---
<details open>
<summary>Expand</summary>

{{ (ds "config").installation }}
</details>
{{end}}

<!-- TESTING -->
{{ if has (ds "config") "testing" }}
## Testing
---
<details>
<summary>Expand</summary>

{{ (ds "config").testing }}
</details>
{{end}}

<!-- DEPLOYMENT -->
{{ if has (ds "config") "deployment" }}
## Deployment
---
<details>
<summary>Expand</summary>

{{ (ds "config").deployment }}
</details>
{{end}}

{{ if has (ds "config") "include" }}
{{ range $file := (datasource "config").include -}}
{{ (include "includes" $file) }}
{{- end }}
{{- end }}

<!-- REFERENCES -->
{{ if has (ds "config") "references" }}
## References
---
<details open>
<summary>Expand</summary>

{{ range $ref := (ds "config").references }}{{ printf "* [%s]%s - %s\n" $ref.name $ref.url $ref.description }}{{end}}

</details>
{{end}}

## Copyright

Copyright © TBD -{{ (time.Now).UTC.Format "2006" }} [YOUR_COMPANY](https://www.yourcompany.com/)

## Trademarks

All other trademarks referenced herein are the property of their respective owners.

<!-- LINKS -->
[issue]: {{ (ds "config").url }}/-/issues
[contributors]: {{ (ds "config").url }}/-/graphs/main
{{ if has (ds "config") "links" }}
{{ range $link := (ds "config").links }}{{ printf "[%s]: %s\n" $link.name $link.url }}{{end}}
{{end}}
83 changes: 83 additions & 0 deletions doc/README.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
---

# project
url: https://

# Logo (can be local path or remote)
logo: doc/logo.svg

name: Tutorials - AWS Getting Started - Build Infrastructure
description: |-
This tutorial leverage the HashiCorp lesson [Build Infrastructure](https://developer.hashicorp.com/terraform/tutorials/aws-get-started/aws-build), you will provision an EC2 instance on Amazon Web Services (AWS).
# List of screenshots
# screenshots:
# - caption: Vestibulum malesuada
# label: vestibulum-malesuada
# url: https://via.placeholder.com/512

usage: |
Once you have opened your project with VSCode Dev Containers:
1. In the terminal, export the AWS environment variables.
2. Execute the following commands
```bash
make pre-commit/run
```
Notice the warnings and errors raised by [tfsec](https://github.com/aquasecurity/tfsec), [checkov](https://github.com/bridgecrewio/checkov), and/or [terrascan](https://github.com/tenable/terrascan).
These messages allow us to improve the security of our solution overall. For this tutorial, we will ignore them.
```bash
make terraform/plan
make terraform/apply
make terraform/destroy
```
To generate documentation powered by [terraform-docs](https://github.com/terraform-docs/terraform-docs):
```bash
# you can combine two Make targets
make terraform-docs/init terraform-docs/build
```
To build your project's documentation
```bash
make doc/build
````
Notice the creation, or update, of the README.md.
You can have a closer look into each Make target [here](.devcontainer/lib/make).
# prerequisites:
# - name: Example
# description: Cras nibh neque, tristique vitae sem quis, convallis euismod dui.
# url: https://example.com

installation: |
If you are using AWS Terraform Dev Container, all the tools should be already installed.
testing: |
```
make pre-commit/run terraform/plan
```
deployment: |
```
make terraform/apply
```
# If you want to include other files
include:
- "Terraform.md"

# explicit urls needs to be enclosed with ()
# implicit urls needs to be enclosed with []
references:
- name: Terraform by HashiCorp
description: Terraform is an open-source infrastructure as code software tool that enables you to safely and predictably create, change, and improve infrastructure.
url: [terraform]

links:
- name: terraform
url: https://www.terraform.io/
- name: Developer HashiCorp
url: https://developer.hashicorp.com/terraform/tutorials/aws-get-started
132 changes: 65 additions & 67 deletions doc/habits.yaml
Original file line number Diff line number Diff line change
@@ -1,33 +1,51 @@
---

# project
url: https://gitlab.aws.dev/proserve-labs/aws-terraform-dev-container

logo: doc/logo.png

title: AWS Terraform Dev Container
description: A VSCode Dev Container with [tools][tools] to help you build and manage AWS infrastructure with Terraform

screenshots:
- caption: Develop your project in a Docker container
label: screenshot-1
url: doc/images/screenshot-1.gif
- caption: Increase productivity with well-defined `Make` commands
label: screenshot-2
url: doc/images/screenshot-2.gif
- caption: Ensure every team member has all the tools on their correct versions
label: screenshot-3
url: doc/images/screenshot-3.gif
- caption: Extensions already installed for you
label: screenshot-4
url: doc/images/screenshot-4.png

getting_started: |-
1. On a terminal, inside your Terraform project, execute the following on Mac, Linux or [WSL][wsl]:
# Logo (can be local path or remote)
logo: doc/logo.svg

title: Tutorials - AWS Getting Started - Build Infrastructure
description: |-
This tutorial leverage the HashiCorp lesson [Build Infrastructure](https://developer.hashicorp.com/terraform/tutorials/aws-get-started/aws-build), you will provision an EC2 instance on Amazon Web Services (AWS).
# List of screenshots
# screenshots:
# - caption: Vestibulum malesuada
# label: vestibulum-malesuada
# url: https://via.placeholder.com/512

usage: |
Once you have opened your project with VSCode Dev Containers:
1. In the terminal, export the AWS environment variables.
2. Execute the following commands
```bash
curl -sL https://raw.githubusercontent.com/awslabs/aws-terraform-dev-container/main/scripts/init.sh | bash
````
2. Open the folder with VSCode
3. Reopen in Container
make pre-commit/run
```
Notice the warnings and errors raised by [tfsec](https://github.com/aquasecurity/tfsec), [checkov](https://github.com/bridgecrewio/checkov), and/or [terrascan](https://github.com/tenable/terrascan).
These messages allow us to improve the security of our solution overall. For this tutorial, we will ignore them.
```bash
make terraform/plan
make terraform/apply
make terraform/destroy
```
To generate documentation powered by [terraform-docs](https://github.com/terraform-docs/terraform-docs):
```bash
# you can combine two Make targets
make terraform-docs/init terraform-docs/build
```
To reopen in container manually, open the [command pallete](https://code.visualstudio.com/docs/getstarted/userinterface#_command-palette) on VS Code and select `Rebuild and Reopen in Container`
To build your project's documentation
```bash
make doc/build
````
Notice the creation, or update, of the README.md.
You can have a closer look into each Make target [here](.devcontainer/lib/make).
prerequisites:
content: |-
@@ -43,55 +61,35 @@ prerequisites:
description: An extension pack that lets you open any folder in a container, on a remote machine, or in WSL and take advantage of VS Code's full feature set.
url: https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.vscode-remote-extensionpack

usage: |-
```bash
make [tab][tab]
installation: |
If you are using AWS Terraform Dev Container, all the tools should be already installed.
testing: |
```
For example, if you want to explore the most common [terraform][terraform] commands:
```bash
make terraform/[tab]
apply clean destroy fmt init init/ plan validate version
make pre-commit/run terraform/plan
```
To display all available commands:
```bash
make help
deployment: |
```
For more information about each [Make targets available](Makefile.md).
make terraform/apply
```
# If you want to include other files
include:
- "Terraform.md"

# explicit urls needs to be enclosed with ()
# implicit urls needs to be enclosed with []
references:
- name: Terraform by HashiCorp
description: Terraform is an open-source infrastructure as code software tool that enables you to safely and predictably create, change, and improve infrastructure.
url: https://www.terraform.io
- name: Changelog
description: All notable changes.
url: CHANGELOG.md
- name: Code Of Conduct
description: Amazon Open Source Code of Conduct
url: CODE_OF_CONDUCT.md
- name: Contributing
description: Learn how to contribute
url: CONTRIBUTING.md
- name: License
description: MIT No Attribution
url: LICENSE
- name: GNU Make
description: If you are new to make, or are looking for a general introduction.
url: https://www.gnu.org/software/make/manual/make.html
url: [terraform]

links:
- name: terraform
url: https://www.terraform.io/
- name: Developer HashiCorp
url: https://developer.hashicorp.com/terraform/tutorials/aws-get-started

license: MIT-0
copyright: Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.

anchors:
- name: docker
url: https://www.docker.com/products/docker-desktop/
- name: vscode-dev-container
url: https://code.visualstudio.com/docs/remote/containers
- name: terraform
url: https://www.terraform.io
- name: license
url: LICENSE
- name: tools
url: TOOLS
- name: wsl
url: https://learn.microsoft.com/en-us/windows/wsl/install
Binary file removed doc/images/screenshot-1.gif
Binary file not shown.
Binary file removed doc/images/screenshot-2.gif
Binary file not shown.
Binary file removed doc/images/screenshot-3.gif
Binary file not shown.
Binary file removed doc/images/screenshot-4.png
Binary file not shown.
Binary file removed doc/logo.png
Binary file not shown.
197 changes: 23 additions & 174 deletions doc/logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 23 additions & 0 deletions main.tf
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
terraform {
required_providers {
aws = {
source = "hashicorp/aws"
version = "~> 4.16"
}
}

required_version = ">= 1.2.0"
}

provider "aws" {
region = "us-west-2"
}

resource "aws_instance" "app_server" {
ami = "ami-830c94e3"
instance_type = "t2.micro"

tags = {
Name = "ExampleAppServerInstance"
}
}
4 changes: 4 additions & 0 deletions tools.env
Original file line number Diff line number Diff line change
@@ -1 +1,5 @@
GITIGNORE=macos,windows,linux,visualstudiocode,python,node,terraform
TFLINT_AWS_RULESET_VERSION=0.21.1
TERRAFORM_DOCS_VERSION=0.16.0
TERRASCAN_VERSION=1.17.1
TFSEC_VERSION=1.28.1