diff --git a/app_server/LICENSE b/app_server/LICENSE new file mode 100644 index 0000000..51fca54 --- /dev/null +++ b/app_server/LICENSE @@ -0,0 +1,11 @@ +Licensed under the Apache License, Version 2.0 (the "License"); +you may not use this file except in compliance with the License. +You may obtain a copy of the License at + + http://www.apache.org/licenses/LICENSE-2.0 + +Unless required by applicable law or agreed to in writing, software +distributed under the License is distributed on an "AS IS" BASIS, +WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +See the License for the specific language governing permissions and +limitations under the License. diff --git a/app_server/README.md b/app_server/README.md new file mode 100644 index 0000000..2a8ece5 --- /dev/null +++ b/app_server/README.md @@ -0,0 +1,3 @@ +# AWS app server + +This module provisions an AWS instance configured application website hosting. diff --git a/app_server/main.tf b/app_server/main.tf new file mode 100644 index 0000000..4f14fe8 --- /dev/null +++ b/app_server/main.tf @@ -0,0 +1,38 @@ +provider "aws" { + region = var.region +} + +module "ec2" { + source = "../.." + +} + +variable "server_name" { + default = "" +} + +variable "region" { + default = "" +} +resource "aws_instance" "app_server" { + ami = data.aws_ami.amazon_linux.id + instance_type = "t2.micro" + + tags = { + Name = var.server_name + } +} + +data "aws_ami" "amazon_linux" { + most_recent = true + + owners = ["amazon"] + + filter { + name = "name" + + values = [ + "amzn-ami-hvm-*-x86_64-gp2", + ] + } +} diff --git a/app_server/outputs.tf b/app_server/outputs.tf new file mode 100644 index 0000000..4ef8885 --- /dev/null +++ b/app_server/outputs.tf @@ -0,0 +1,11 @@ +# Output variable definitions + +output "arn" { + description = "ARN of the server" + value = aws_instance.app_server.arn +} + +output "server_name" { + description = "Name (id) of the sever" + value = aws_instance.app_server.id +} diff --git a/app_server/terraform.tfvars b/app_server/terraform.tfvars new file mode 100644 index 0000000..e7193ae --- /dev/null +++ b/app_server/terraform.tfvars @@ -0,0 +1,6 @@ +region = "us-east-2" + +server_name = "example_app_server" + + +