diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..7a3e2fd --- /dev/null +++ b/.gitignore @@ -0,0 +1,29 @@ +# Local .terraform directories +**/.terraform/* + +# .tfstate files +*.tfstate +*.tfstate.* + +# Crash log files +crash.log + +# Ignore any .tfvars files that are generated automatically for each Terraform run. Most +# .tfvars files are managed as part of configuration and so should be included in +# version control. +# +# example.tfvars + +# Ignore override files as they are usually used to override resources locally and so +# are not checked in +override.tf +override.tf.json +*_override.tf +*_override.tf.json + +# Include override files you do wish to add to version control using negated pattern +# +# !example_override.tf + +# Include tfplan files to ignore the plan output of command: terraform plan -out=tfplan +# example: *tfplan* diff --git a/ec2.tf b/ec2.tf index f55bdd8..e69de29 100644 --- a/ec2.tf +++ b/ec2.tf @@ -1,24 +0,0 @@ -terraform { - required_providers { - aws = { - source = "hashicorp/aws" - version = "~> 3.27" - } - } - - required_version = ">= 0.14.9" -} - -provider "aws" { - profile = "default" - region = "us-west-2" -} - -resource "aws_instance" "app_server" { - ami = "ami-830c94e3" - instance_type = "t2.micro" - - tags = { - Name = "ExampleAppServerInstance" - } -} diff --git a/ec2_child_module/.terraform.lock.hcl b/ec2_child_module/.terraform.lock.hcl new file mode 100644 index 0000000..e7a7344 --- /dev/null +++ b/ec2_child_module/.terraform.lock.hcl @@ -0,0 +1,24 @@ +# This file is maintained automatically by "terraform init". +# Manual edits may be lost in future updates. + +provider "registry.terraform.io/hashicorp/aws" { + version = "4.45.0" + hashes = [ + "h1:J/XjRsEJIpxi+mczXQfnH3nvfACv3LRDtrthQJCIibY=", + "zh:22da03786f25658a000d1bcc28c780816a97e7e8a1f59fff6eee7d452830e95e", + "zh:2543be56eee0491eb0c79ca1c901dcbf71da26625961fe719f088263fef062f4", + "zh:31a1da1e3beedfd88c3c152ab505bdcf330427f26b75835885526f7bb75c4857", + "zh:4409afe50f225659d5f378fe9303a45052953a1219f7f1acc82b69d07528b7ba", + "zh:4dadec3b783f10d2f8eef3dab5e817baae9c932a7967d45fe3d77fcbcbdaa438", + "zh:55be80d6e24828dcb0db7a0226fb275415c1c0ad63dd2f33b76f3ac0cd64e6a6", + "zh:560bba29efb7dbe0bfcc937369d88817aa31a8d18aa25395b1afe2576cb04495", + "zh:6caacc202e83438ff63d5d96733e283f44e349668d96c6b1c5c7df463ebf85cc", + "zh:6cabab83a61d5b4ac801c5a5d57556a0e76ec8dc879d28cf777509db5f6a657e", + "zh:96c4528bf9c16edb8841b68479ec51c499ed7fa680462fa28caeab3fc168bb43", + "zh:9b12af85486a96aedd8d7984b0ff811a4b42e3d88dad1a3fb4c0b580d04fa425", + "zh:cdc0b47ff840d708fbf75abfe86d23dc7f1dffdd233a771822a17b5c637f4769", + "zh:d9a9583e82776d1ebb6cf6c3d47acc2b302f8778f470ceffe7579dc794eb1feb", + "zh:e9367ca9f6f6418a23cdf8d01f29dd0c4f614e78499f52a767a422e4c334b915", + "zh:f6d355a2fb3bcebb597f68bbca4fa2aaa364efd29240236c582375e219d77656", + ] +} diff --git a/ec2_child_module/child_main.tf b/ec2_child_module/child_main.tf new file mode 100644 index 0000000..e87a317 --- /dev/null +++ b/ec2_child_module/child_main.tf @@ -0,0 +1,8 @@ +resource "aws_instance" "wk21" { + ami = "ami-0b0dcb5067f052a63" + instance_type = "t2.micro" + + tags = { + Name = "MyInstance" + } +} diff --git a/ec2_child_module/child_variables.tf b/ec2_child_module/child_variables.tf new file mode 100644 index 0000000..01adde2 --- /dev/null +++ b/ec2_child_module/child_variables.tf @@ -0,0 +1,10 @@ +variable "ami" { + type = string + default = "ami-0b0dcb5067f052a63" +} + +variable "instance_type" { + type = string + default = "t2.micro" +} + diff --git a/main.tf b/main.tf new file mode 100644 index 0000000..ca8223e --- /dev/null +++ b/main.tf @@ -0,0 +1,3 @@ +module "ec2_child_module" { + source = "./ec2_child_module" +} diff --git a/providers.tf b/providers.tf new file mode 100644 index 0000000..208412c --- /dev/null +++ b/providers.tf @@ -0,0 +1,13 @@ +terraform { + required_providers { + aws = { + source = "hashicorp/aws" + version = "~> 4.0" + } + } +} + +provider "aws" { + profile = "default" + region = "us-east-1" +}