This Terraform root module demonstrates deployment of servian TechChallengeApp to Cloud foundry
- Contents of this README:
- What is being provisioned
- Requirements
- Providers
- Modules
- Resources
- Inputs
- High level architectural overview of deployment
- GitHub Action overview
- deployment-overview.
- Deployment
- GitHub Actions (Automated Process)
- Manual Deployment.
- Technical Challenge URL
- Contact / Getting help
- License
- PostgreSQL database
- TechChallengeApp
Name | Version |
---|---|
terraform | >= 0.14.0 |
cloudfoundry | >= 0.14.2 |
cloudfoundry-Host | n/a |
Name | Version |
---|---|
cloudfoundry | >= 0.14.1 |
hsdp | n/a |
No modules.
Name | Type |
---|---|
cloudfoundry_app.servianapp | resource |
cloudfoundry_service_instance.database | resource |
cloudfoundry_service_key.database_key | resource |
cloudfoundry_domain.domain | data source |
cloudfoundry_org.org | data source |
cloudfoundry_service.rds | data source |
hsdp_config.cf | data source |
Name | Description | Type | Default | Required |
---|---|---|---|---|
cf_api | Cloud foundry API endpoint (region specific) | string |
"https://api.cloud.pcftest.com" |
yes |
cf_app_name | The CF app name | string |
"servian-app" |
yes |
cf_domain_name | The CF domain to use for app | string |
"cloud.pcftest.com" |
no |
cf_db_name | The name of the database | string |
"servian-db" |
yes |
cf_org_name | The CF Org to deploy under | string |
n/a | yes |
cf_app_region | Cloud foundry region | string |
"us-east" |
yes |
cf_space_id | The id of the CF Space to deploy in | string |
n/a | yes |
db_broker | The Database broker to use for requesting a PostgreSQL database | string |
"hsdp-rds" |
no |
db_plan | The Database plan to use | string |
"postgres-micro-dev" |
no |
disk | The amount of Disk space to allocate for app (MB) | number |
1024 |
no |
docker_image | Docker image to use | string |
servian/techchallengeapp:latest |
yes |
listenport | The listenport of the app | number |
8080 |
yes |
listenhost | The listenhost of the app | string |
0.0.0.0 |
yes |
memory | The amount of RAM to allocate for app (MB) | number |
512 |
no |
GitHub Action overview | deployment-overview |
---|---|
![]() |
![]() |
- Whenever new code is merged to the main branch then the GitHub action will be triggered automatically.
- On successful build completion, Tech Challange App and postgres DB instance will be provisioned in cloud foundry
- The secret variables are configured in Github
- Full workflow about provisioning Tech Challange App and postgres DB is available in the servian-app-actions.yml
Terraform should be installed on your system. Instructions available here. Once installed check the version, it should be at least 0.14.2
or higher:
$ terraform version
Terraform v1.0.7
Next Terraform needs to download the necessary provider plugins, modules and set up the initial (empty) state. Start by executing
$ terraform init
Now you are ready to run terraform plan with secrets vraiables :
$ terraform plan -var="cf_org_name=${{secrets.CF_ORG_NAME}}" -var="cf_username=${{secrets.CF_USERNAME}}" -var="cf_password=${{secrets.CF_PASSWORD}}" -var="cf_space_id=${{secrets.CF_SPACE_ID}}" -out=tfplan
Terraform will calculate an execution plan and display all the actions it needs to perform to deploy app and components.
The apply step will kick off provisioning of all resources:
$ terraform apply -auto-approve "tfplan"
This typically takes between 5-15 minutes. The majority of the time is spend waiting on the PostgreSQL database to become available for use. Once the apply step finishes you should see something like below:
Apply complete! Resources: 4 added, 0 changed, 0 destroyed..
You can remove all created resources using the terraform destroy command
$ terraform destroy
To Access Technical Challenge URL depolyed in cloud foundry:
https://techchallenge-app.cloud.pcftest.com/
Please reach me at Rajesh Cholleti
License is MIT