Skip to content
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

Update from main repo #37

Merged
merged 26 commits into from
Jun 25, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
d68d289
Add basic azure checks
nimrodkor Jun 16, 2020
203f20e
Fix so it actually deploys
nimrodkor Jun 16, 2020
3f3d069
Add Azure BE and add guidelines to README
nimrodkor Jun 17, 2020
898d5be
Add all relevant resources
nimrodkor Jun 17, 2020
de3bb77
Fix so it runs
nimrodkor Jun 17, 2020
0097bf2
Re-add payload + BE azure configuration
nimrodkor Jun 18, 2020
69bc3a1
Merge pull request #29 from bridgecrewio/feature/add_azure
nimrodkor Jun 18, 2020
26983f3
update resource scan result doc
actions-user Jun 18, 2020
fbe02c6
Update template instead of README
nimrodkor Jun 18, 2020
53d93eb
update resource scan result doc
actions-user Jun 18, 2020
8f8e19b
Corrected ReadMe Markdown Errors
AErmie Jun 19, 2020
4171830
Corrected ReadMe Markdown Errors
AErmie Jun 19, 2020
22a6554
Added working Azure code example
AErmie Jun 19, 2020
1c45d5a
Merge branch 'master' of https://github.com/AErmie/terragoat
AErmie Jun 19, 2020
39e90a2
Updated template file per BridgeCrew direction
AErmie Jun 19, 2020
898b1ea
Unified Azure code examples to use Bash syntax
AErmie Jun 19, 2020
8a1b789
Version pinning / Storage Container Mod
AErmie Jun 19, 2020
81738b8
Added Random Int, Corrected KV Resource
AErmie Jun 19, 2020
f8ff847
Corrected KeyVault Secret Resource
AErmie Jun 19, 2020
2a202a4
Reverted auto-gen section of template
AErmie Jun 23, 2020
fe23fcf
Merge pull request #30 from AErmie/master
nimrodkor Jun 23, 2020
decde8d
update resource scan result doc
actions-user Jun 23, 2020
0bde09d
Fix template.md
nimrodkor Jun 23, 2020
f2bc42a
update resource scan result doc
actions-user Jun 23, 2020
6380354
Add newline to readme
nimrodkor Jun 23, 2020
12b263f
update resource scan result doc
actions-user Jun 23, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
113 changes: 85 additions & 28 deletions .github/template.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
# TerraGoat - Vulnerable Terraform Infrastructure
# TerraGoat - Vulnerable Terraform Infrastructure

[![Maintained by Bridgecrew.io](https://img.shields.io/badge/maintained%20by-bridgecrew.io-blueviolet)](https://bridge.dev/2WBms5Q)
![Terraform Version](https://img.shields.io/badge/tf-%3E%3D0.12.0-blue.svg)

TerraGoat is Bridgecrew's "Vulnerable by Design" Terraform repository.
[![Terragoat](terragoat-logo.png)](#)
![Terragoat](terragoat-logo.png)

TerraGoat is Bridgecrew's "Vulnerable by Design" Terraform repository.
TerraGoat is a learning and training project that demonstrates how common configuration errors can find their way into production cloud environments.


## Table of Contents

* [Introduction](#introduction)
* [Getting Started](#getting-started)
* [AWS](#aws-setup)
* [Azure](#azure-setup)
* [Contributing](#contributing)
* [Support](#support)

Expand All @@ -23,23 +25,30 @@ TerraGoat was built to enable DevSecOps design and implement a sustainable misco
TerraGoat follows the tradition of existing *Goat projects that provide a baseline training ground to practice implementing secure development best practices for cloud infrastructure.

## Important notes

* **Where to get help:** the [Bridgecrew Community Slack](https://codified-security.herokuapp.com/)

Before you proceed please take a not of these warning:
> :warning: TerraGoat creates intentionally vulnerable AWS resources into your account. **DO NOT deploy TerraGoat in a production environment or alongside any sensitive AWS resources.**

## Requirements
* Terraform 0.12

* Terraform 0.12
* aws cli
* azure cli

To prevent vulnerable infrastructure from arriving to production
see: [checkov](https://github.com/bridgecrewio/checkov/), the open source static analysis tool for infrastructure as code.
To prevent vulnerable infrastructure from arriving to production see: [checkov](https://github.com/bridgecrewio/checkov/), the open source static analysis tool for infrastructure as code.

## Getting started
### Installation
You can deploy multiple TerraGoat stacks in a single AWS account using the parameters `TF_VAR_environment` and `TF_VAR_environment`.

#### Create an S3 bucket backend to keep Terraform state

### AWS Setup

#### Installation (AWS)

You can deploy multiple TerraGoat stacks in a single AWS account using the parameter `TF_VAR_environment`.

#### Create an S3 Bucket backend to keep Terraform state

```bash
export TERRAGOAT_STATE_BUCKET="mydevsecops-bucket"
export TF_VAR_company_name=acme
Expand All @@ -49,7 +58,7 @@ export TF_VAR_region="us-west-2"
aws s3api create-bucket --bucket $TERRAGOAT_STATE_BUCKET \
--region $TF_VAR_region --create-bucket-configuration LocationConstraint=$TF_VAR_region

# Enable versioning
# Enable versioning
aws s3api put-bucket-versioning --bucket $TERRAGOAT_STATE_BUCKET --versioning-configuration Status=Enabled

# Enable encryption
Expand All @@ -64,9 +73,10 @@ aws s3api put-bucket-encryption --bucket $TERRAGOAT_STATE_BUCKET --server-side-e
}'
```

#### Apply TerraGoat
#### Apply TerraGoat (AWS)

```bash
cd terraform/
cd terraform/aws/
terraform init \
-backend-config="bucket=$TERRAGOAT_STATE_BUCKET" \
-backend-config="key=$TF_VAR_company_name-$TF_VAR_environment.tfstate" \
Expand All @@ -75,48 +85,95 @@ terraform init \
terraform apply
```

#### Remove TerraGoat
#### Remove TerraGoat (AWS)

```bash
terraform destroy
```

#### Creating multiple TerraGoat stacks
```bash
#### Creating multiple TerraGoat AWS stacks

cd terraform/
```bash
cd terraform/aws/
export TERRAGOAT_ENV=$TF_VAR_environment
export TERRAGOAT_STACKS_NUM=5
for i in $(seq 1 $TERRAGOAT_STACKS_NUM)
do
export TF_VAR_environment=$TERRAGOAT_ENV$i
export TF_VAR_environment=$TERRAGOAT_ENV$i
terraform init \
-backend-config="bucket=$TERRAGOAT_STATE_BUCKET" \
-backend-config="key=$TF_VAR_company_name-$TF_VAR_environment.tfstate" \
-backend-config="region=$TF_VAR_region"
-backend-config="region=$TF_VAR_region"

terraform apply -auto-approve
done
```

#### Deleting multiple TerraGoat stacks
```bash
#### Deleting multiple TerraGoat stacks (AWS)

cd terraform/
```bash
cd terraform/aws/
export TF_VAR_environment = $TERRAGOAT_ENV
for i in $(seq 1 $TERRAGOAT_STACKS_NUM)
do
export TF_VAR_environment=$TERRAGOAT_ENV$i
export TF_VAR_environment=$TERRAGOAT_ENV$i
terraform init \
-backend-config="bucket=$TERRAGOAT_STATE_BUCKET" \
-backend-config="key=$TF_VAR_company_name-$TF_VAR_environment.tfstate" \
-backend-config="region=$TF_VAR_region"
-backend-config="region=$TF_VAR_region"

terraform destroy -auto-approve
done
```

### Azure Setup

#### Installation (Azure)

You can deploy multiple TerraGoat stacks in a single Azure subscription using the parameter `TF_VAR_environment`.

#### Create an Azure Storage Account backend to keep Terraform state

```bash
export TERRAGOAT_RESOURCE_GROUP="TerraGoatRG"
export TERRAGOAT_STATE_STORAGE_ACCOUNT="mydevsecopssa"
export TERRAGOAT_STATE_CONTAINER="mydevsecops"
export TF_VAR_environment="dev"
export TF_VAR_region="westus"

# Create resource group
az group create --location $TF_VAR_region --name $TERRAGOAT_RESOURCE_GROUP

# Create storage account
az storage account create --name $TERRAGOAT_STATE_STORAGE_ACCOUNT --resource-group $TERRAGOAT_RESOURCE_GROUP --location $TF_VAR_region --sku Standard_LRS --kind StorageV2 --https-only true --encryption-services blob

# Get storage account key
ACCOUNT_KEY=$(az storage account keys list --resource-group $TERRAGOAT_RESOURCE_GROUP --account-name $TERRAGOAT_STATE_STORAGE_ACCOUNT --query [0].value -o tsv)

# Create blob container
az storage container create --name $TERRAGOAT_STATE_CONTAINER --account-name $TERRAGOAT_STATE_STORAGE_ACCOUNT --account-key $ACCOUNT_KEY
```

#### Apply TerraGoat (Azure)

```bash
cd terraform/azure/
terraform init -reconfigure -backend-config="resource_group_name=$TERRAGOAT_RESOURCE_GROUP" \
-backend-config "storage_account_name=$TERRAGOAT_STATE_STORAGE_ACCOUNT" \
-backend-config="container_name=$TERRAGOAT_STATE_CONTAINER" \
-backend-config "key=$TF_VAR_environment.terraform.tfstate"

terraform apply
```

#### Remove TerraGoat (Azure)

```bash
terraform destroy
```

## Bridgecrew's IaC herd of goats

## Bridgecrew's IaC heard of goats:
* [CfnGoat](https://github.com/bridgecrewio/cfngoat) - Vulnerable by design Cloudformation template
* [TerraGoat](https://github.com/bridgecrewio/terragoat) - Vulnerable by design Terraform stack

Expand All @@ -132,4 +189,4 @@ We would love to hear about more ideas on how to find vulnerable infrastructure-

If you need direct support you can contact us at [[email protected]](mailto:[email protected]).

# Existing vulnerabilities (Auto-Generated)
## Existing vulnerabilities (Auto-Generated)
Loading