Working with Ansible Code
After cloning the ansible code from the Release package, perform the below steps:
Navigate to infra/terraform/environments.
Add the default SSH key to /default-user-data.yaml.
Important
Without adding the SSH key, you cannot execute Terraform.
cd ~/infra/terraform/environments/dev vi main.tf
If you want to create a bucket, then add the below code block to the main.tf and change the bucket name accordingly. Ensure that bucket name is unique.
resource "aws_s3_bucket" "global_unique_bucket_name" { bucket = "global_unique_bucket_name" versioning { enabled = true
Note
If you have a bucket created already, then no need of adding the code block.
Modify the bucket name, key, and Security Group.
Add Cluster Number and Instance Type in the Module.
Change the name and cluster size details as required.
Edit or update the variables in the Makefile (TF_VAR_region and TF_VAR_username) as per the requirement.
Ensure that the parameter “backend-config=key=” contains $(TF_VAR_username) and other required variables (refer to the above step).
Remove .terraform from ~/infra/terraform/envrionment/dev/ (if exists).
cd ~/infra/terraform/envrionment/dev/
Run makeinit from ~/infra/terraform/envrionment/dev.
Run makeplan from ~/infra/terraform/envrionment/dev.
Note
Ensure that there are no instances getting destroyed. If any instance is destroyed, modify the main.tf file and add respective cluster name details.
~/infra/terraform/envrionment/dev/make apply
Important
Before proceeding with makeapply, ensure that no existing environment is destroyed. If any such messages arise, add all the instance details to main.tf file.