WHAT TO EXPECT
In this article, users will learn how to deploy a cloudSwXtch instance on AWS using a Terraform script.
Prerequisites:
For this script to work, users will need to have already provisioned a VPC, Subnets, and SSH Keys. Those parameters must be placed into the AWS/terraform/terraform.tfvars file.
Deploying a Terraform Script
Choose which platform will be used to run Terraform. For this example, the user is on a Linux machine. Download instructions can be found at: terraform.io/downloads
Clone the repository using SSH. Please note: An SSH key will be needed to set up GitHub.
$ git clone git@github.com:swxtchio/cloudSwXtch-supportOr, alternatively, users can clone with the HTTPS URL: (here on GitHub)
$ git clone https://github.com/swxtchio/cloudSwXtch-support.gitThen:
$ cd cloudSwXtch-support/AWS/terraformUpdate the values in the AWS/terraform/terraform.tfvars file to match the existing AWS resources, such as: VPC ID, Subnet IDs, and SSH Key names.
Run terraform init inside the AWS/terraform/ directory.

For this step, the user needs to have authenticated their AWS credentials inside the console. Or the user can pass the credentials with environmental variables. One simple way to do this is using an Access Key (AK). If the user doesn't have one, they can generate their AK in Amazon's IAM->Users->(their user), on the Security Credentials tab, Access Keys. Then, they have to export the following:
$ export AWS_ACCESS_KEY_ID="anaccesskey" $ export AWS_SECRET_ACCESS_KEY="asecretkey" $ export AWS_REGION="us-west-2"Now that Terraform has been initialized and the user is authenticated, run this command to evaluate the config and confirm the desired output, which will be shown:
$ terraform plan
This is the result of running terraform plan with 2 cloudSwXtches. The provided terraform example creates a security group for all of the deployed resources: two aws_network_interface for each of the cloudSwXtches and an aws_instance for each cloudSwXtch.
Run the Terraform apply command (followed by “yes” when prompted) to approve the action.
terraform apply yes
Once the resources have been applied successfully, the user should see an output similar to this:

Users can view the resources created from the AWS portal as confirmation of a successful deployment.