Terraform to build some resources with module

Job ID: 31380728

Budget: £10 – £15 GBP

Create a small terraform module that generates:

N ec2 instances
A security group that provides access to port 22 from a variable ip
N Elastic IP addresses if the input boolean is set to true
Implementation details:

If enabled, link each elastic IP to an instance.
Assign the sg to each instance
user-data should be read from a file defined as input
Compose the name of every object from a static part and an input variable called "tenant" (p.e. Ec2-1 instance name: tenant-instance-1)
Module inputs:

IP address for the security group
A variable called "tenant" to compose resources names
Number of instances
Boolean to create Elastic IPs or not (defaults to false)
User data file location
Module ouputs:

Each instance public IP (either the assinged public IP or the elastic IP)
Security group ID
Related categories: Linux DNS Amazon Web Services