Download Binaries here: https://www.terraform.io/downloads.html
Terraform is distributed as a single binary. Install Terraform by unzipping it and moving it to a directory included in your system's PATH .
For this example aws
is used as a provider (see main.tf
provider resource).
You can use any provider of your choice. An overview of all providers you can see here: https://www.terraform.io/docs/providers/index.html
If you change the provider, please be sure to subsequently change the resources, as well!
There are multiple ways to use your cloud provider's credentials. More information can be found here: https://www.terraform.io/docs/providers/aws/index.html
For example:
- using hard coded credentials: https://www.terraform.io/docs/providers/aws/index.html#static-credentials
Need to update the provider ressource inmain.tf
- using environment variables: https://www.terraform.io/docs/providers/aws/index.html#environment-variables
I used this in combination with the profile provided by the AWS CLI,
by usingAWS_PROFILE=<my_aws_cli_profile> terraform <command>
- navigate into the directory
s3-static-website
- initialise Terraform provider with
terraform init
- [optional] using
terraform validate
to check if the scripts are valid - planning your infrastructure using the variables file via
terraform plan -var-file=variables.tfvars
- if your are happy with your plan, apply
terraform apply -var-file=variables.tfvars
- Side note: with
terraform apply -auto-approve [...]
you can skip the additional input after the planning step
- Side note: with
- if you are tired of your infrastructure you can run
terraform destroy -var-file=variables.tfvars
- Side note: with
terraform destroy -auto-approve [...]
you can skip the additional input after the planning step
- Side note: with
Feel free to contact me in case of questions. 👋
🐤 (aka Twitter): @wolkencode
📧 schille.nora@gmail.com or nora.schille@codecamp-n.com