To follow this tutorial you will need:
- The Terraform CLI (0.14.9+) installed.
- The AWS CLI installed.
- An AWS account.
- Your AWS credentials. You can create a new Access Key on this page.
-
Copy all your environment variables from
set_env.bash.example
fileset_env.bash
file.cp -v set_env.bash.example set_env.bash
-
Replace all AWS and Project Secrets based on your requirements in
set_env.bash
file. -
Assign exutable permission to your
set_env.bash
file.chmod +x ./set_env.bash
-
Run the
set_env.bash
scripts to update the environment variables../set_env.bash source ./set_env.bash
-
When you create a new configuration — or check out an existing configuration from version control — you need to initialize the directory with terraform init. Initializing a configuration directory downloads and installs the providers defined in the configuration, which in this case is the aws provider
terraform init
-
You can also make sure your configuration is syntactically valid and internally consistent by using
terraform validate
-
To preview the changes that Terraform plans to make to your infrastructure and store them in file.
terraform plan -out main.tf.out
-
Finally, To executes the actions proposed in a Terraform plan.
terraform apply "main.tf.out"
-
from the console output, you will recieve public ip of your EC2 instance, you can connect it via your provided ssh key or via AWS Management Console. E.g.
Outputs: instance_ip = "1.1.1.1"
-
To ensure that the planned operations are executed as expected, or to inspect the current state as Terraform sees it.
terraform show