This repository contains Terraform configuration files to set up cloud infrastructure for the Cloud Automation project. The Terraform files are located in the tf_files
directory. This README will guide you through the process of running Terraform to create, modify, and destroy cloud resources.
-
Install Terraform: To work with Terraform, you need to have it installed on your local machine. Visit the official Terraform download page and follow the instructions for your operating system.
-
Configure cloud provider credentials: Terraform uses provider-specific credentials to authenticate and interact with the cloud provider. Make sure you have the necessary credentials configured. The
tf_files
directory contains multiple subdirectories for different cloud providers (e.g.,aws
,gcp
). Check the provider-specific documentation for instructions on configuring credentials.
-
Clone the repository:
git clone https://github.com/uc-cdis/gen3-terraform.git
-
Navigate to the
tf_files
directory:cd gen3-terraform/tf_files
-
Choose the appropriate subdirectory for your cloud provider (e.g.,
aws
,gcp
). In this example, we will use theaws
directory:cd aws
-
Initialize Terraform:
terraform init
This command downloads the necessary provider plugins and sets up the backend for storing the Terraform state.
-
Create a new Terraform workspace (optional):
terraform workspace new my_workspace
This step is optional but recommended if you plan to manage multiple environments or if you're collaborating with others.
-
Review the Terraform plan:
terraform plan
This command shows a summary of the changes that Terraform will apply to your cloud resources.
-
Apply the Terraform configuration:
terraform apply
This command prompts you to confirm that you want to apply the changes and then proceeds to create, update, or delete cloud resources as needed.
-
Verify the infrastructure:
Check your cloud provider's management console or CLI to verify that the resources have been created or modified as expected.
-
Destroy the infrastructure:
terraform destroy
This command removes all resources created by Terraform.
-
Delete the Terraform workspace (if created earlier):
terraform workspace select default terraform workspace delete my_workspace
-
Remove the
.terraform
directory and any generated.tfstate
files.
If you encounter any issues while working with Terraform, refer to the official Terraform documentation and the cloud provider's documentation for help.
Contributions to improve or extend the Terraform configurations in this repository are welcome! Please submit a pull request or open an issue to discuss any changes you would like to make.