This repository contains terraform code for setting up infrastructure configurations. Terraform is a code tool from HahiCorp. It is a tool for building, changing and managing infrastructure in a safe, repeatable way. Developers and Infrastructure teams can use Terraform to mange environments with a configuration language called the HashiCorp Configuration Language (HCL) for human readable, automated deployments.
- Cloud Provider - Amazon Web Services
- CLI access setup for above account
- Terraform installed on local machine
The basic workflow steps of Terraform deployment is as follows:
- Scope - Confirm what resources need to be created for a given project.
- Author- Create the configuration file in HCL based on the scoped parameters.
- Initialize - Run
terraform initin the project directory with the configuarion files. This will download the correct provider plug-ins for the project. - Plan & Apply - Run
*terraform plan*to verify creation process and then terraform apply to create real resources as well as state file that compares future changes in your configuration files to what actually exists in your deployment environment. Upon*terraform apply*, the user will be prompted to review the proposed changes and must affirm the changes or else Terraform will not apply the proposed plan. - Destroy - The
terraform destroycommand terminates resources defined in your Terraform configuration. This command is the reverse ofterraform applyin that it terminates all the resources specified by the configuration. It does not destroy resources running elsewhere that are not described in the current configuration.Just like with apply, Terraform determines the order in which things must be destroyed.
-
To ssh into the EC2 instance ssh -i .ssh/key-pair ubuntu@ipaddress
-
To scp the file to ec2 instance scp -i ~/.ssh/key-pair /home/aditya/Desktop/csye6225spring2021/webapp.zip ubuntu@ipaddress:
-
Commands to set up MYSQL server inside the EC2 instance sudo mysql ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'insert_password'; Create schema webapp;
-
Terraform command to change workspace terraform workspace new "alpha"
-
Command to allow zsh to run shell scripts (This command is useful if bash is your default terminal chmod +x buildAMI.sh
-
The command to import certificate is as following:- aws acm import-certificate --certificate fileb://certificate_body.pem --certificate-chain fileb:// certificate_chain.pem --private-key fileb://private_key.pem where, --certificate is for certificate body, -- certificate-chain is for certificate chain that is the ca-bundle file that Comodo gives --private-key is the key the user created to generate the certificate.