This builds an AWS Infrastructure with networking and compute instance using terraform. Ansible is integrated to deploy a nginx docker container on the instance
Terraform version 1 or above
Ansible version 2.9 or above
Community Docker installed (can be done using below command)
ansible-galaxy collection install community.docker| Name | Version |
|---|---|
| aws | 4.19.0 |
| http | 2.2.0 |
- Clone the github repository
- Change terraform.tfvars.example to terraform.tfvars and provide the variable values.
- Run the below to initialize terraform
terraform init
- Run a plan followed by an apply
terraform plan terraform apply
| Name | Type |
|---|---|
| aws_instance.awsvm | resource |
| aws_internet_gateway.gw | resource |
| aws_key_pair.ec2_key | resource |
| aws_network_acl.nacl | resource |
| aws_route.default_rt | resource |
| aws_route_table.public_rt | resource |
| aws_route_table_association.public_assoc | resource |
| aws_security_group.allow_http_ssh | resource |
| aws_subnet.pubsubnet | resource |
| aws_vpc.main | resource |
| aws_ami.ec2-ami | data source |
| http_http.my_public_ip | data source |
| Name | Description | Type | Default | Required |
|---|---|---|---|---|
| aws_region | n/a | string |
"us-east-1" |
no |
| dns_hostnames | n/a | bool |
true |
no |
| instance_tenancy | n/a | string |
"default" |
no |
| instance_type | Ec2 instance type | string |
"t2.small" |
no |
| key_name | n/a | any |
n/a | yes |
| name | Name of the resource | any |
n/a | yes |
| private_key_path | n/a | any |
n/a | yes |
| public_key_path | n/a | any |
n/a | yes |
| ssh_user | n/a | string |
"ubuntu" |
no |
| vpc_cidr | Enter a cidr block in /16 subnet | string |
"10.0.0.0/16" |
no |
| Name | Description |
|---|---|
| ec2_public_ip | PUBLIC IP |
| vpc_id | VPC ID |