https://github.com/swisscom/terraform-dcs-demo
This repo contains sample infrastructure as code snippets to deploy, maintain and manage infrastructure on DCS using Terraform vCloud Director provider.
https://github.com/swisscom/terraform-dcs-demo
Last synced: 3 months ago
JSON representation
This repo contains sample infrastructure as code snippets to deploy, maintain and manage infrastructure on DCS using Terraform vCloud Director provider.
- Host: GitHub
- URL: https://github.com/swisscom/terraform-dcs-demo
- Owner: swisscom
- License: apache-2.0
- Created: 2019-09-30T14:00:16.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2024-10-16T15:40:10.000Z (over 1 year ago)
- Last Synced: 2025-03-04T22:02:06.600Z (over 1 year ago)
- Language: HCL
- Size: 15.6 KB
- Stars: 5
- Watchers: 23
- Forks: 4
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# DCS Infrastructure as code with Terraform
## Introduction
This repo contains sample infrastructure as code snippets to deploy, maintain and manage infrastructure on DCS using Terraform [vCloud Director](https://www.terraform.io/docs/providers/vcd/index.html) provider.
[Terraform](https://www.terraform.io/) enables you to safely and predictably create, change, and improve infrastructure. It is an open source tool that codifies APIs into declarative configuration files that can be shared amongst team members, treated as code, edited, reviewed, and versioned.
[Download](https://www.terraform.io/downloads.html) Terraform based on your operating system to execute terraform code and plans.
Install Terraform by unzipping it and moving it to a directory included in your system's [PATH](https://superuser.com/questions/284342/what-are-path-and-other-environment-variables-and-how-can-i-set-or-use-them).
## How to use this Module
* Make sure that you have DCS contract and have your Contract Number/Pro-Number ready.
* Create vCloud Director API User from DCS Self Service Portal.
* Create Dynamic Data Center from DCS Self Service Portal.
#### What are these different files
1. **config-values.tfvars**
This file is to pass configuration values to the terraform apply/destroy commands instead of passing values manually.
**Edit this file by exchanging the values as per your DCS environment setup**.
1. **main.tf**
This file is to define terraform provider for [vCloud Director](https://github.com/terraform-providers/terraform-provider-vcd).
1. **variables.tf**
This file defines all the needed variables that are referenced in this sample terraform script.
1. **dcs-terraform-basic-sample.tf**
This sample terraform script shows how terraform can be used to write infrastructure as code in DCS with vCloud Director. This particular example will create a vDC Network,vApp and VM attached to the network.
#### Quick Start
1. Open your shell change directory to `\terraform-dcs-demo` and execute `terraform init` it will download vCloud Director provider and initialize terraform.
1. Run `terraform validate` to make sure the configuration is valid.
1. Run `terraform apply -var-file="config-values.tfvars"` to apply the changes required to reach the desired state of the configuration. This will start deploying resources in your DCS contract.
1. Run `terraform destroy -var-file="config-values.tfvars"` Infrastructure managed by Terraform will be destroyed. This will ask for confirmation before destroying. This will start destroying resources managed by Terraform in your DCS contract.
## References
[Terraform](https://www.terraform.io/)
[Download Terraform](https://www.terraform.io/downloads.html)
[vCloud Director Terraform Provider](https://github.com/terraform-providers/terraform-provider-vcd)
[Getting Started with Terraform](https://learn.hashicorp.com/terraform/getting-started/install)