Skip to content

Commit

Permalink
Updated template file per BridgeCrew direction
Browse files Browse the repository at this point in the history
  • Loading branch information
AErmie committed Jun 19, 2020
1 parent 1c45d5a commit 39e90a2
Showing 1 changed file with 22 additions and 14 deletions.
36 changes: 22 additions & 14 deletions .github/template.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,27 +134,35 @@ You can deploy multiple TerraGoat stacks in a single Azure subscription using th

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

Create a resource group and a storage account in your Azure portal.
Then run (replace with your values):
```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"

```shell script
export TF_VAR_environment=acme
terraform init -reconfigure -backend-config="resource_group_name=<YOUR_RESOURCE_GROUP>" \
-backend-config "storage_account_name=<YOUR_STORAGE_ACCOUNT>" \
-backend-config "key=$TF_VAR_environment.terraform.tfstate
```
# Create resource group
az group create --location $TF_VAR_region --name $TERRAGOAT_RESOURCE_GROUP

#### Apply TerraGoat (Azure)
# 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

To run terragoat, first login to azure CLI using:
# 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)

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

After being redirected to your login page and signing in, run:
#### 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"

```shell script
terraform apply
```

Expand Down

0 comments on commit 39e90a2

Please sign in to comment.