Terraform is an infrastructure-as-code provisioning tool comprised of the Terraform language and the Terraform CLI. It lets you treat all parts of operations like software - defining, creating, updating, and destroying your infrastructure with code.
- Written in Go
- Language is declarative, meaning your configurations describe your desired end state, not the steps necessary to get there. Terraform handles the underlying logic of figuring out how to get to the end state by creating a graph of resource dependencies and using that to determine the correct order to make changes.
- Terraform generally takes an immutable infrastructure approach, meaning once something is created, it doesn't get changed. Any changes needed are generally made by destroying the existing resource and recreating it with the desired configuration.
- Allows you to automate your provisioning workflows. This allows for less human errors, speeds up how long it takes to provision new infrastructure, and makes things more consistent.
- Defines infrastruture in human-readable configuration files that can be put in version control. Once in version control, you can run tests, do code reviews, and track changes over time.
- Enables reused through composable modules.
- Supports encoding security and other standards as code so you can have consistently applied policies across all of your infrastruture.
- Write
- Make sure you have Terraform installed.
- Make sure Terraform is working by running
terraform -version
. You can see other commands avaialble withterraform -help
- Clone this repository and navigate into the
firehydrant-configuration
directory. You should see 3 files in this directory: main.tf, variables.tf, and outputs.tf. - Generate a bot token for yourself in FireHydrant and export it to the environment variable TF_VAR_firehydrant_api_key
export TF_VAR_firehydrant_api_key=YOUR_BOT_TOKEN_HERE
- Export a unique prefix to the environment variable TF_VAR_resource_prefix (ideally something like your name, with only alphanumeric characters)
This will help make sure the resources you create don't conflict with anyone else's.
export TF_VAR_resource_prefix=YOUR_CHOSEN_PREFIX_HERE
- Get the IDs for
data-source-service
,data-source-functionality
, anddata-source-environment
fron the FireHydrant UI and add them to your main.tf file under theData Sources
section. - Run
terraform init
to download any necessary providers needed to work with your configuration. - Run
terraform fmt
to automatically format your configuration with the standard Terraform style. - Run
terraform validate
to check whether your current configuration is valid.
- Plan
- Run
terraform plan
. This will show a preview of everything that will be created if your runterraform apply
with your current configuration.
- Run
- Apply
- Run
terraform apply
. This will generate another plan and ask for your approval before creating anything. Type 'yes' and then look in the FireHydrant UI to see your applied changes. - Update your configuration by changing the attributes of a few resources. Save your changes.
- Run
terraform apply
again. This will generate another plan and ask for your approval before changing anything. Type 'yes' and then look in the FireHydrant UI to see your applied changes. - Run
terraform destroy
. This will generate another plan and ask for your approval before destroying anything. Type 'yes' and then look in the FireHydrant UI to see that everything .
- Run