A easy way project about how you can provision an EC2 instance using local-exec
command to get private IP with output
on Terraform.
These examples deploy resources into your AWS account. Although all the resources should fall under the AWS Free Tier, it is not me responsibility if you are charged money for this.
$ tree
.
├── README.md
├── backend.tf
├── instance.tf
├── output.tf
├── private_ips.txt
├── terraform.tfstate
├── terraform.tfstate.backup
├── variables.tf
└── versions.tf
0 directories, 9 files
To use Terraform you will need to install it. HashiCorp distributes Terraform as a binary package. You can also install Terraform using popular package managers.
- Install
yum-config-manager
to manage your repositories.
$ sudo yum install -y yum-utils
- Use
yum-config-manager
to add the official HashiCorp Linux repository.
$ sudo yum-config-manager --add-repo https://rpm.releases.hashicorp.com/RHEL/hashicorp.repo
- Install:
$ sudo yum -y install terraform
- Make sure you have visited the Terraform documentation before to start.
- Set your AWS credentials as the environment variables
AWS_ACCESS_KEY_ID
andAWS_SECRET_ACCESS_KEY
. - Go to your Terraform project folder.
- Run
terraform init
. - Run
terraform-plan
. - Run
terraform-apply
- To clean up and delete all resources after you're done, run
terraform destroy
.
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.
Please make sure to update tests as appropriate.