thilinapiy / terraform-sample

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Terraform Sample

Prerequisites

  • Terraform >= v1.0.0
  • AWS access key and secret key with proper permissions
  • AWS EC2 Key-pair

How to deploy to an AWS region

Copy example.tfvars file to .auto.tfvars and update following details.

access_key="XXXXXXXXXXXXXXXX"
secret_key="XXXXXXXXXXXXXXXXXXXXXXXXXXXX"
region="ap-southeast-2"
ssh_key_name="nginx-key-pair"

Run following terraform commands to deploy to AWS.

terraform init
terraform plan
terraform apply

If all went well you will see something like this;

Outputs:

azs = tolist([
  "ap-southeast-2a",
])
nginx_public_ip = [
  "54.253.48.63",
]
public_subnets = [
  "subnet-0abd6e0a666bc29bf",
]
security_group_id = "sg-04aa1307f9f6b974a"
security_group_name = "nginx-20210812080402834000000001"
vpc_cidr_block = "10.0.0.0/16"
vpc_id = "vpc-06bead6afcc389f38"

Accessing Nginx

You can use the nginx_public_ip to access the Nginx instance. Note that the installations in EC2 instance can take a minute or two.

http://54.253.48.63

Accessing resource log

Resource log is available in the following URL.

http://54.253.48.63/resource.html

Accessing search rest API

Search API is available in the following URL.

http://54.253.48.63:8080/search/<query>
http://54.253.48.63:8080/search/nginx

Know limitations

  • No high availability or scalability options
  • Communication happens over insecure http over the Internet
  • Instance is directly exposed to the Internet without multiple layers of security
  • Rest API is not proxy via the Nginx
  • No log management, monitoring or data retention

About


Languages

Language:HCL 57.6%Language:Shell 32.7%Language:Python 9.7%