diff --git a/.gitignore b/.gitignore index 15ab5ef..e999c0f 100644 --- a/.gitignore +++ b/.gitignore @@ -37,4 +37,6 @@ override.tf.json .terraformrc terraform.rc +.terraform.lock.hcl +.terraform # End of https://www.toptal.com/developers/gitignore/api/terraform diff --git a/README.md b/README.md index ad0490c..7fedf3b 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,3 @@ -# Automate Terraform with GitHub Actions +# FediServices.nz AWS Infra -This repo is a companion repo to the [Automate Terraform with GitHub Actions tutorial](https://developer.hashicorp.com/terraform/tutorials/automation/github-actions). +This repo contains the code required to deploy status.fediservices.nz onto an EC2 instance with an EIP. diff --git a/ec2.tf b/ec2.tf index e21c15a..816c287 100644 --- a/ec2.tf +++ b/ec2.tf @@ -1,35 +1,26 @@ -# # Instance -# resource "aws_instance" "instance" { -# ami = data.aws_ami.ubuntu.id -# instance_type = "t4g.micro" -# iam_instance_profile = aws_iam_instance_profile.profile.name -# availability_zone = element(aws_subnet.subnet.*.availability_zone, 1) -# user_data = data.template_file.userdata.rendered -# subnet_id = element(aws_subnet.subnet.*.id, 1) -# key_name = var.ssh_key -# vpc_security_group_ids = [aws_security_group.sg.id] -# } +# Instance +resource "aws_instance" "instance" { + ami = data.aws_ami.ubuntu.id + instance_type = var.instance_type + iam_instance_profile = aws_iam_instance_profile.profile.name + availability_zone = element(aws_subnet.subnet.*.availability_zone, 1) + user_data = data.template_file.userdata.rendered + subnet_id = element(aws_subnet.subnet.*.id, 1) + key_name = var.ssh_key + vpc_security_group_ids = [aws_security_group.sg.id] +} -# # Elastic IP -# resource "aws_eip" "eip" { -# instance = aws_instance.instance.id -# vpc = true +# Elastic IP +resource "aws_eip" "eip" { + instance = aws_instance.instance.id + vpc = true +} -# tags = var.tags -# } - - -# # Create a new load balancer attachment -# resource "aws_elb_attachment" "attachment" { -# elb = aws_elb.lb.id -# instance = aws_instance.instance.id -# } - -# # EBS Vol for persistance -# resource "aws_ebs_volume" "instance" { -# availability_zone = element(aws_subnet.subnet.*.availability_zone, 1) -# size = "8" -# type = "gp2" -# encrypted = true -# } +# EBS Vol for persistance +resource "aws_ebs_volume" "ebs" { + availability_zone = element(aws_subnet.subnet.*.availability_zone, 1) + size = "1" + type = "gp3" + encrypted = true +} diff --git a/iam.tf b/iam.tf new file mode 100644 index 0000000..c3225ee --- /dev/null +++ b/iam.tf @@ -0,0 +1,93 @@ +resource "aws_iam_role" "role" { + name = "status" + + assume_role_policy = <