Skip to content

Commit

Permalink
add the dummy script in case you don't need to terraform.
Browse files Browse the repository at this point in the history
  • Loading branch information
mazgi committed Sep 13, 2022
1 parent f934db6 commit b99cb54
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 14 deletions.
16 changes: 6 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ Environment variable names and uses are as follows.
| Name | Required with Terraform | Value |
| -------------------------- | ----------------------- | --------------------------------------------------------------------------------------------------------------- |
| PROJECT_UNIQUE_ID | **Yes** | An ID to indicate your environment.<br/>The value is used for an Object Storage bucket or Storage Account name. |
| \_TERRAFORM_BACKEND_TYPE | **Yes** | Acceptable values are `azurerm`, `gcs`, and `s3`. |
| \_TERRAFORM_BACKEND_TYPE | **Yes** | Acceptable values are `azurerm`, `gcs`, `s3`, and `none`. |
| TF_VAR_allowed_ipaddr_list | no | IP address ranges you want access to your cloud environment. |

</details>
Expand Down Expand Up @@ -89,15 +89,7 @@ Environment variable names and uses are as follows.

### Step 2. Define your service in the `docker-compose.yml`

Comment-in the `provisioning` service in the [`docker-compose.yml`](docker-compose.yml) as follows or define a service you own.

```yaml
services:
# provisioning:
# <<: *provisioning-base
```

:arrow_down:
You are able to update and define the `provisioning` service to your need in the [`docker-compose.yml`](docker-compose.yml).

```yaml
services:
Expand All @@ -115,6 +107,10 @@ docker compose up
docker compose exec provisioning terraform apply
```

```console
rm -rf tmp/run/container-*/ && docker compose down --remove-orphans
```

### Step 3. Set secrets for GitHub Actions

The [gh command](https://cli.github.com/) helps set secrets.
Expand Down
10 changes: 6 additions & 4 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ x-service-provisioning-base: &provisioning-base
mkdir -p $${_STAT_DIR:?}/
export _STAT_DIR_INTERNAL=/tmp/container-myself
ln --force --no-dereference --symbolic $${_STAT_DIR:?}/ $${_STAT_DIR_INTERNAL:?}
echo '{}' | jq '. + {enabled:true}' > $${_STAT_DIR_INTERNAL}/stat.json
echo '{}' | jq '. + {enabled:true}' | tee $${_STAT_DIR_INTERNAL}/stat.tmp.json > $${_STAT_DIR_INTERNAL}/stat.json
:
rm -rf /workspace/tmp/provisioning/.terraform.d
/workspace/scripts/provisioning.init-terraform-with-$${_TERRAFORM_BACKEND_TYPE}-backend.zsh\
Expand Down Expand Up @@ -52,7 +52,7 @@ x-service-provisioning-base: &provisioning-base
GCP_DEFAULT_REGION: ${GCP_DEFAULT_REGION:-us-central1}
GOOGLE_APPLICATION_CREDENTIALS: ${GOOGLE_APPLICATION_CREDENTIALS:-/workspace/config/credentials/google-cloud-keyfile.provisioning-owner.json}
# </Google>
_TERRAFORM_BACKEND_TYPE: ~
_TERRAFORM_BACKEND_TYPE: none
TF_DATA_DIR: /tmp/provisioning/.terraform.d/
TF_VAR_allowed_ipaddr_list: ${TF_VAR_allowed_ipaddr_list}
TF_VAR_aws_access_key: ${AWS_ACCESS_KEY_ID}
Expand Down Expand Up @@ -83,8 +83,10 @@ x-service-provisioning-base: &provisioning-base

# You are able to implement your service like below.
services:
# provisioning:
# <<: *provisioning-base
provisioning:
<<: *provisioning-base

# The following services are for Demonstration and CI/CD purposes; therefore, you can remove these.
provisioning-azurerm-backend:
<<: *provisioning-base
environment:
Expand Down
23 changes: 23 additions & 0 deletions scripts/provisioning.init-terraform-with-none-backend.zsh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/usr/bin/env -S zsh -eu
setopt extended_glob

# see: http:https://zsh.sourceforge.net/Doc/Release/Zsh-Modules.html#index-funcstack
if [[ ${#funcstack[@]} -ne 0 ]]; then
echo 'the script is being sourced.'
echo "please run it is as a subshell such as \"sh $0\""
return 0
fi

if [[ ! -v PROJECT_UNIQUE_ID ]]; then
echo 'the $PROJECT_UNIQUE_ID variable is not set.'
echo 'it was canceled.'
exit 0
fi

termColorClear='\033[0m'
termColorWarn='\033[1;33m'
echoWarn() {
echo -e "${termColorWarn}$1${termColorClear}"
}

echoWarn "\"$(basename $0)\" is the dummy script. You are able to remove this if you don't want to use Terraform."

0 comments on commit b99cb54

Please sign in to comment.