├── .github └── workflows │ └── docker.yml ├── .gitignore ├── .gitpod.bashrc ├── Dockerfile ├── LICENSE.md └── README.md /.github/workflows/docker.yml: -------------------------------------------------------------------------------- 1 | name: Build and push image 2 | 3 | on: 4 | push: 5 | schedule: 6 | - cron: '0 12 * * *' 7 | 8 | env: 9 | AWS_ECR_PUBLIC_REGISTRY_ALIAS: "vlaaaaaaad" 10 | AWS_ECR_PUBLIC_REPO_NAME: "gitpod-terraform" 11 | 12 | jobs: 13 | aws_ecr_public: 14 | name: Amazon ECR Public 15 | runs-on: ubuntu-latest 16 | 17 | steps: 18 | - name: Get the code 19 | uses: actions/checkout@v2 20 | 21 | - name: Prepare for container image build 22 | id: prepare 23 | run: | 24 | echo "::set-output name=created::$(date -u +'%Y-%m-%dT%H:%M:%SZ')" 25 | echo "::set-output name=version::$(date '+%Y-%m-%d')" 26 | 27 | ECR_PUBLIC_SHA_TAG="public.ecr.aws/${{ env.AWS_ECR_PUBLIC_REGISTRY_ALIAS }}/${{ env.AWS_ECR_PUBLIC_REPO_NAME }}:${{ github.sha }}" 28 | TAGS=$ECR_PUBLIC_SHA_TAG 29 | echo "🏷️ Added container tag: ${ECR_PUBLIC_SHA_TAG}" 30 | 31 | if [[ "${{ github.ref }}" == 'refs/heads/main' ]]; then 32 | ECR_PUBLIC_DATE_TAG="public.ecr.aws/${{ env.AWS_ECR_PUBLIC_REGISTRY_ALIAS }}/${{ env.AWS_ECR_PUBLIC_REPO_NAME }}:$(date '+%Y-%m-%d')" 33 | ECR_PUBLIC_LATEST_TAG="public.ecr.aws/${{ env.AWS_ECR_PUBLIC_REGISTRY_ALIAS }}/${{ env.AWS_ECR_PUBLIC_REPO_NAME }}:latest" 34 | 35 | TAGS+=", ${ECR_PUBLIC_DATE_TAG}, ${ECR_PUBLIC_LATEST_TAG}" 36 | echo "🏷️ Added container tag: ${ECR_PUBLIC_DATE_TAG}" 37 | echo "🏷️ Added container tag: ${ECR_PUBLIC_LATEST_TAG}" 38 | fi 39 | 40 | echo "::set-output name=tags::${TAGS}" 41 | echo "🏷️ Final list of container image tags: ${TAGS}" 42 | 43 | - name: Login to AWS ECR Public 44 | uses: docker/login-action@v1 45 | with: 46 | registry: public.ecr.aws 47 | username: ${{ secrets.AWS_ACCESS_KEY_ID }} 48 | password: ${{ secrets.AWS_SECRET_ACCESS_KEY }} 49 | 50 | - name: Set up Docker Buildx 51 | uses: docker/setup-buildx-action@v1 52 | 53 | - name: Build and push to AWS ECR Public 54 | uses: docker/build-push-action@v2 55 | with: 56 | context: . 57 | no-cache: true # Waiting for https://github.com/docker/buildx/pull/535 58 | file: ./Dockerfile 59 | platforms: linux/amd64 60 | labels: | 61 | org.opencontainers.image.title=${{ github.event.repository.name }} 62 | org.opencontainers.image.vendor=${{ github.event.repository.owner.login }} 63 | org.opencontainers.image.description=${{ github.event.repository.description }} 64 | org.opencontainers.image.url=${{ github.event.repository.html_url }} 65 | org.opencontainers.image.source=${{ github.event.repository.clone_url }} 66 | org.opencontainers.image.version=${{ steps.prepare.outputs.version }} 67 | org.opencontainers.image.created=${{ steps.prepare.outputs.created }} 68 | org.opencontainers.image.revision=${{ github.sha }} 69 | org.opencontainers.image.licenses=${{ github.event.repository.license.spdx_id }} 70 | push: true 71 | tags: ${{ steps.prepare.outputs.tags }} 72 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # macOS 2 | .DS_Store 3 | .DS_Store? 4 | **/.DS_Store 5 | ._* 6 | .Spotlight-V100 7 | .Trashes 8 | ehthumbs.db 9 | Thumbs.db 10 | -------------------------------------------------------------------------------- /.gitpod.bashrc: -------------------------------------------------------------------------------- 1 | # Load completion for terrafom docs 2 | source <(terraform-docs completion bash) 3 | 4 | alias tf="terraform " 5 | complete -C /home/linuxbrew/.linuxbrew/bin/terraform terraform 6 | complete -C /home/linuxbrew/.linuxbrew/bin/terraform tf 7 | 8 | export PS1="┌─── \u @ ☁️ : \n│ \w \n└ " 9 | -------------------------------------------------------------------------------- /Dockerfile: -------------------------------------------------------------------------------- 1 | # Big image but it's cached on gitpod nodes already 2 | FROM gitpod/workspace-full:latest 3 | 4 | # Install tools as the gitpod user 5 | USER gitpod 6 | SHELL ["/bin/bash", "-o", "pipefail", "-c"] 7 | 8 | # Install helper tools 9 | RUN brew update && brew upgrade && brew install \ 10 | gawk coreutils pre-commit tfenv terraform-docs \ 11 | tflint tfsec instrumenta/instrumenta/conftest \ 12 | && brew install --ignore-dependencies cdktf \ 13 | && brew cleanup 14 | RUN tfenv install latest && tfenv use latest 15 | 16 | COPY .gitpod.bashrc /home/gitpod/.bashrc.d/custom 17 | 18 | # Give back control 19 | USER root 20 | # and revert back to default shell 21 | # otherwise adding Gitpod Layer will fail 22 | SHELL ["/bin/sh", "-c"] 23 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | # MIT License 2 | 3 | Copyright (c) 2019 Vlad Ionescu 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Gitpod Terraform image 2 | 3 | [![Open in Gitpod](https://gitpod.io/button/open-in-gitpod.svg)](https://gitpod.io#https://github.com/Vlaaaaaaad/gitpod-terraform) 4 | 5 | Helper image for Terraform module development in [Gitpod](https://gitpod.io). 6 | 7 | Tags available: 8 | 9 | - `latest` which is the recommended tag ([Gitpod-official images use `latest` too](https://hub.docker.com/r/gitpod/workspace-full/tags)) 10 | - the date of the build, like `2021-06-25` for tighter control of versions 11 | 12 | To use the image, [set it in `.gitpod.yml`](https://www.gitpod.io/docs/42_config_docker/): 13 | 14 | ```yaml 15 | image: public.ecr.aws/vlaaaaaaad/gitpod-terraform:latest 16 | ``` 17 | 18 | ## Builtins 19 | 20 | The image comes with several helpful tools pre-installed: 21 | 22 | - `bash` which is also configured 23 | - latest version of [Terraform](https://www.terraform.io/) installed by [`tfenv`](https://github.com/tfutils/tfenv) for a better user experience 24 | - `cdktf` for people on the edge using [CDK (Cloud Development Kit) for Terraform](https://github.com/hashicorp/terraform-cdk) 25 | - [pre-commit](https://pre-commit.com) for pre-commit hooks like [pre-commit-terraform](https://github.com/antonbabenko/pre-commit-terraform) 26 | - [terraform-docs](https://github.com/segmentio/terraform-docs) for Terraform documentation generation 27 | - [tflint](https://github.com/wata727/tflint) for Terraform best practices verification 28 | - [tfsec](https://github.com/liamg/tfsec) for security best practices 29 | - [conftest](https://github.com/instrumenta/conftest) for running Open Policy Agent tests on Terraform code 30 | 31 | --- 32 | 33 | ## Contributing 34 | 35 | 1. Fork it ([https://github.com/vlaaaaaaad/gitpod-terraform/fork](https://github.com/vlaaaaaaad/gitpod-terraform/fork)) 36 | 2. Create your feature branch (`git checkout -b feature/fooBar`) 37 | 3. Commit your changes (`git commit -am 'Add some fooBar'`) 38 | 4. Push to the branch (`git push origin feature/fooBar`) 39 | 5. Create a new Pull Request 40 | 41 | ## Credits 42 | 43 | - [@jankeromnes](https://github.com/jankeromnes) for being [very helpful on a GitHub issue and providing guidance](https://github.com/gitpod-io/gitpod/issues/782) 44 | 45 | ## License 46 | 47 | This project is provided under the [MIT License](https://github.com/vlaaaaaaad/gitpod-terraform/blob/master/LICENSE.md). See [LICENSE](https://github.com/vlaaaaaaad/gitpod-terraform/blob/master/LICENSE.md) for more information. 48 | --------------------------------------------------------------------------------