From e2e098340466d81a62f6fcea3a97279ba6da7739 Mon Sep 17 00:00:00 2001 From: Greg Hendrickson Date: Thu, 16 Nov 2023 15:15:01 -0800 Subject: [PATCH 01/17] add updates to all in aws_simple --- .gitignore | 5 ++ aws/aws_simple/ec2/variables.tf | 13 ----- aws/aws_simple/main.tf | 41 ++++++++++------ aws/aws_simple/{ => modules}/ec2/ec2.tf | 43 ++++++++++------ aws/aws_simple/modules/ec2/outputs.tf | 4 ++ .../{ => modules}/ec2/terraform.tfvars | 0 aws/aws_simple/{ => modules}/ec2/user-data.sh | 5 +- aws/aws_simple/modules/ec2/variables.tf | 49 +++++++++++++++++++ aws/aws_simple/{ => modules}/efs/main.tf | 0 aws/aws_simple/{ => modules}/elb/main.tf | 0 aws/aws_simple/modules/vpc/outputs.tf | 3 ++ .../modules/vpc/subnets/us-east/outputs.tf | 16 ++++++ .../vpc/subnets/us-east/subnets-east.tf | 15 ++++-- .../vpc/subnets/us-east/terraform.tfvars | 0 .../vpc/subnets/us-east/variables.tf | 5 ++ .../modules/vpc/subnets/us-west/outputs.tf | 16 ++++++ .../vpc/subnets/us-west/subnets-west.tf | 7 ++- .../vpc/subnets/us-west/terraform.tfvars | 1 - .../vpc/subnets/us-west/variables.tf | 5 ++ aws/aws_simple/modules/vpc/terraform.tfvars | 8 +++ aws/aws_simple/modules/vpc/variables.tf | 33 +++++++++++++ aws/aws_simple/{ => modules}/vpc/vpc.tf | 22 ++++----- aws/aws_simple/terraform.tfvars | 4 +- aws/aws_simple/vpc/terraform.tfvars | 2 - aws/aws_simple/vpc/variables.tf | 4 -- 25 files changed, 225 insertions(+), 76 deletions(-) create mode 100644 .gitignore delete mode 100644 aws/aws_simple/ec2/variables.tf rename aws/aws_simple/{ => modules}/ec2/ec2.tf (67%) create mode 100644 aws/aws_simple/modules/ec2/outputs.tf rename aws/aws_simple/{ => modules}/ec2/terraform.tfvars (100%) rename aws/aws_simple/{ => modules}/ec2/user-data.sh (56%) create mode 100644 aws/aws_simple/modules/ec2/variables.tf rename aws/aws_simple/{ => modules}/efs/main.tf (100%) rename aws/aws_simple/{ => modules}/elb/main.tf (100%) create mode 100644 aws/aws_simple/modules/vpc/outputs.tf create mode 100644 aws/aws_simple/modules/vpc/subnets/us-east/outputs.tf rename aws/aws_simple/{ => modules}/vpc/subnets/us-east/subnets-east.tf (77%) rename aws/aws_simple/{ => modules}/vpc/subnets/us-east/terraform.tfvars (100%) rename aws/aws_simple/{ => modules}/vpc/subnets/us-east/variables.tf (84%) create mode 100644 aws/aws_simple/modules/vpc/subnets/us-west/outputs.tf rename aws/aws_simple/{ => modules}/vpc/subnets/us-west/subnets-west.tf (86%) rename aws/aws_simple/{ => modules}/vpc/subnets/us-west/terraform.tfvars (99%) rename aws/aws_simple/{ => modules}/vpc/subnets/us-west/variables.tf (84%) create mode 100644 aws/aws_simple/modules/vpc/terraform.tfvars create mode 100644 aws/aws_simple/modules/vpc/variables.tf rename aws/aws_simple/{ => modules}/vpc/vpc.tf (77%) delete mode 100644 aws/aws_simple/vpc/terraform.tfvars delete mode 100644 aws/aws_simple/vpc/variables.tf diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..2462613 --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +aws/aws_simple/.terraform.lock.hcl +aws/aws_simple/.terraform/modules/modules.json +aws/aws_simple/terraform.tfstate.backup +aws/aws_simple/terraform.tfstate +aws/aws_simple/.terraform/providers/registry.terraform.io/hashicorp/aws/5.25.0/linux_amd64/terraform-provider-aws_v5.25.0_x5 diff --git a/aws/aws_simple/ec2/variables.tf b/aws/aws_simple/ec2/variables.tf deleted file mode 100644 index ad092af..0000000 --- a/aws/aws_simple/ec2/variables.tf +++ /dev/null @@ -1,13 +0,0 @@ - -# Define variables -variable "min_size" { - type = number - description = "Minimum number of instances in the Auto Scaling Group" - default = 1 -} - -variable "max_size" { - type = number - description = "Maximum number of instances in the Auto Scaling Group" - default = 1 -} diff --git a/aws/aws_simple/main.tf b/aws/aws_simple/main.tf index 7c01d7a..ecd4bc0 100644 --- a/aws/aws_simple/main.tf +++ b/aws/aws_simple/main.tf @@ -1,34 +1,43 @@ # Define provider provider "aws" { region = var.aws_region - access_key = var.aws_access_key - secret_key = var.aws_secret_key } # Define modules -module "vpc_us_west" { +module "vpc_us" { source = "./modules/vpc" + + us_east_subnet_1_id = module.subnets_us_east.us_east_subnet_1_id + us_east_subnet_2_id = module.subnets_us_east.us_east_subnet_2_id + us_east_subnet_3_id = module.subnets_us_east.us_east_subnet_3_id + + us_west_subnet_1_id = module.subnets_us_west.us_west_subnet_1_id + us_west_subnet_2_id = module.subnets_us_west.us_west_subnet_2_id + us_west_subnet_3_id = module.subnets_us_west.us_west_subnet_3_id } -module "subnet_us_west" { - source = "./modules/subnet" - vpc_id = module.vpc_us_west.vpc_id - region = "us-west-2" +module "subnets_us_west" { + source = "./modules/vpc/subnets/us-west" + vpc_id = module.vpc_us.vpc_id } -module "vpc_us_east" { - source = "./modules/vpc" - region = "us-east-1" -} - -module "subnet_us_east" { - source = "./modules/subnet" - vpc_id = module.vpc_us_east.vpc_id - region = "us-east-1" +module "subnets_us_east" { + source = "./modules/vpc/subnets/us-east" + vpc_id = module.vpc_us.vpc_id } module "ec2" { source = "./modules/ec2" + + us_east_subnet_1_id = module.subnets_us_east.us_east_subnet_1_id + us_east_subnet_2_id = module.subnets_us_east.us_east_subnet_2_id + us_east_subnet_3_id = module.subnets_us_east.us_east_subnet_3_id + + us_west_subnet_1_id = module.subnets_us_west.us_west_subnet_1_id + us_west_subnet_2_id = module.subnets_us_west.us_west_subnet_2_id + us_west_subnet_3_id = module.subnets_us_west.us_west_subnet_3_id + + vpc_id = module.vpc_us.vpc_id } module "elb" { diff --git a/aws/aws_simple/ec2/ec2.tf b/aws/aws_simple/modules/ec2/ec2.tf similarity index 67% rename from aws/aws_simple/ec2/ec2.tf rename to aws/aws_simple/modules/ec2/ec2.tf index 1245e58..96743ff 100644 --- a/aws/aws_simple/ec2/ec2.tf +++ b/aws/aws_simple/modules/ec2/ec2.tf @@ -1,40 +1,36 @@ # Define the VPC and subnets data sources data "aws_vpc" "vpc" { - id = data.aws_subnet.subnet1.vpc_id -} - -module "vpc_subnets" { - source = "../vpc/subnets" + id = var.vpc_id } data "aws_subnet" "subnet1" { - id = module.vpc_subnets.subnet_ids[0] + id = var.us_east_subnet_1_id } data "aws_subnet" "subnet2" { - id = module.vpc_subnets.subnet_ids[1] + id = var.us_east_subnet_2_id } data "aws_subnet" "subnet3" { - id = module.vpc_subnets.subnet_ids[2] + id = var.us_east_subnet_3_id } data "aws_subnet" "subnet4" { - id = module.vpc_subnets.subnet_ids[3] + id = var.us_west_subnet_1_id } data "aws_subnet" "subnet5" { - id = module.vpc_subnets.subnet_ids[4] + id = var.us_west_subnet_2_id } data "aws_subnet" "subnet6" { - id = module.vpc_subnets.subnet_ids[5] + id = var.us_west_subnet_3_id } # Create a security group for the EC2 instance resource "aws_security_group" "instance" { name_prefix = "instance-" - vpc_id = data.aws_vpc.vpc.id + vpc_id = var.vpc_id ingress { from_port = 80 @@ -73,9 +69,23 @@ resource "aws_launch_configuration" "lc" { resource "aws_autoscaling_group" "asg" { name_prefix = "asg-" launch_configuration = aws_launch_configuration.lc.id + depends_on = [ + var.vpc_id, + aws_launch_configuration.lc, + data.aws_subnet.subnet1, + data.aws_subnet.subnet2, + data.aws_subnet.subnet3, + data.aws_subnet.subnet4, + data.aws_subnet.subnet5, + data.aws_subnet.subnet6 + ] vpc_zone_identifier = [ data.aws_subnet.subnet1.id, - data.aws_subnet.subnet2.id + data.aws_subnet.subnet2.id, + data.aws_subnet.subnet3.id, + data.aws_subnet.subnet4.id, + data.aws_subnet.subnet5.id, + data.aws_subnet.subnet6.id ] min_size = var.min_size max_size = var.max_size @@ -90,7 +100,8 @@ resource "aws_autoscaling_group" "asg" { } } -# Output the instance public IP address -output "public_ip" { - value = aws_autoscaling_group.asg.instances[0].public_ip +data "aws_instances" "asg_instances" { + instance_tags = { + "aws:autoscaling:groupName" = aws_autoscaling_group.asg.name + } } diff --git a/aws/aws_simple/modules/ec2/outputs.tf b/aws/aws_simple/modules/ec2/outputs.tf new file mode 100644 index 0000000..d5f2320 --- /dev/null +++ b/aws/aws_simple/modules/ec2/outputs.tf @@ -0,0 +1,4 @@ +# output "public_ips" { +# description = "Public IP addresses of the instances in the Auto Scaling group" +# value = [for i in data.aws_instances.asg_instances.ids : aws_instance[i].public_ip] +# } \ No newline at end of file diff --git a/aws/aws_simple/ec2/terraform.tfvars b/aws/aws_simple/modules/ec2/terraform.tfvars similarity index 100% rename from aws/aws_simple/ec2/terraform.tfvars rename to aws/aws_simple/modules/ec2/terraform.tfvars diff --git a/aws/aws_simple/ec2/user-data.sh b/aws/aws_simple/modules/ec2/user-data.sh similarity index 56% rename from aws/aws_simple/ec2/user-data.sh rename to aws/aws_simple/modules/ec2/user-data.sh index 73a1be4..bb81c28 100644 --- a/aws/aws_simple/ec2/user-data.sh +++ b/aws/aws_simple/modules/ec2/user-data.sh @@ -16,7 +16,8 @@ sudo chmod 600 /home/greg/.ssh/authorized_keys sudo chown -R greg:greg /home/greg/.ssh # Add your public key to authorized_keys -sudo echo "YOUR_PUBLIC_KEY" >> /home/greg/.ssh/authorized_keys +sudo echo "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCdOF80z0piQEnYzNCu2OGvOJdm7+3wfDuiC+Jzi8VbSC5VW4iJAQXOuDNGLzyqNi6uMjI77xpEL6Xzn29uJiQti6Y/LxhOZwNNIQiGUpFco1wkBYeBFbtgHQxsMLwumrxQGEj2fyCiSrACAPyy/l1fP4mlN7abBGD5aozBrYKxXPS/kfwO5nsWmw27RgTzfHJzie2dUU3ew/kd7td3wEdWrRXq8wNbu+yvAyiog54huUUWmYZwY3QVwXr6R1wsVudawM6BEl45QFq+hdB4t83azHG94XLy2NCAncohdU7zP40nsbvIDyh+4wIKeU90z6TLrXfHUYuBT6/ky7qOFm/Ym1QG4zCDz3jin8Qoa31PGaObzj/zoMJXgOXKcp16W0j9SZAenvnSfuWUEfBR1yBRR0T5Wg5v1vi7KGBTATaz8el802uliL+yZbGtMbNpAPGR5nK5C4yorf8yVYvIgo/LJaWCDND2O1e2mdut1WyRmvIwMnq7PFZT8zAsgGXfhDM= greg@ligma +" >> /home/greg/.ssh/authorized_keys # Set hostname INSTANCE_ID=$(curl -s http://169.254.169.254/latest/meta-data/instance-id) @@ -25,4 +26,4 @@ HOSTNAME="$INSTANCE_ID-$AVAILABILITY_ZONE" sudo hostnamectl set-hostname $HOSTNAME # Run cloud-init.sh script -sudo sh /path/to/cloud-init.sh +# sudo sh /path/to/cloud-init.sh diff --git a/aws/aws_simple/modules/ec2/variables.tf b/aws/aws_simple/modules/ec2/variables.tf new file mode 100644 index 0000000..6092172 --- /dev/null +++ b/aws/aws_simple/modules/ec2/variables.tf @@ -0,0 +1,49 @@ + +# Define variables +variable "min_size" { + type = number + description = "Minimum number of instances in the Auto Scaling Group" + default = 1 +} + +variable "max_size" { + type = number + description = "Maximum number of instances in the Auto Scaling Group" + default = 1 +} + + +variable "us_east_subnet_1_id" { + description = "The ID of the first US East subnet" + type = string +} + +variable "us_east_subnet_2_id" { + description = "The ID of the second US East subnet" + type = string +} + +variable "us_east_subnet_3_id" { + description = "The ID of the third US East subnet" + type = string +} + +variable "us_west_subnet_1_id" { + description = "The ID of the first US West subnet" + type = string +} + +variable "us_west_subnet_2_id" { + description = "The ID of the second US West subnet" + type = string +} + +variable "us_west_subnet_3_id" { + description = "The ID of the third US West subnet" + type = string +} + +variable "vpc_id" { + description = "The ID of the VPC" + type = string +} \ No newline at end of file diff --git a/aws/aws_simple/efs/main.tf b/aws/aws_simple/modules/efs/main.tf similarity index 100% rename from aws/aws_simple/efs/main.tf rename to aws/aws_simple/modules/efs/main.tf diff --git a/aws/aws_simple/elb/main.tf b/aws/aws_simple/modules/elb/main.tf similarity index 100% rename from aws/aws_simple/elb/main.tf rename to aws/aws_simple/modules/elb/main.tf diff --git a/aws/aws_simple/modules/vpc/outputs.tf b/aws/aws_simple/modules/vpc/outputs.tf new file mode 100644 index 0000000..87ef5aa --- /dev/null +++ b/aws/aws_simple/modules/vpc/outputs.tf @@ -0,0 +1,3 @@ +output "vpc_id" { + value = aws_vpc.vpc_us.id +} diff --git a/aws/aws_simple/modules/vpc/subnets/us-east/outputs.tf b/aws/aws_simple/modules/vpc/subnets/us-east/outputs.tf new file mode 100644 index 0000000..71f3ecd --- /dev/null +++ b/aws/aws_simple/modules/vpc/subnets/us-east/outputs.tf @@ -0,0 +1,16 @@ +# In your vpc/subnets/us-east module + +output "us_east_subnet_1_id" { + description = "The ID of the first US East subnet" + value = aws_subnet.us_east_subnet_1.id +} + +output "us_east_subnet_2_id" { + description = "The ID of the second US East subnet" + value = aws_subnet.us_east_subnet_2.id +} + +output "us_east_subnet_3_id" { + description = "The ID of the third US East subnet" + value = aws_subnet.us_east_subnet_3.id +} \ No newline at end of file diff --git a/aws/aws_simple/vpc/subnets/us-east/subnets-east.tf b/aws/aws_simple/modules/vpc/subnets/us-east/subnets-east.tf similarity index 77% rename from aws/aws_simple/vpc/subnets/us-east/subnets-east.tf rename to aws/aws_simple/modules/vpc/subnets/us-east/subnets-east.tf index a182a30..dea401b 100644 --- a/aws/aws_simple/vpc/subnets/us-east/subnets-east.tf +++ b/aws/aws_simple/modules/vpc/subnets/us-east/subnets-east.tf @@ -1,31 +1,36 @@ - provider "aws" { - region = "us-east-1" + region = var.region } resource "aws_subnet" "us_east_subnet_1" { - vpc_id = aws_vpc.my_vpc.id + vpc_id = var.vpc_id cidr_block = var.us_east_subnet_1_cidr_block availability_zone = var.us_east_subnet_1_az tags = { Name = "${var.region}_${var.us_east_subnet_1_az}_subnet" } + + depends_on = [var.vpc_id] } resource "aws_subnet" "us_east_subnet_2" { - vpc_id = aws_vpc.my_vpc.id + vpc_id = var.vpc_id cidr_block = var.us_east_subnet_2_cidr_block availability_zone = var.us_east_subnet_2_az tags = { Name = "${var.region}_${var.us_east_subnet_2_az}_subnet" } + + depends_on = [var.vpc_id] } resource "aws_subnet" "us_east_subnet_3" { - vpc_id = aws_vpc.my_vpc.id + vpc_id = var.vpc_id cidr_block = var.us_east_subnet_3_cidr_block availability_zone = var.us_east_subnet_3_az tags = { Name = "${var.region}_${var.us_east_subnet_3_az}_subnet" } + + depends_on = [var.vpc_id] } \ No newline at end of file diff --git a/aws/aws_simple/vpc/subnets/us-east/terraform.tfvars b/aws/aws_simple/modules/vpc/subnets/us-east/terraform.tfvars similarity index 100% rename from aws/aws_simple/vpc/subnets/us-east/terraform.tfvars rename to aws/aws_simple/modules/vpc/subnets/us-east/terraform.tfvars diff --git a/aws/aws_simple/vpc/subnets/us-east/variables.tf b/aws/aws_simple/modules/vpc/subnets/us-east/variables.tf similarity index 84% rename from aws/aws_simple/vpc/subnets/us-east/variables.tf rename to aws/aws_simple/modules/vpc/subnets/us-east/variables.tf index 784dc3a..06b49e1 100644 --- a/aws/aws_simple/vpc/subnets/us-east/variables.tf +++ b/aws/aws_simple/modules/vpc/subnets/us-east/variables.tf @@ -25,4 +25,9 @@ variable "us_east_subnet_2_cidr_block" { variable "us_east_subnet_3_cidr_block" { default = "10.0.6.0/24" +} + +variable "vpc_id" { + description = "The ID of the VPC" + type = string } \ No newline at end of file diff --git a/aws/aws_simple/modules/vpc/subnets/us-west/outputs.tf b/aws/aws_simple/modules/vpc/subnets/us-west/outputs.tf new file mode 100644 index 0000000..9fa8450 --- /dev/null +++ b/aws/aws_simple/modules/vpc/subnets/us-west/outputs.tf @@ -0,0 +1,16 @@ +# In your vpc/subnets/us-east module + +output "us_west_subnet_1_id" { + description = "The ID of the first US East subnet" + value = aws_subnet.us_west_subnet_1.id +} + +output "us_west_subnet_2_id" { + description = "The ID of the second US East subnet" + value = aws_subnet.us_west_subnet_2.id +} + +output "us_west_subnet_3_id" { + description = "The ID of the third US East subnet" + value = aws_subnet.us_west_subnet_3.id +} \ No newline at end of file diff --git a/aws/aws_simple/vpc/subnets/us-west/subnets-west.tf b/aws/aws_simple/modules/vpc/subnets/us-west/subnets-west.tf similarity index 86% rename from aws/aws_simple/vpc/subnets/us-west/subnets-west.tf rename to aws/aws_simple/modules/vpc/subnets/us-west/subnets-west.tf index 07281c7..fc69355 100644 --- a/aws/aws_simple/vpc/subnets/us-west/subnets-west.tf +++ b/aws/aws_simple/modules/vpc/subnets/us-west/subnets-west.tf @@ -1,6 +1,5 @@ - resource "aws_subnet" "us_west_subnet_1" { - vpc_id = aws_vpc.my_vpc.id + vpc_id = var.vpc_id cidr_block = var.us_west_subnet_1_cidr_block availability_zone = var.us_west_subnet_1_az tags = { @@ -9,7 +8,7 @@ resource "aws_subnet" "us_west_subnet_1" { } resource "aws_subnet" "us_west_subnet_2" { - vpc_id = aws_vpc.my_vpc.id + vpc_id = var.vpc_id cidr_block = var.us_west_subnet_2_cidr_block availability_zone = var.us_west_subnet_2_az tags = { @@ -18,7 +17,7 @@ resource "aws_subnet" "us_west_subnet_2" { } resource "aws_subnet" "us_west_subnet_3" { - vpc_id = aws_vpc.my_vpc.id + vpc_id = var.vpc_id cidr_block = var.us_west_subnet_3_cidr_block availability_zone = var.us_west_subnet_3_az tags = { diff --git a/aws/aws_simple/vpc/subnets/us-west/terraform.tfvars b/aws/aws_simple/modules/vpc/subnets/us-west/terraform.tfvars similarity index 99% rename from aws/aws_simple/vpc/subnets/us-west/terraform.tfvars rename to aws/aws_simple/modules/vpc/subnets/us-west/terraform.tfvars index b43cf99..d8d98e3 100644 --- a/aws/aws_simple/vpc/subnets/us-west/terraform.tfvars +++ b/aws/aws_simple/modules/vpc/subnets/us-west/terraform.tfvars @@ -7,4 +7,3 @@ us_west_subnet_2_az = "us-west-2b" us_west_subnet_3_cidr_block = "10.0.3.0/24" us_west_subnet_3_az = "us-west-2c" - diff --git a/aws/aws_simple/vpc/subnets/us-west/variables.tf b/aws/aws_simple/modules/vpc/subnets/us-west/variables.tf similarity index 84% rename from aws/aws_simple/vpc/subnets/us-west/variables.tf rename to aws/aws_simple/modules/vpc/subnets/us-west/variables.tf index 14cba45..2bc6502 100644 --- a/aws/aws_simple/vpc/subnets/us-west/variables.tf +++ b/aws/aws_simple/modules/vpc/subnets/us-west/variables.tf @@ -25,4 +25,9 @@ variable "us_west_subnet_3_az" { variable "region" { default = "us-west-2" +} + +variable "vpc_id" { + description = "The ID of the VPC" + type = string } \ No newline at end of file diff --git a/aws/aws_simple/modules/vpc/terraform.tfvars b/aws/aws_simple/modules/vpc/terraform.tfvars new file mode 100644 index 0000000..009494e --- /dev/null +++ b/aws/aws_simple/modules/vpc/terraform.tfvars @@ -0,0 +1,8 @@ +vpc_cidr_block = "10.0.0.0/16" + +us_east_subnet_1_id = "" +us_east_subnet_2_id = "" +us_east_subnet_3_id = "" +us_west_subnet_1_id = "" +us_west_subnet_2_id = "" +us_west_subnet_3_id = "" \ No newline at end of file diff --git a/aws/aws_simple/modules/vpc/variables.tf b/aws/aws_simple/modules/vpc/variables.tf new file mode 100644 index 0000000..248726f --- /dev/null +++ b/aws/aws_simple/modules/vpc/variables.tf @@ -0,0 +1,33 @@ +variable "vpc_cidr_block" { + default = "10.0.0.0/16" +} + +variable "us_east_subnet_1_id" { + description = "The ID of the first US East subnet" + type = string +} + +variable "us_east_subnet_2_id" { + description = "The ID of the second US East subnet" + type = string +} + +variable "us_east_subnet_3_id" { + description = "The ID of the third US East subnet" + type = string +} + +variable "us_west_subnet_1_id" { + description = "The ID of the first US West subnet" + type = string +} + +variable "us_west_subnet_2_id" { + description = "The ID of the second US West subnet" + type = string +} + +variable "us_west_subnet_3_id" { + description = "The ID of the third US West subnet" + type = string +} \ No newline at end of file diff --git a/aws/aws_simple/vpc/vpc.tf b/aws/aws_simple/modules/vpc/vpc.tf similarity index 77% rename from aws/aws_simple/vpc/vpc.tf rename to aws/aws_simple/modules/vpc/vpc.tf index 7072b79..b81b126 100644 --- a/aws/aws_simple/vpc/vpc.tf +++ b/aws/aws_simple/modules/vpc/vpc.tf @@ -1,24 +1,24 @@ #Create aws vpc -resource "aws_vpc" "my_vpc" { +resource "aws_vpc" "vpc_us" { cidr_block = var.vpc_cidr_block tags = { - Name = "production-vpc" + Name = "vpc_us" Environment = "production" } } # Create aws internet gateway resource "aws_internet_gateway" "my_igw" { - vpc_id = aws_vpc.my_vpc.id + vpc_id = aws_vpc.vpc_us.id } # Create route table entries for the west subnets resource "aws_route_table" "us_west_route_table" { - vpc_id = aws_vpc.my_vpc.id + vpc_id = aws_vpc.vpc_us.id } # Create route table entries for the east subnets resource "aws_route_table" "us_east_route_table" { - vpc_id = aws_vpc.my_vpc.id + vpc_id = aws_vpc.vpc_us.id } resource "aws_route" "us_west_route" { @@ -34,32 +34,32 @@ resource "aws_route" "us_east_route" { } resource "aws_route_table_association" "us_west_subnet_1_association" { - subnet_id = aws_subnet.us_west_subnet_1.id + subnet_id = var.us_west_subnet_1_id route_table_id = aws_route_table.us_west_route_table.id } resource "aws_route_table_association" "us_west_subnet_2_association" { - subnet_id = aws_subnet.us_west_subnet_2.id + subnet_id = var.us_west_subnet_2_id route_table_id = aws_route_table.us_west_route_table.id } resource "aws_route_table_association" "us_west_subnet_3_association" { - subnet_id = aws_subnet.us_west_subnet_3.id + subnet_id = var.us_west_subnet_3_id route_table_id = aws_route_table.us_west_route_table.id } resource "aws_route_table_association" "us_east_subnet_1_association" { - subnet_id = aws_subnet.us_east_subnet_1.id + subnet_id = var.us_east_subnet_1_id route_table_id = aws_route_table.us_east_route_table.id } resource "aws_route_table_association" "us_east_subnet_2_association" { - subnet_id = aws_subnet.us_east_subnet_2.id + subnet_id = var.us_east_subnet_2_id route_table_id = aws_route_table.us_east_route_table.id } resource "aws_route_table_association" "us_east_subnet_3_association" { - subnet_id = aws_subnet.us_east_subnet_3.id + subnet_id = var.us_east_subnet_3_id route_table_id = aws_route_table.us_east_route_table.id } diff --git a/aws/aws_simple/terraform.tfvars b/aws/aws_simple/terraform.tfvars index 0c441f7..7bfa3a2 100644 --- a/aws/aws_simple/terraform.tfvars +++ b/aws/aws_simple/terraform.tfvars @@ -1,3 +1,3 @@ -aws_secret_key = "" +aws_secret_key = "" aws_access_key = "" -aws_region = "us-west-2" \ No newline at end of file +aws_region = "us-west-2" diff --git a/aws/aws_simple/vpc/terraform.tfvars b/aws/aws_simple/vpc/terraform.tfvars deleted file mode 100644 index d0f2291..0000000 --- a/aws/aws_simple/vpc/terraform.tfvars +++ /dev/null @@ -1,2 +0,0 @@ -vpc_cidr_block = "10.0.0.0/16" - diff --git a/aws/aws_simple/vpc/variables.tf b/aws/aws_simple/vpc/variables.tf deleted file mode 100644 index f8b2145..0000000 --- a/aws/aws_simple/vpc/variables.tf +++ /dev/null @@ -1,4 +0,0 @@ -variable "vpc_cidr_block" { - default = "10.0.0.0/16" -} - From 48ed0ca1d618a1dbaf5910def40f2388f3eaa17a Mon Sep 17 00:00:00 2001 From: Greg Hendrickson Date: Fri, 17 Nov 2023 09:46:38 -0800 Subject: [PATCH 02/17] seperate east/west --- aws/aws_simple/main.tf | 28 +++-- aws/aws_simple/modules/ec2/ec2-east/ec2.tf | 71 ++++++++++++ .../modules/ec2/{ => ec2-east}/outputs.tf | 0 .../ec2/{ => ec2-east}/terraform.tfvars | 0 .../modules/ec2/{ => ec2-east}/user-data.sh | 0 .../modules/ec2/{ => ec2-east}/variables.tf | 22 +--- aws/aws_simple/modules/ec2/ec2-west/ec2.tf | 72 ++++++++++++ .../modules/ec2/ec2-west/outputs.tf | 4 + .../modules/ec2/ec2-west/terraform.tfvars | 2 + .../modules/ec2/ec2-west/user-data.sh | 29 +++++ .../modules/ec2/ec2-west/variables.tf | 34 ++++++ aws/aws_simple/modules/ec2/ec2.tf | 107 ------------------ aws/aws_simple/modules/vpc/outputs.tf | 3 - .../modules/vpc/subnets/us-east/outputs.tf | 2 +- .../vpc/subnets/us-east/subnets-east.tf | 14 +-- .../modules/vpc/subnets/us-east/variables.tf | 11 +- .../vpc/subnets/us-west/subnets-west.tf | 13 ++- .../modules/vpc/subnets/us-west/variables.tf | 3 +- aws/aws_simple/modules/vpc/terraform.tfvars | 8 -- .../modules/vpc/vpc-east/outputs.tf | 8 ++ .../modules/vpc/vpc-east/terraform.tfvars | 2 + .../modules/vpc/vpc-east/variables.tf | 23 ++++ .../modules/vpc/vpc-east/vpc-east.tf | 42 +++++++ .../modules/vpc/vpc-west/outputs.tf | 8 ++ .../modules/vpc/vpc-west/terraform.tfvars | 2 + .../modules/vpc/{ => vpc-west}/variables.tf | 20 +--- .../modules/vpc/vpc-west/vpc-west.tf | 46 ++++++++ aws/aws_simple/modules/vpc/vpc.tf | 65 ----------- 28 files changed, 396 insertions(+), 243 deletions(-) create mode 100644 aws/aws_simple/modules/ec2/ec2-east/ec2.tf rename aws/aws_simple/modules/ec2/{ => ec2-east}/outputs.tf (100%) rename aws/aws_simple/modules/ec2/{ => ec2-east}/terraform.tfvars (100%) rename aws/aws_simple/modules/ec2/{ => ec2-east}/user-data.sh (100%) rename aws/aws_simple/modules/ec2/{ => ec2-east}/variables.tf (66%) create mode 100644 aws/aws_simple/modules/ec2/ec2-west/ec2.tf create mode 100644 aws/aws_simple/modules/ec2/ec2-west/outputs.tf create mode 100644 aws/aws_simple/modules/ec2/ec2-west/terraform.tfvars create mode 100644 aws/aws_simple/modules/ec2/ec2-west/user-data.sh create mode 100644 aws/aws_simple/modules/ec2/ec2-west/variables.tf delete mode 100644 aws/aws_simple/modules/ec2/ec2.tf delete mode 100644 aws/aws_simple/modules/vpc/outputs.tf delete mode 100644 aws/aws_simple/modules/vpc/terraform.tfvars create mode 100644 aws/aws_simple/modules/vpc/vpc-east/outputs.tf create mode 100644 aws/aws_simple/modules/vpc/vpc-east/terraform.tfvars create mode 100644 aws/aws_simple/modules/vpc/vpc-east/variables.tf create mode 100644 aws/aws_simple/modules/vpc/vpc-east/vpc-east.tf create mode 100644 aws/aws_simple/modules/vpc/vpc-west/outputs.tf create mode 100644 aws/aws_simple/modules/vpc/vpc-west/terraform.tfvars rename aws/aws_simple/modules/vpc/{ => vpc-west}/variables.tf (57%) create mode 100644 aws/aws_simple/modules/vpc/vpc-west/vpc-west.tf delete mode 100644 aws/aws_simple/modules/vpc/vpc.tf diff --git a/aws/aws_simple/main.tf b/aws/aws_simple/main.tf index ecd4bc0..99a90d7 100644 --- a/aws/aws_simple/main.tf +++ b/aws/aws_simple/main.tf @@ -4,13 +4,17 @@ provider "aws" { } # Define modules -module "vpc_us" { - source = "./modules/vpc" - +module "vpc-east" { + source = "./modules/vpc/vpc-east" + region = "us-east-1" us_east_subnet_1_id = module.subnets_us_east.us_east_subnet_1_id us_east_subnet_2_id = module.subnets_us_east.us_east_subnet_2_id us_east_subnet_3_id = module.subnets_us_east.us_east_subnet_3_id +} +module "vpc-west" { + source = "./modules/vpc/vpc-west" + region = "us-west-2" us_west_subnet_1_id = module.subnets_us_west.us_west_subnet_1_id us_west_subnet_2_id = module.subnets_us_west.us_west_subnet_2_id us_west_subnet_3_id = module.subnets_us_west.us_west_subnet_3_id @@ -18,28 +22,36 @@ module "vpc_us" { module "subnets_us_west" { source = "./modules/vpc/subnets/us-west" - vpc_id = module.vpc_us.vpc_id + + vpc_id_west_2 = module.vpc-west.vpc_id_west_2 } module "subnets_us_east" { source = "./modules/vpc/subnets/us-east" - vpc_id = module.vpc_us.vpc_id + vpc_id_east_1 = module.vpc-east.vpc_id_east_1 } module "ec2" { - source = "./modules/ec2" + source = "./modules/ec2/ec2-east" us_east_subnet_1_id = module.subnets_us_east.us_east_subnet_1_id us_east_subnet_2_id = module.subnets_us_east.us_east_subnet_2_id us_east_subnet_3_id = module.subnets_us_east.us_east_subnet_3_id + vpc_id_east_1 = module.vpc-east.vpc_id_east_1 +} + +module "ec2-west" { + source = "./modules/ec2/ec2-west" + us_west_subnet_1_id = module.subnets_us_west.us_west_subnet_1_id us_west_subnet_2_id = module.subnets_us_west.us_west_subnet_2_id us_west_subnet_3_id = module.subnets_us_west.us_west_subnet_3_id - - vpc_id = module.vpc_us.vpc_id + + vpc_id_west_2 = module.vpc-west.vpc_id_west_2 } + module "elb" { source = "./modules/elb" } diff --git a/aws/aws_simple/modules/ec2/ec2-east/ec2.tf b/aws/aws_simple/modules/ec2/ec2-east/ec2.tf new file mode 100644 index 0000000..cdbaf94 --- /dev/null +++ b/aws/aws_simple/modules/ec2/ec2-east/ec2.tf @@ -0,0 +1,71 @@ +provider "aws" { + region = "us-east-1" +} +# Create a security group for the EC2 instance +resource "aws_security_group" "instance-east" { + name_prefix = "instance-east-" + vpc_id = var.vpc_id_east_1 + + ingress { + from_port = 80 + to_port = 80 + protocol = "tcp" + cidr_blocks = ["0.0.0.0/0"] + } + + ingress { + from_port = 443 + to_port = 443 + protocol = "tcp" + cidr_blocks = ["0.0.0.0/0"] + } + + tags = { + Name = "instance-security-group-east" + } +} + +# Define the Launch Configuration +resource "aws_launch_configuration" "lc-east" { + name_prefix = "lc-east-" + image_id = "ami-0237a465e7f465b10" + instance_type = "t3.small" + security_groups = [ + aws_security_group.instance-east.id + ] + user_data = file("${path.module}/user-data.sh") + root_block_device { + volume_size = 300 + } +} + +# Define the Auto Scaling Group +resource "aws_autoscaling_group" "asg-east" { + name_prefix = "asg-east-" + launch_configuration = aws_launch_configuration.lc-east.id + depends_on = [ + aws_launch_configuration.lc-east, + ] + vpc_zone_identifier = [ + var.us_east_subnet_1_id, + var.us_east_subnet_2_id, + var.us_east_subnet_3_id, + ] + min_size = var.min_size + max_size = var.max_size + desired_capacity = var.min_size + health_check_grace_period = 300 + health_check_type = "EC2" + termination_policies = ["OldestInstance"] + tag { + key = "Name" + value = "asg-instance-east" + propagate_at_launch = true + } +} + +data "aws_instances" "asg_instances-east" { + instance_tags = { + "aws:autoscaling:groupName" = aws_autoscaling_group.asg-east.name + } +} diff --git a/aws/aws_simple/modules/ec2/outputs.tf b/aws/aws_simple/modules/ec2/ec2-east/outputs.tf similarity index 100% rename from aws/aws_simple/modules/ec2/outputs.tf rename to aws/aws_simple/modules/ec2/ec2-east/outputs.tf diff --git a/aws/aws_simple/modules/ec2/terraform.tfvars b/aws/aws_simple/modules/ec2/ec2-east/terraform.tfvars similarity index 100% rename from aws/aws_simple/modules/ec2/terraform.tfvars rename to aws/aws_simple/modules/ec2/ec2-east/terraform.tfvars diff --git a/aws/aws_simple/modules/ec2/user-data.sh b/aws/aws_simple/modules/ec2/ec2-east/user-data.sh similarity index 100% rename from aws/aws_simple/modules/ec2/user-data.sh rename to aws/aws_simple/modules/ec2/ec2-east/user-data.sh diff --git a/aws/aws_simple/modules/ec2/variables.tf b/aws/aws_simple/modules/ec2/ec2-east/variables.tf similarity index 66% rename from aws/aws_simple/modules/ec2/variables.tf rename to aws/aws_simple/modules/ec2/ec2-east/variables.tf index 6092172..068b688 100644 --- a/aws/aws_simple/modules/ec2/variables.tf +++ b/aws/aws_simple/modules/ec2/ec2-east/variables.tf @@ -28,22 +28,10 @@ variable "us_east_subnet_3_id" { type = string } -variable "us_west_subnet_1_id" { - description = "The ID of the first US West subnet" - type = string -} - -variable "us_west_subnet_2_id" { - description = "The ID of the second US West subnet" - type = string -} - -variable "us_west_subnet_3_id" { - description = "The ID of the third US West subnet" - type = string -} - -variable "vpc_id" { +variable "vpc_id_east_1" { description = "The ID of the VPC" type = string -} \ No newline at end of file +} + + + diff --git a/aws/aws_simple/modules/ec2/ec2-west/ec2.tf b/aws/aws_simple/modules/ec2/ec2-west/ec2.tf new file mode 100644 index 0000000..69277bf --- /dev/null +++ b/aws/aws_simple/modules/ec2/ec2-west/ec2.tf @@ -0,0 +1,72 @@ +provider "aws" { + region = "us-west-2" +} + +# Create a security group for the EC2 instance +resource "aws_security_group" "instance-west" { + name_prefix = "instance-west-" + vpc_id = var.vpc_id_west_2 + + ingress { + from_port = 80 + to_port = 80 + protocol = "tcp" + cidr_blocks = ["0.0.0.0/0"] + } + + ingress { + from_port = 443 + to_port = 443 + protocol = "tcp" + cidr_blocks = ["0.0.0.0/0"] + } + + tags = { + Name = "instance-security-group-west" + } +} + +# Define the Launch Configuration +resource "aws_launch_configuration" "lc-west" { + name_prefix = "lc-west" + image_id = "ami-03bf1eb153d14803f" + instance_type = "t3.small" + security_groups = [ + aws_security_group.instance-west.id + ] + user_data = file("${path.module}/user-data.sh") + root_block_device { + volume_size = 300 + } +} + +# Define the Auto Scaling Group +resource "aws_autoscaling_group" "asg-west" { + name_prefix = "asg-west-" + launch_configuration = aws_launch_configuration.lc-west.id + depends_on = [ + aws_launch_configuration.lc-west, + ] + vpc_zone_identifier = [ + var.us_west_subnet_1_id, + var.us_west_subnet_2_id, + var.us_west_subnet_3_id + ] + min_size = var.min_size + max_size = var.max_size + desired_capacity = var.min_size + health_check_grace_period = 300 + health_check_type = "EC2" + termination_policies = ["OldestInstance"] + tag { + key = "Name" + value = "asg-instance-west" + propagate_at_launch = true + } +} + +data "aws_instances" "asg_instances-west" { + instance_tags = { + "aws:autoscaling:groupName" = aws_autoscaling_group.asg-west.name + } +} diff --git a/aws/aws_simple/modules/ec2/ec2-west/outputs.tf b/aws/aws_simple/modules/ec2/ec2-west/outputs.tf new file mode 100644 index 0000000..d5f2320 --- /dev/null +++ b/aws/aws_simple/modules/ec2/ec2-west/outputs.tf @@ -0,0 +1,4 @@ +# output "public_ips" { +# description = "Public IP addresses of the instances in the Auto Scaling group" +# value = [for i in data.aws_instances.asg_instances.ids : aws_instance[i].public_ip] +# } \ No newline at end of file diff --git a/aws/aws_simple/modules/ec2/ec2-west/terraform.tfvars b/aws/aws_simple/modules/ec2/ec2-west/terraform.tfvars new file mode 100644 index 0000000..e591122 --- /dev/null +++ b/aws/aws_simple/modules/ec2/ec2-west/terraform.tfvars @@ -0,0 +1,2 @@ +min_size = 1 +max_size = 10 \ No newline at end of file diff --git a/aws/aws_simple/modules/ec2/ec2-west/user-data.sh b/aws/aws_simple/modules/ec2/ec2-west/user-data.sh new file mode 100644 index 0000000..bb81c28 --- /dev/null +++ b/aws/aws_simple/modules/ec2/ec2-west/user-data.sh @@ -0,0 +1,29 @@ +#!/bin/bash + +# Install necessary packages +sudo apt-get update +sudo apt-get install -y git amazon-efs-utils vim-nox neofetch htop tmux curl wget + +# Create new user with sudo privileges +sudo useradd -m -s /bin/bash greg +sudo usermod -aG sudo greg + +# Add authorized keys for your public key +sudo mkdir -p /home/greg/.ssh +sudo touch /home/greg/.ssh/authorized_keys +sudo chmod 700 /home/greg/.ssh +sudo chmod 600 /home/greg/.ssh/authorized_keys +sudo chown -R greg:greg /home/greg/.ssh + +# Add your public key to authorized_keys +sudo echo "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCdOF80z0piQEnYzNCu2OGvOJdm7+3wfDuiC+Jzi8VbSC5VW4iJAQXOuDNGLzyqNi6uMjI77xpEL6Xzn29uJiQti6Y/LxhOZwNNIQiGUpFco1wkBYeBFbtgHQxsMLwumrxQGEj2fyCiSrACAPyy/l1fP4mlN7abBGD5aozBrYKxXPS/kfwO5nsWmw27RgTzfHJzie2dUU3ew/kd7td3wEdWrRXq8wNbu+yvAyiog54huUUWmYZwY3QVwXr6R1wsVudawM6BEl45QFq+hdB4t83azHG94XLy2NCAncohdU7zP40nsbvIDyh+4wIKeU90z6TLrXfHUYuBT6/ky7qOFm/Ym1QG4zCDz3jin8Qoa31PGaObzj/zoMJXgOXKcp16W0j9SZAenvnSfuWUEfBR1yBRR0T5Wg5v1vi7KGBTATaz8el802uliL+yZbGtMbNpAPGR5nK5C4yorf8yVYvIgo/LJaWCDND2O1e2mdut1WyRmvIwMnq7PFZT8zAsgGXfhDM= greg@ligma +" >> /home/greg/.ssh/authorized_keys + +# Set hostname +INSTANCE_ID=$(curl -s http://169.254.169.254/latest/meta-data/instance-id) +AVAILABILITY_ZONE=$(curl -s http://169.254.169.254/latest/meta-data/placement/availability-zone) +HOSTNAME="$INSTANCE_ID-$AVAILABILITY_ZONE" +sudo hostnamectl set-hostname $HOSTNAME + +# Run cloud-init.sh script +# sudo sh /path/to/cloud-init.sh diff --git a/aws/aws_simple/modules/ec2/ec2-west/variables.tf b/aws/aws_simple/modules/ec2/ec2-west/variables.tf new file mode 100644 index 0000000..13e92ed --- /dev/null +++ b/aws/aws_simple/modules/ec2/ec2-west/variables.tf @@ -0,0 +1,34 @@ + +# Define variables +variable "min_size" { + type = number + description = "Minimum number of instances in the Auto Scaling Group" + default = 1 +} + +variable "max_size" { + type = number + description = "Maximum number of instances in the Auto Scaling Group" + default = 1 +} + +variable "us_west_subnet_1_id" { + description = "The ID of the first US West subnet" + type = string +} + +variable "us_west_subnet_2_id" { + description = "The ID of the second US West subnet" + type = string +} + +variable "us_west_subnet_3_id" { + description = "The ID of the third US West subnet" + type = string +} + +variable "vpc_id_west_2" { + description = "The ID of the VPC" + type = string +} + diff --git a/aws/aws_simple/modules/ec2/ec2.tf b/aws/aws_simple/modules/ec2/ec2.tf deleted file mode 100644 index 96743ff..0000000 --- a/aws/aws_simple/modules/ec2/ec2.tf +++ /dev/null @@ -1,107 +0,0 @@ -# Define the VPC and subnets data sources -data "aws_vpc" "vpc" { - id = var.vpc_id -} - -data "aws_subnet" "subnet1" { - id = var.us_east_subnet_1_id -} - -data "aws_subnet" "subnet2" { - id = var.us_east_subnet_2_id -} - -data "aws_subnet" "subnet3" { - id = var.us_east_subnet_3_id -} - -data "aws_subnet" "subnet4" { - id = var.us_west_subnet_1_id -} - -data "aws_subnet" "subnet5" { - id = var.us_west_subnet_2_id -} - -data "aws_subnet" "subnet6" { - id = var.us_west_subnet_3_id -} - -# Create a security group for the EC2 instance -resource "aws_security_group" "instance" { - name_prefix = "instance-" - vpc_id = var.vpc_id - - ingress { - from_port = 80 - to_port = 80 - protocol = "tcp" - cidr_blocks = ["0.0.0.0/0"] - } - - ingress { - from_port = 443 - to_port = 443 - protocol = "tcp" - cidr_blocks = ["0.0.0.0/0"] - } - - tags = { - Name = "instance-security-group" - } -} - -# Define the Launch Configuration -resource "aws_launch_configuration" "lc" { - name_prefix = "lc-" - image_id = "ami-0c55b159cbfafe1f0" # Amazon Linux 2 AMI - instance_type = "t3.small" - security_groups = [ - aws_security_group.instance.id - ] - user_data = file("${path.module}/user-data.sh") - root_block_device { - volume_size = 20 - } -} - -# Define the Auto Scaling Group -resource "aws_autoscaling_group" "asg" { - name_prefix = "asg-" - launch_configuration = aws_launch_configuration.lc.id - depends_on = [ - var.vpc_id, - aws_launch_configuration.lc, - data.aws_subnet.subnet1, - data.aws_subnet.subnet2, - data.aws_subnet.subnet3, - data.aws_subnet.subnet4, - data.aws_subnet.subnet5, - data.aws_subnet.subnet6 - ] - vpc_zone_identifier = [ - data.aws_subnet.subnet1.id, - data.aws_subnet.subnet2.id, - data.aws_subnet.subnet3.id, - data.aws_subnet.subnet4.id, - data.aws_subnet.subnet5.id, - data.aws_subnet.subnet6.id - ] - min_size = var.min_size - max_size = var.max_size - desired_capacity = var.min_size - health_check_grace_period = 300 - health_check_type = "EC2" - termination_policies = ["OldestInstance"] - tag { - key = "Name" - value = "asg-instance" - propagate_at_launch = true - } -} - -data "aws_instances" "asg_instances" { - instance_tags = { - "aws:autoscaling:groupName" = aws_autoscaling_group.asg.name - } -} diff --git a/aws/aws_simple/modules/vpc/outputs.tf b/aws/aws_simple/modules/vpc/outputs.tf deleted file mode 100644 index 87ef5aa..0000000 --- a/aws/aws_simple/modules/vpc/outputs.tf +++ /dev/null @@ -1,3 +0,0 @@ -output "vpc_id" { - value = aws_vpc.vpc_us.id -} diff --git a/aws/aws_simple/modules/vpc/subnets/us-east/outputs.tf b/aws/aws_simple/modules/vpc/subnets/us-east/outputs.tf index 71f3ecd..e73df5c 100644 --- a/aws/aws_simple/modules/vpc/subnets/us-east/outputs.tf +++ b/aws/aws_simple/modules/vpc/subnets/us-east/outputs.tf @@ -13,4 +13,4 @@ output "us_east_subnet_2_id" { output "us_east_subnet_3_id" { description = "The ID of the third US East subnet" value = aws_subnet.us_east_subnet_3.id -} \ No newline at end of file +} diff --git a/aws/aws_simple/modules/vpc/subnets/us-east/subnets-east.tf b/aws/aws_simple/modules/vpc/subnets/us-east/subnets-east.tf index dea401b..f846e52 100644 --- a/aws/aws_simple/modules/vpc/subnets/us-east/subnets-east.tf +++ b/aws/aws_simple/modules/vpc/subnets/us-east/subnets-east.tf @@ -1,36 +1,30 @@ provider "aws" { - region = var.region + region = "us-east-1" } resource "aws_subnet" "us_east_subnet_1" { - vpc_id = var.vpc_id + vpc_id = var.vpc_id_east_1 cidr_block = var.us_east_subnet_1_cidr_block availability_zone = var.us_east_subnet_1_az tags = { Name = "${var.region}_${var.us_east_subnet_1_az}_subnet" } - - depends_on = [var.vpc_id] } resource "aws_subnet" "us_east_subnet_2" { - vpc_id = var.vpc_id + vpc_id = var.vpc_id_east_1 cidr_block = var.us_east_subnet_2_cidr_block availability_zone = var.us_east_subnet_2_az tags = { Name = "${var.region}_${var.us_east_subnet_2_az}_subnet" } - - depends_on = [var.vpc_id] } resource "aws_subnet" "us_east_subnet_3" { - vpc_id = var.vpc_id + vpc_id = var.vpc_id_east_1 cidr_block = var.us_east_subnet_3_cidr_block availability_zone = var.us_east_subnet_3_az tags = { Name = "${var.region}_${var.us_east_subnet_3_az}_subnet" } - - depends_on = [var.vpc_id] } \ No newline at end of file diff --git a/aws/aws_simple/modules/vpc/subnets/us-east/variables.tf b/aws/aws_simple/modules/vpc/subnets/us-east/variables.tf index 06b49e1..e8b4108 100644 --- a/aws/aws_simple/modules/vpc/subnets/us-east/variables.tf +++ b/aws/aws_simple/modules/vpc/subnets/us-east/variables.tf @@ -16,18 +16,19 @@ variable "region" { variable "us_east_subnet_1_cidr_block" { - default = "10.0.4.0/24" + default = "10.1.4.0/24" } variable "us_east_subnet_2_cidr_block" { - default = "10.0.5.0/24" + default = "10.1.5.0/24" } variable "us_east_subnet_3_cidr_block" { - default = "10.0.6.0/24" + default = "10.1.6.0/24" } -variable "vpc_id" { +variable "vpc_id_east_1" { description = "The ID of the VPC" type = string -} \ No newline at end of file +} + diff --git a/aws/aws_simple/modules/vpc/subnets/us-west/subnets-west.tf b/aws/aws_simple/modules/vpc/subnets/us-west/subnets-west.tf index fc69355..2f3f099 100644 --- a/aws/aws_simple/modules/vpc/subnets/us-west/subnets-west.tf +++ b/aws/aws_simple/modules/vpc/subnets/us-west/subnets-west.tf @@ -1,26 +1,33 @@ +provider "aws" { + region = "us-west-2" +} + resource "aws_subnet" "us_west_subnet_1" { - vpc_id = var.vpc_id + vpc_id = var.vpc_id_west_2 cidr_block = var.us_west_subnet_1_cidr_block availability_zone = var.us_west_subnet_1_az tags = { Name = "${var.region}_${var.us_west_subnet_1_az}_subnet" } + depends_on = [var.vpc_id_west_2] } resource "aws_subnet" "us_west_subnet_2" { - vpc_id = var.vpc_id + vpc_id = var.vpc_id_west_2 cidr_block = var.us_west_subnet_2_cidr_block availability_zone = var.us_west_subnet_2_az tags = { Name = "${var.region}_${var.us_west_subnet_2_az}_subnet" } + depends_on = [var.vpc_id_west_2] } resource "aws_subnet" "us_west_subnet_3" { - vpc_id = var.vpc_id + vpc_id = var.vpc_id_west_2 cidr_block = var.us_west_subnet_3_cidr_block availability_zone = var.us_west_subnet_3_az tags = { Name = "${var.region}_${var.us_west_subnet_3_az}_subnet" } + depends_on = [var.vpc_id_west_2] } diff --git a/aws/aws_simple/modules/vpc/subnets/us-west/variables.tf b/aws/aws_simple/modules/vpc/subnets/us-west/variables.tf index 2bc6502..0237ab3 100644 --- a/aws/aws_simple/modules/vpc/subnets/us-west/variables.tf +++ b/aws/aws_simple/modules/vpc/subnets/us-west/variables.tf @@ -27,7 +27,8 @@ variable "region" { default = "us-west-2" } -variable "vpc_id" { + +variable "vpc_id_west_2" { description = "The ID of the VPC" type = string } \ No newline at end of file diff --git a/aws/aws_simple/modules/vpc/terraform.tfvars b/aws/aws_simple/modules/vpc/terraform.tfvars deleted file mode 100644 index 009494e..0000000 --- a/aws/aws_simple/modules/vpc/terraform.tfvars +++ /dev/null @@ -1,8 +0,0 @@ -vpc_cidr_block = "10.0.0.0/16" - -us_east_subnet_1_id = "" -us_east_subnet_2_id = "" -us_east_subnet_3_id = "" -us_west_subnet_1_id = "" -us_west_subnet_2_id = "" -us_west_subnet_3_id = "" \ No newline at end of file diff --git a/aws/aws_simple/modules/vpc/vpc-east/outputs.tf b/aws/aws_simple/modules/vpc/vpc-east/outputs.tf new file mode 100644 index 0000000..8695c74 --- /dev/null +++ b/aws/aws_simple/modules/vpc/vpc-east/outputs.tf @@ -0,0 +1,8 @@ +output "vpc_id_east_1" { + value = aws_vpc.vpc_us_east_1.id +} + +output "vpc_cidr_block" { + description = "The CIDR block of the VPC" + value = aws_vpc.vpc_us_east_1.cidr_block +} \ No newline at end of file diff --git a/aws/aws_simple/modules/vpc/vpc-east/terraform.tfvars b/aws/aws_simple/modules/vpc/vpc-east/terraform.tfvars new file mode 100644 index 0000000..a4b92a4 --- /dev/null +++ b/aws/aws_simple/modules/vpc/vpc-east/terraform.tfvars @@ -0,0 +1,2 @@ +vpc_cidr_block = "10.1.0.0/16" +region = "us-east-1" \ No newline at end of file diff --git a/aws/aws_simple/modules/vpc/vpc-east/variables.tf b/aws/aws_simple/modules/vpc/vpc-east/variables.tf new file mode 100644 index 0000000..a112697 --- /dev/null +++ b/aws/aws_simple/modules/vpc/vpc-east/variables.tf @@ -0,0 +1,23 @@ +variable "vpc_cidr_block" { + default = "10.1.0.0/16" +} + +variable "us_east_subnet_1_id" { + description = "The ID of the first US East subnet" + type = string +} + +variable "us_east_subnet_2_id" { + description = "The ID of the second US East subnet" + type = string +} + +variable "us_east_subnet_3_id" { + description = "The ID of the third US East subnet" + type = string +} + +variable "region" { + description = "The region to deploy to" + type = string +} \ No newline at end of file diff --git a/aws/aws_simple/modules/vpc/vpc-east/vpc-east.tf b/aws/aws_simple/modules/vpc/vpc-east/vpc-east.tf new file mode 100644 index 0000000..2cdeb8b --- /dev/null +++ b/aws/aws_simple/modules/vpc/vpc-east/vpc-east.tf @@ -0,0 +1,42 @@ +provider "aws" { + region = "us-east-1" +} + +resource "aws_vpc" "vpc_us_east_1" { + cidr_block = var.vpc_cidr_block + tags = { + Name = "vpc_us_east_1" + Environment = "production" + } +} + +# Create aws internet gateway +resource "aws_internet_gateway" "my_igw_east_1" { + vpc_id = aws_vpc.vpc_us_east_1.id +} + +# Create route table entries for the east subnets +resource "aws_route_table" "us_east_route_table" { + vpc_id = aws_vpc.vpc_us_east_1.id +} + +resource "aws_route" "us_east_route" { + route_table_id = aws_route_table.us_east_route_table.id + destination_cidr_block = "0.0.0.0/0" + gateway_id = aws_internet_gateway.my_igw_east_1.id +} + +resource "aws_route_table_association" "us_east_subnet_1_association" { + subnet_id = var.us_east_subnet_1_id + route_table_id = aws_route_table.us_east_route_table.id +} + +resource "aws_route_table_association" "us_east_subnet_2_association" { + subnet_id = var.us_east_subnet_2_id + route_table_id = aws_route_table.us_east_route_table.id +} + +resource "aws_route_table_association" "us_east_subnet_3_association" { + subnet_id = var.us_east_subnet_3_id + route_table_id = aws_route_table.us_east_route_table.id +} diff --git a/aws/aws_simple/modules/vpc/vpc-west/outputs.tf b/aws/aws_simple/modules/vpc/vpc-west/outputs.tf new file mode 100644 index 0000000..62963e1 --- /dev/null +++ b/aws/aws_simple/modules/vpc/vpc-west/outputs.tf @@ -0,0 +1,8 @@ +output "vpc_id_west_2" { + value = aws_vpc.vpc_us_west_2.id +} + +output "vpc_cidr_block" { + description = "The CIDR block of the VPC" + value = aws_vpc.vpc_us_west_2.cidr_block +} \ No newline at end of file diff --git a/aws/aws_simple/modules/vpc/vpc-west/terraform.tfvars b/aws/aws_simple/modules/vpc/vpc-west/terraform.tfvars new file mode 100644 index 0000000..517c863 --- /dev/null +++ b/aws/aws_simple/modules/vpc/vpc-west/terraform.tfvars @@ -0,0 +1,2 @@ +vpc_cidr_block = "10.0.0.0/16" +region = "us-west-2" \ No newline at end of file diff --git a/aws/aws_simple/modules/vpc/variables.tf b/aws/aws_simple/modules/vpc/vpc-west/variables.tf similarity index 57% rename from aws/aws_simple/modules/vpc/variables.tf rename to aws/aws_simple/modules/vpc/vpc-west/variables.tf index 248726f..c901f87 100644 --- a/aws/aws_simple/modules/vpc/variables.tf +++ b/aws/aws_simple/modules/vpc/vpc-west/variables.tf @@ -2,21 +2,6 @@ variable "vpc_cidr_block" { default = "10.0.0.0/16" } -variable "us_east_subnet_1_id" { - description = "The ID of the first US East subnet" - type = string -} - -variable "us_east_subnet_2_id" { - description = "The ID of the second US East subnet" - type = string -} - -variable "us_east_subnet_3_id" { - description = "The ID of the third US East subnet" - type = string -} - variable "us_west_subnet_1_id" { description = "The ID of the first US West subnet" type = string @@ -30,4 +15,9 @@ variable "us_west_subnet_2_id" { variable "us_west_subnet_3_id" { description = "The ID of the third US West subnet" type = string +} + +variable "region" { + description = "The region to deploy to" + type = string } \ No newline at end of file diff --git a/aws/aws_simple/modules/vpc/vpc-west/vpc-west.tf b/aws/aws_simple/modules/vpc/vpc-west/vpc-west.tf new file mode 100644 index 0000000..eed9b31 --- /dev/null +++ b/aws/aws_simple/modules/vpc/vpc-west/vpc-west.tf @@ -0,0 +1,46 @@ +provider "aws" { + region = var.region +} + +#Create aws vpc +resource "aws_vpc" "vpc_us_west_2" { + cidr_block = var.vpc_cidr_block + tags = { + Name = "vpc_us_west_1" + Environment = "production" + } +} + +# Create aws internet gateway +resource "aws_internet_gateway" "my_igw_west_2" { + vpc_id = aws_vpc.vpc_us_west_2.id +} + +# Create route table entries for the west subnets +resource "aws_route_table" "us_west_route_table" { + vpc_id = aws_vpc.vpc_us_west_2.id +} + +resource "aws_route" "us_west_route" { + route_table_id = aws_route_table.us_west_route_table.id + destination_cidr_block = "0.0.0.0/0" + gateway_id = aws_internet_gateway.my_igw_west_2.id +} + +resource "aws_route_table_association" "us_west_subnet_1_association" { + subnet_id = var.us_west_subnet_1_id + route_table_id = aws_route_table.us_west_route_table.id +} + +resource "aws_route_table_association" "us_west_subnet_2_association" { + subnet_id = var.us_west_subnet_2_id + route_table_id = aws_route_table.us_west_route_table.id +} + +resource "aws_route_table_association" "us_west_subnet_3_association" { + subnet_id = var.us_west_subnet_3_id + route_table_id = aws_route_table.us_west_route_table.id +} + + + diff --git a/aws/aws_simple/modules/vpc/vpc.tf b/aws/aws_simple/modules/vpc/vpc.tf deleted file mode 100644 index b81b126..0000000 --- a/aws/aws_simple/modules/vpc/vpc.tf +++ /dev/null @@ -1,65 +0,0 @@ -#Create aws vpc -resource "aws_vpc" "vpc_us" { - cidr_block = var.vpc_cidr_block - tags = { - Name = "vpc_us" - Environment = "production" - } -} -# Create aws internet gateway -resource "aws_internet_gateway" "my_igw" { - vpc_id = aws_vpc.vpc_us.id -} - -# Create route table entries for the west subnets -resource "aws_route_table" "us_west_route_table" { - vpc_id = aws_vpc.vpc_us.id -} - -# Create route table entries for the east subnets -resource "aws_route_table" "us_east_route_table" { - vpc_id = aws_vpc.vpc_us.id -} - -resource "aws_route" "us_west_route" { - route_table_id = aws_route_table.us_west_route_table.id - destination_cidr_block = "0.0.0.0/0" - gateway_id = aws_internet_gateway.my_igw.id -} - -resource "aws_route" "us_east_route" { - route_table_id = aws_route_table.us_east_route_table.id - destination_cidr_block = "0.0.0.0/0" - gateway_id = aws_internet_gateway.my_igw.id -} - -resource "aws_route_table_association" "us_west_subnet_1_association" { - subnet_id = var.us_west_subnet_1_id - route_table_id = aws_route_table.us_west_route_table.id -} - -resource "aws_route_table_association" "us_west_subnet_2_association" { - subnet_id = var.us_west_subnet_2_id - route_table_id = aws_route_table.us_west_route_table.id -} - -resource "aws_route_table_association" "us_west_subnet_3_association" { - subnet_id = var.us_west_subnet_3_id - route_table_id = aws_route_table.us_west_route_table.id -} - -resource "aws_route_table_association" "us_east_subnet_1_association" { - subnet_id = var.us_east_subnet_1_id - route_table_id = aws_route_table.us_east_route_table.id -} - -resource "aws_route_table_association" "us_east_subnet_2_association" { - subnet_id = var.us_east_subnet_2_id - route_table_id = aws_route_table.us_east_route_table.id -} - -resource "aws_route_table_association" "us_east_subnet_3_association" { - subnet_id = var.us_east_subnet_3_id - route_table_id = aws_route_table.us_east_route_table.id -} - From 7a620b3a7a549597d290efc3e303287a5e23a136 Mon Sep 17 00:00:00 2001 From: Greg Hendrickson Date: Fri, 17 Nov 2023 11:06:04 -0800 Subject: [PATCH 03/17] launch configuration to launch template --- .gitignore | 1 + .../ec2/ec2-east/{ec2.tf => ec2-east.tf} | 49 +++++++++++++------ .../modules/ec2/ec2-east/outputs.tf | 4 -- .../modules/ec2/ec2-east/terraform.tfvars | 2 +- .../ec2/ec2-west/{ec2.tf => ec2-west..tf} | 46 +++++++++++------ .../modules/ec2/ec2-west/terraform.tfvars | 2 +- .../vpc/subnets/us-east/subnets-east.tf | 3 ++ .../vpc/subnets/us-west/subnets-west.tf | 3 ++ 8 files changed, 74 insertions(+), 36 deletions(-) rename aws/aws_simple/modules/ec2/ec2-east/{ec2.tf => ec2-east.tf} (62%) rename aws/aws_simple/modules/ec2/ec2-west/{ec2.tf => ec2-west..tf} (64%) diff --git a/.gitignore b/.gitignore index 2462613..7f01bc4 100644 --- a/.gitignore +++ b/.gitignore @@ -3,3 +3,4 @@ aws/aws_simple/.terraform/modules/modules.json aws/aws_simple/terraform.tfstate.backup aws/aws_simple/terraform.tfstate aws/aws_simple/.terraform/providers/registry.terraform.io/hashicorp/aws/5.25.0/linux_amd64/terraform-provider-aws_v5.25.0_x5 +aws/aws_simple/.terraform.tfstate.lock.info diff --git a/aws/aws_simple/modules/ec2/ec2-east/ec2.tf b/aws/aws_simple/modules/ec2/ec2-east/ec2-east.tf similarity index 62% rename from aws/aws_simple/modules/ec2/ec2-east/ec2.tf rename to aws/aws_simple/modules/ec2/ec2-east/ec2-east.tf index cdbaf94..b68f61d 100644 --- a/aws/aws_simple/modules/ec2/ec2-east/ec2.tf +++ b/aws/aws_simple/modules/ec2/ec2-east/ec2-east.tf @@ -1,55 +1,67 @@ provider "aws" { region = "us-east-1" } + # Create a security group for the EC2 instance resource "aws_security_group" "instance-east" { name_prefix = "instance-east-" vpc_id = var.vpc_id_east_1 - + # HTTP access ingress { from_port = 80 to_port = 80 protocol = "tcp" cidr_blocks = ["0.0.0.0/0"] } - + # HTTPS access ingress { from_port = 443 to_port = 443 protocol = "tcp" cidr_blocks = ["0.0.0.0/0"] } + # SSH access + ingress { + from_port = 22 + to_port = 22 + protocol = "tcp" + cidr_blocks = ["0.0.0.0/0"] + } tags = { Name = "instance-security-group-east" } } -# Define the Launch Configuration -resource "aws_launch_configuration" "lc-east" { - name_prefix = "lc-east-" +# Define the Launch Template +resource "aws_launch_template" "lt-east" { + name_prefix = "lt-east-" image_id = "ami-0237a465e7f465b10" instance_type = "t3.small" - security_groups = [ - aws_security_group.instance-east.id - ] - user_data = file("${path.module}/user-data.sh") - root_block_device { - volume_size = 300 + user_data = base64encode(file("${path.module}/user-data.sh")) + block_device_mappings { + device_name = "/dev/xvda" + ebs { + volume_size = 300 + } + } + network_interfaces { + associate_public_ip_address = true + security_groups = [aws_security_group.instance-east.id] } } # Define the Auto Scaling Group resource "aws_autoscaling_group" "asg-east" { name_prefix = "asg-east-" - launch_configuration = aws_launch_configuration.lc-east.id - depends_on = [ - aws_launch_configuration.lc-east, - ] + launch_template { + id = aws_launch_template.lt-east.id + version = "$Latest" + } vpc_zone_identifier = [ var.us_east_subnet_1_id, var.us_east_subnet_2_id, - var.us_east_subnet_3_id, + var.us_east_subnet_3_id ] min_size = var.min_size max_size = var.max_size @@ -62,6 +74,11 @@ resource "aws_autoscaling_group" "asg-east" { value = "asg-instance-east" propagate_at_launch = true } + + depends_on = [ + aws_security_group.instance-east, + aws_launch_template.lt-east + ] } data "aws_instances" "asg_instances-east" { diff --git a/aws/aws_simple/modules/ec2/ec2-east/outputs.tf b/aws/aws_simple/modules/ec2/ec2-east/outputs.tf index d5f2320..e69de29 100644 --- a/aws/aws_simple/modules/ec2/ec2-east/outputs.tf +++ b/aws/aws_simple/modules/ec2/ec2-east/outputs.tf @@ -1,4 +0,0 @@ -# output "public_ips" { -# description = "Public IP addresses of the instances in the Auto Scaling group" -# value = [for i in data.aws_instances.asg_instances.ids : aws_instance[i].public_ip] -# } \ No newline at end of file diff --git a/aws/aws_simple/modules/ec2/ec2-east/terraform.tfvars b/aws/aws_simple/modules/ec2/ec2-east/terraform.tfvars index e591122..62c817a 100644 --- a/aws/aws_simple/modules/ec2/ec2-east/terraform.tfvars +++ b/aws/aws_simple/modules/ec2/ec2-east/terraform.tfvars @@ -1,2 +1,2 @@ -min_size = 1 +min_size = 3 max_size = 10 \ No newline at end of file diff --git a/aws/aws_simple/modules/ec2/ec2-west/ec2.tf b/aws/aws_simple/modules/ec2/ec2-west/ec2-west..tf similarity index 64% rename from aws/aws_simple/modules/ec2/ec2-west/ec2.tf rename to aws/aws_simple/modules/ec2/ec2-west/ec2-west..tf index 69277bf..9cdc72f 100644 --- a/aws/aws_simple/modules/ec2/ec2-west/ec2.tf +++ b/aws/aws_simple/modules/ec2/ec2-west/ec2-west..tf @@ -6,7 +6,7 @@ provider "aws" { resource "aws_security_group" "instance-west" { name_prefix = "instance-west-" vpc_id = var.vpc_id_west_2 - + # HTTP access ingress { from_port = 80 to_port = 80 @@ -14,6 +14,7 @@ resource "aws_security_group" "instance-west" { cidr_blocks = ["0.0.0.0/0"] } + # HTTPS access ingress { from_port = 443 to_port = 443 @@ -21,32 +22,45 @@ resource "aws_security_group" "instance-west" { cidr_blocks = ["0.0.0.0/0"] } + # SSH access + ingress { + from_port = 22 + to_port = 22 + protocol = "tcp" + cidr_blocks = ["0.0.0.0/0"] + } + tags = { Name = "instance-security-group-west" } } -# Define the Launch Configuration -resource "aws_launch_configuration" "lc-west" { - name_prefix = "lc-west" +# Define the Launch Template +resource "aws_launch_template" "lt-west" { + name_prefix = "lt-west" image_id = "ami-03bf1eb153d14803f" instance_type = "t3.small" - security_groups = [ - aws_security_group.instance-west.id - ] - user_data = file("${path.module}/user-data.sh") - root_block_device { - volume_size = 300 + user_data = base64encode(file("${path.module}/user-data.sh")) + block_device_mappings { + device_name = "/dev/xvda" + ebs { + volume_size = 300 + } + } + network_interfaces { + associate_public_ip_address = true + security_groups = [aws_security_group.instance-west.id] + } } # Define the Auto Scaling Group resource "aws_autoscaling_group" "asg-west" { name_prefix = "asg-west-" - launch_configuration = aws_launch_configuration.lc-west.id - depends_on = [ - aws_launch_configuration.lc-west, - ] + launch_template { + id = aws_launch_template.lt-west.id + version = "$Latest" + } vpc_zone_identifier = [ var.us_west_subnet_1_id, var.us_west_subnet_2_id, @@ -63,6 +77,10 @@ resource "aws_autoscaling_group" "asg-west" { value = "asg-instance-west" propagate_at_launch = true } + depends_on = [ + aws_security_group.instance-west, + aws_launch_template.lt-west + ] } data "aws_instances" "asg_instances-west" { diff --git a/aws/aws_simple/modules/ec2/ec2-west/terraform.tfvars b/aws/aws_simple/modules/ec2/ec2-west/terraform.tfvars index e591122..62c817a 100644 --- a/aws/aws_simple/modules/ec2/ec2-west/terraform.tfvars +++ b/aws/aws_simple/modules/ec2/ec2-west/terraform.tfvars @@ -1,2 +1,2 @@ -min_size = 1 +min_size = 3 max_size = 10 \ No newline at end of file diff --git a/aws/aws_simple/modules/vpc/subnets/us-east/subnets-east.tf b/aws/aws_simple/modules/vpc/subnets/us-east/subnets-east.tf index f846e52..b15c20a 100644 --- a/aws/aws_simple/modules/vpc/subnets/us-east/subnets-east.tf +++ b/aws/aws_simple/modules/vpc/subnets/us-east/subnets-east.tf @@ -6,6 +6,7 @@ resource "aws_subnet" "us_east_subnet_1" { vpc_id = var.vpc_id_east_1 cidr_block = var.us_east_subnet_1_cidr_block availability_zone = var.us_east_subnet_1_az + map_public_ip_on_launch = true tags = { Name = "${var.region}_${var.us_east_subnet_1_az}_subnet" } @@ -15,6 +16,7 @@ resource "aws_subnet" "us_east_subnet_2" { vpc_id = var.vpc_id_east_1 cidr_block = var.us_east_subnet_2_cidr_block availability_zone = var.us_east_subnet_2_az + map_public_ip_on_launch = true tags = { Name = "${var.region}_${var.us_east_subnet_2_az}_subnet" } @@ -24,6 +26,7 @@ resource "aws_subnet" "us_east_subnet_3" { vpc_id = var.vpc_id_east_1 cidr_block = var.us_east_subnet_3_cidr_block availability_zone = var.us_east_subnet_3_az + map_public_ip_on_launch = true tags = { Name = "${var.region}_${var.us_east_subnet_3_az}_subnet" } diff --git a/aws/aws_simple/modules/vpc/subnets/us-west/subnets-west.tf b/aws/aws_simple/modules/vpc/subnets/us-west/subnets-west.tf index 2f3f099..4e6d645 100644 --- a/aws/aws_simple/modules/vpc/subnets/us-west/subnets-west.tf +++ b/aws/aws_simple/modules/vpc/subnets/us-west/subnets-west.tf @@ -9,6 +9,7 @@ resource "aws_subnet" "us_west_subnet_1" { tags = { Name = "${var.region}_${var.us_west_subnet_1_az}_subnet" } + map_public_ip_on_launch = true depends_on = [var.vpc_id_west_2] } @@ -19,6 +20,7 @@ resource "aws_subnet" "us_west_subnet_2" { tags = { Name = "${var.region}_${var.us_west_subnet_2_az}_subnet" } + map_public_ip_on_launch = true depends_on = [var.vpc_id_west_2] } @@ -29,5 +31,6 @@ resource "aws_subnet" "us_west_subnet_3" { tags = { Name = "${var.region}_${var.us_west_subnet_3_az}_subnet" } + map_public_ip_on_launch = true depends_on = [var.vpc_id_west_2] } From 71092a702f3571775660be3c14bd0c80111c0df5 Mon Sep 17 00:00:00 2001 From: Greg Hendrickson Date: Fri, 17 Nov 2023 11:22:13 -0800 Subject: [PATCH 04/17] syntax in tfvars. update userdata to base64 encode --- aws/aws_simple/modules/ec2/ec2-east/terraform.tfvars | 4 ++-- aws/aws_simple/modules/ec2/ec2-east/user-data.sh | 4 ++-- aws/aws_simple/modules/ec2/ec2-east/variables.tf | 2 -- aws/aws_simple/modules/ec2/ec2-west/terraform.tfvars | 4 ++-- aws/aws_simple/modules/ec2/ec2-west/user-data.sh | 4 ++-- aws/aws_simple/modules/ec2/ec2-west/variables.tf | 2 -- 6 files changed, 8 insertions(+), 12 deletions(-) diff --git a/aws/aws_simple/modules/ec2/ec2-east/terraform.tfvars b/aws/aws_simple/modules/ec2/ec2-east/terraform.tfvars index 62c817a..a3c3722 100644 --- a/aws/aws_simple/modules/ec2/ec2-east/terraform.tfvars +++ b/aws/aws_simple/modules/ec2/ec2-east/terraform.tfvars @@ -1,2 +1,2 @@ -min_size = 3 -max_size = 10 \ No newline at end of file +min_size = "3" +max_size = "10" \ No newline at end of file diff --git a/aws/aws_simple/modules/ec2/ec2-east/user-data.sh b/aws/aws_simple/modules/ec2/ec2-east/user-data.sh index bb81c28..b845ff9 100644 --- a/aws/aws_simple/modules/ec2/ec2-east/user-data.sh +++ b/aws/aws_simple/modules/ec2/ec2-east/user-data.sh @@ -16,8 +16,8 @@ sudo chmod 600 /home/greg/.ssh/authorized_keys sudo chown -R greg:greg /home/greg/.ssh # Add your public key to authorized_keys -sudo echo "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCdOF80z0piQEnYzNCu2OGvOJdm7+3wfDuiC+Jzi8VbSC5VW4iJAQXOuDNGLzyqNi6uMjI77xpEL6Xzn29uJiQti6Y/LxhOZwNNIQiGUpFco1wkBYeBFbtgHQxsMLwumrxQGEj2fyCiSrACAPyy/l1fP4mlN7abBGD5aozBrYKxXPS/kfwO5nsWmw27RgTzfHJzie2dUU3ew/kd7td3wEdWrRXq8wNbu+yvAyiog54huUUWmYZwY3QVwXr6R1wsVudawM6BEl45QFq+hdB4t83azHG94XLy2NCAncohdU7zP40nsbvIDyh+4wIKeU90z6TLrXfHUYuBT6/ky7qOFm/Ym1QG4zCDz3jin8Qoa31PGaObzj/zoMJXgOXKcp16W0j9SZAenvnSfuWUEfBR1yBRR0T5Wg5v1vi7KGBTATaz8el802uliL+yZbGtMbNpAPGR5nK5C4yorf8yVYvIgo/LJaWCDND2O1e2mdut1WyRmvIwMnq7PFZT8zAsgGXfhDM= greg@ligma -" >> /home/greg/.ssh/authorized_keys +sudo echo " +ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCdOF80z0piQEnYzNCu2OGvOJdm7+3wfDuiC+Jzi8VbSC5VW4iJAQXOuDNGLzyqNi6uMjI77xpEL6Xzn29uJiQti6Y/LxhOZwNNIQiGUpFco1wkBYeBFbtgHQxsMLwumrxQGEj2fyCiSrACAPyy/l1fP4mlN7abBGD5aozBrYKxXPS/kfwO5nsWmw27RgTzfHJzie2dUU3ew/kd7td3wEdWrRXq8wNbu+yvAyiog54huUUWmYZwY3QVwXr6R1wsVudawM6BEl45QFq+hdB4t83azHG94XLy2NCAncohdU7zP40nsbvIDyh+4wIKeU90z6TLrXfHUYuBT6/ky7qOFm/Ym1QG4zCDz3jin8Qoa31PGaObzj/zoMJXgOXKcp16W0j9SZAenvnSfuWUEfBR1yBRR0T5Wg5v1vi7KGBTATaz8el802uliL+yZbGtMbNpAPGR5nK5C4yorf8yVYvIgo/LJaWCDND2O1e2mdut1WyRmvIwMnq7PFZT8zAsgGXfhDM= greg@ligma" >> /home/greg/.ssh/authorized_keys # Set hostname INSTANCE_ID=$(curl -s http://169.254.169.254/latest/meta-data/instance-id) diff --git a/aws/aws_simple/modules/ec2/ec2-east/variables.tf b/aws/aws_simple/modules/ec2/ec2-east/variables.tf index 068b688..db897bd 100644 --- a/aws/aws_simple/modules/ec2/ec2-east/variables.tf +++ b/aws/aws_simple/modules/ec2/ec2-east/variables.tf @@ -3,13 +3,11 @@ variable "min_size" { type = number description = "Minimum number of instances in the Auto Scaling Group" - default = 1 } variable "max_size" { type = number description = "Maximum number of instances in the Auto Scaling Group" - default = 1 } diff --git a/aws/aws_simple/modules/ec2/ec2-west/terraform.tfvars b/aws/aws_simple/modules/ec2/ec2-west/terraform.tfvars index 62c817a..a3c3722 100644 --- a/aws/aws_simple/modules/ec2/ec2-west/terraform.tfvars +++ b/aws/aws_simple/modules/ec2/ec2-west/terraform.tfvars @@ -1,2 +1,2 @@ -min_size = 3 -max_size = 10 \ No newline at end of file +min_size = "3" +max_size = "10" \ No newline at end of file diff --git a/aws/aws_simple/modules/ec2/ec2-west/user-data.sh b/aws/aws_simple/modules/ec2/ec2-west/user-data.sh index bb81c28..b845ff9 100644 --- a/aws/aws_simple/modules/ec2/ec2-west/user-data.sh +++ b/aws/aws_simple/modules/ec2/ec2-west/user-data.sh @@ -16,8 +16,8 @@ sudo chmod 600 /home/greg/.ssh/authorized_keys sudo chown -R greg:greg /home/greg/.ssh # Add your public key to authorized_keys -sudo echo "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCdOF80z0piQEnYzNCu2OGvOJdm7+3wfDuiC+Jzi8VbSC5VW4iJAQXOuDNGLzyqNi6uMjI77xpEL6Xzn29uJiQti6Y/LxhOZwNNIQiGUpFco1wkBYeBFbtgHQxsMLwumrxQGEj2fyCiSrACAPyy/l1fP4mlN7abBGD5aozBrYKxXPS/kfwO5nsWmw27RgTzfHJzie2dUU3ew/kd7td3wEdWrRXq8wNbu+yvAyiog54huUUWmYZwY3QVwXr6R1wsVudawM6BEl45QFq+hdB4t83azHG94XLy2NCAncohdU7zP40nsbvIDyh+4wIKeU90z6TLrXfHUYuBT6/ky7qOFm/Ym1QG4zCDz3jin8Qoa31PGaObzj/zoMJXgOXKcp16W0j9SZAenvnSfuWUEfBR1yBRR0T5Wg5v1vi7KGBTATaz8el802uliL+yZbGtMbNpAPGR5nK5C4yorf8yVYvIgo/LJaWCDND2O1e2mdut1WyRmvIwMnq7PFZT8zAsgGXfhDM= greg@ligma -" >> /home/greg/.ssh/authorized_keys +sudo echo " +ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCdOF80z0piQEnYzNCu2OGvOJdm7+3wfDuiC+Jzi8VbSC5VW4iJAQXOuDNGLzyqNi6uMjI77xpEL6Xzn29uJiQti6Y/LxhOZwNNIQiGUpFco1wkBYeBFbtgHQxsMLwumrxQGEj2fyCiSrACAPyy/l1fP4mlN7abBGD5aozBrYKxXPS/kfwO5nsWmw27RgTzfHJzie2dUU3ew/kd7td3wEdWrRXq8wNbu+yvAyiog54huUUWmYZwY3QVwXr6R1wsVudawM6BEl45QFq+hdB4t83azHG94XLy2NCAncohdU7zP40nsbvIDyh+4wIKeU90z6TLrXfHUYuBT6/ky7qOFm/Ym1QG4zCDz3jin8Qoa31PGaObzj/zoMJXgOXKcp16W0j9SZAenvnSfuWUEfBR1yBRR0T5Wg5v1vi7KGBTATaz8el802uliL+yZbGtMbNpAPGR5nK5C4yorf8yVYvIgo/LJaWCDND2O1e2mdut1WyRmvIwMnq7PFZT8zAsgGXfhDM= greg@ligma" >> /home/greg/.ssh/authorized_keys # Set hostname INSTANCE_ID=$(curl -s http://169.254.169.254/latest/meta-data/instance-id) diff --git a/aws/aws_simple/modules/ec2/ec2-west/variables.tf b/aws/aws_simple/modules/ec2/ec2-west/variables.tf index 13e92ed..dd4bd97 100644 --- a/aws/aws_simple/modules/ec2/ec2-west/variables.tf +++ b/aws/aws_simple/modules/ec2/ec2-west/variables.tf @@ -3,13 +3,11 @@ variable "min_size" { type = number description = "Minimum number of instances in the Auto Scaling Group" - default = 1 } variable "max_size" { type = number description = "Maximum number of instances in the Auto Scaling Group" - default = 1 } variable "us_west_subnet_1_id" { From 524d36b239a296ed43dced62475e46786ff19b28 Mon Sep 17 00:00:00 2001 From: Greg Hendrickson Date: Fri, 17 Nov 2023 12:56:07 -0800 Subject: [PATCH 05/17] TODO: fix efs later. s3 backend created --- .gitignore | 8 ++++ aws/aws_simple/main.tf | 25 +++++++++-- aws/aws_simple/modules/efs/main.tf | 60 +++++++++++++++++++++++++ aws/aws_simple/modules/efs/outputs.tf | 0 aws/aws_simple/modules/efs/variables.tf | 31 +++++++++++++ aws/backend/main.tf | 9 ++++ aws/s3/main.tf | 24 ++++++++++ 7 files changed, 154 insertions(+), 3 deletions(-) create mode 100644 aws/aws_simple/modules/efs/outputs.tf create mode 100644 aws/aws_simple/modules/efs/variables.tf create mode 100644 aws/backend/main.tf create mode 100644 aws/s3/main.tf diff --git a/.gitignore b/.gitignore index 7f01bc4..92d672e 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,11 @@ aws/aws_simple/terraform.tfstate.backup aws/aws_simple/terraform.tfstate aws/aws_simple/.terraform/providers/registry.terraform.io/hashicorp/aws/5.25.0/linux_amd64/terraform-provider-aws_v5.25.0_x5 aws/aws_simple/.terraform.tfstate.lock.info +aws/backend/terraform.tfstate +aws/s3/.terraform.lock.hcl +aws/s3/terraform.tfstate +aws/s3/terraform.tfstate.backup +aws/s3/.terraform/providers/registry.terraform.io/hashicorp/aws/5.26.0/linux_amd64/terraform-provider-aws_v5.26.0_x5 +aws/aws_simple/.terraform/providers/registry.terraform.io/hashicorp/template/2.2.0/linux_amd64/terraform-provider-template_v2.2.0_x4 +aws/aws_simple/.terraform/providers/registry.terraform.io/hashicorp/aws/5.26.0/linux_amd64/terraform-provider-aws_v5.26.0_x5 +aws/aws_simple/.terraform/terraform.tfstate diff --git a/aws/aws_simple/main.tf b/aws/aws_simple/main.tf index 99a90d7..dd174f2 100644 --- a/aws/aws_simple/main.tf +++ b/aws/aws_simple/main.tf @@ -1,3 +1,10 @@ +terraform { + backend "s3" { + bucket = "my-tf-bucket-ghndrx" + key = "terraform.tfstate" + region = "us-west-2" + } +} # Define provider provider "aws" { region = var.aws_region @@ -31,9 +38,11 @@ module "subnets_us_east" { vpc_id_east_1 = module.vpc-east.vpc_id_east_1 } -module "ec2" { +module "ec2-east" { source = "./modules/ec2/ec2-east" - + + min_size = "4" + max_size = "10" us_east_subnet_1_id = module.subnets_us_east.us_east_subnet_1_id us_east_subnet_2_id = module.subnets_us_east.us_east_subnet_2_id us_east_subnet_3_id = module.subnets_us_east.us_east_subnet_3_id @@ -43,7 +52,9 @@ module "ec2" { module "ec2-west" { source = "./modules/ec2/ec2-west" - + + min_size = "4" + max_size = "10" us_west_subnet_1_id = module.subnets_us_west.us_west_subnet_1_id us_west_subnet_2_id = module.subnets_us_west.us_west_subnet_2_id us_west_subnet_3_id = module.subnets_us_west.us_west_subnet_3_id @@ -58,4 +69,12 @@ module "elb" { module "efs" { source = "./modules/efs" + + us_east_subnet_1_id = module.subnets_us_east.us_east_subnet_1_id + us_east_subnet_2_id = module.subnets_us_east.us_east_subnet_2_id + us_east_subnet_3_id = module.subnets_us_east.us_east_subnet_3_id + us_west_subnet_1_id = module.subnets_us_west.us_west_subnet_1_id + us_west_subnet_2_id = module.subnets_us_west.us_west_subnet_2_id + us_west_subnet_3_id = module.subnets_us_west.us_west_subnet_3_id + } diff --git a/aws/aws_simple/modules/efs/main.tf b/aws/aws_simple/modules/efs/main.tf index e69de29..951a747 100644 --- a/aws/aws_simple/modules/efs/main.tf +++ b/aws/aws_simple/modules/efs/main.tf @@ -0,0 +1,60 @@ +resource "aws_efs_file_system" "efs" { + creation_token = "efs-asg-west-east" + encrypted = true + performance_mode = "generalPurpose" + throughput_mode = "bursting" +} + + + +resource "aws_efs_mount_target" "us_west_subnet_1" { + file_system_id = aws_efs_file_system.efs.id + subnet_id = var.us_west_subnet_1_id + depends_on = [var.us_west_subnet_1_id] +} + +resource "aws_efs_mount_target" "us_west_subnet_2" { + file_system_id = aws_efs_file_system.efs.id + subnet_id = var.us_west_subnet_2_id + depends_on = [var.us_west_subnet_2_id] +} + +resource "aws_efs_mount_target" "us_west_subnet_3" { + file_system_id = aws_efs_file_system.efs.id + subnet_id = var.us_west_subnet_3_id + depends_on = [var.us_west_subnet_3_id] +} + +data "template_file" "mount_script" { + template = <> /etc/fstab +mount -a -t efs,nfs4 defaults +EOF +} + +provider "aws" { + region = "us-east-1" + + +} + +resource "aws_efs_mount_target" "us_east_subnet_1" { + file_system_id = aws_efs_file_system.efs.id + subnet_id = var.us_east_subnet_1_id + depends_on = [var.us_east_subnet_1_id] +} + +resource "aws_efs_mount_target" "us_east_subnet_2" { + file_system_id = aws_efs_file_system.efs.id + subnet_id = var.us_east_subnet_2_id + depends_on = [var.us_east_subnet_2_id] +} + +resource "aws_efs_mount_target" "us_east_subnet_3" { + file_system_id = aws_efs_file_system.efs.id + subnet_id = var.us_east_subnet_3_id + depends_on = [var.us_east_subnet_3_id] +} \ No newline at end of file diff --git a/aws/aws_simple/modules/efs/outputs.tf b/aws/aws_simple/modules/efs/outputs.tf new file mode 100644 index 0000000..e69de29 diff --git a/aws/aws_simple/modules/efs/variables.tf b/aws/aws_simple/modules/efs/variables.tf new file mode 100644 index 0000000..ad01200 --- /dev/null +++ b/aws/aws_simple/modules/efs/variables.tf @@ -0,0 +1,31 @@ +variable "us_east_subnet_1_id" { + description = "The ID of the first US East subnet" + type = string +} + +variable "us_east_subnet_2_id" { + description = "The ID of the second US East subnet" + type = string +} + +variable "us_east_subnet_3_id" { + description = "The ID of the third US East subnet" + type = string +} + +variable "us_west_subnet_1_id" { + description = "The ID of the first US East subnet" + type = string +} + +variable "us_west_subnet_2_id" { + description = "The ID of the second US East subnet" + type = string +} + +variable "us_west_subnet_3_id" { + description = "The ID of the third US East subnet" + type = string +} + + \ No newline at end of file diff --git a/aws/backend/main.tf b/aws/backend/main.tf new file mode 100644 index 0000000..e89474e --- /dev/null +++ b/aws/backend/main.tf @@ -0,0 +1,9 @@ +terraform { + backend "s3" { + bucket = "my-tf-bucket-ghndrx" + key = "terraform.tfstate" + region = "us-west-2" + } +} + +# Rest of your Terraform configuration goes here... diff --git a/aws/s3/main.tf b/aws/s3/main.tf new file mode 100644 index 0000000..a0735a5 --- /dev/null +++ b/aws/s3/main.tf @@ -0,0 +1,24 @@ +# Provider configuration +provider "aws" { + region = "us-west-2" + # Add your AWS access and secret keys here + +} + +resource "aws_s3_bucket" "my-tf-bucket-ghndrx" { + bucket = "my-tf-bucket-ghndrx" + + tags = { + Name = "tf-backend" + Environment = "production" + } +} + +# Output the bucket name +output "my-tf-bucket-ghndrx" { + value = aws_s3_bucket.my-tf-bucket-ghndrx.bucket +} + + + + From 5bd7a7562b847caccc7e1c903db4edc082861459 Mon Sep 17 00:00:00 2001 From: Greg Hendrickson Date: Fri, 17 Nov 2023 14:02:43 -0800 Subject: [PATCH 06/17] remove efs elb --- aws/aws_simple/main.tf | 16 ------- aws/aws_simple/modules/efs/main.tf | 60 ------------------------- aws/aws_simple/modules/efs/outputs.tf | 0 aws/aws_simple/modules/efs/variables.tf | 31 ------------- aws/aws_simple/modules/elb/main.tf | 0 5 files changed, 107 deletions(-) delete mode 100644 aws/aws_simple/modules/efs/main.tf delete mode 100644 aws/aws_simple/modules/efs/outputs.tf delete mode 100644 aws/aws_simple/modules/efs/variables.tf delete mode 100644 aws/aws_simple/modules/elb/main.tf diff --git a/aws/aws_simple/main.tf b/aws/aws_simple/main.tf index dd174f2..55a75f9 100644 --- a/aws/aws_simple/main.tf +++ b/aws/aws_simple/main.tf @@ -62,19 +62,3 @@ module "ec2-west" { vpc_id_west_2 = module.vpc-west.vpc_id_west_2 } - -module "elb" { - source = "./modules/elb" -} - -module "efs" { - source = "./modules/efs" - - us_east_subnet_1_id = module.subnets_us_east.us_east_subnet_1_id - us_east_subnet_2_id = module.subnets_us_east.us_east_subnet_2_id - us_east_subnet_3_id = module.subnets_us_east.us_east_subnet_3_id - us_west_subnet_1_id = module.subnets_us_west.us_west_subnet_1_id - us_west_subnet_2_id = module.subnets_us_west.us_west_subnet_2_id - us_west_subnet_3_id = module.subnets_us_west.us_west_subnet_3_id - -} diff --git a/aws/aws_simple/modules/efs/main.tf b/aws/aws_simple/modules/efs/main.tf deleted file mode 100644 index 951a747..0000000 --- a/aws/aws_simple/modules/efs/main.tf +++ /dev/null @@ -1,60 +0,0 @@ -resource "aws_efs_file_system" "efs" { - creation_token = "efs-asg-west-east" - encrypted = true - performance_mode = "generalPurpose" - throughput_mode = "bursting" -} - - - -resource "aws_efs_mount_target" "us_west_subnet_1" { - file_system_id = aws_efs_file_system.efs.id - subnet_id = var.us_west_subnet_1_id - depends_on = [var.us_west_subnet_1_id] -} - -resource "aws_efs_mount_target" "us_west_subnet_2" { - file_system_id = aws_efs_file_system.efs.id - subnet_id = var.us_west_subnet_2_id - depends_on = [var.us_west_subnet_2_id] -} - -resource "aws_efs_mount_target" "us_west_subnet_3" { - file_system_id = aws_efs_file_system.efs.id - subnet_id = var.us_west_subnet_3_id - depends_on = [var.us_west_subnet_3_id] -} - -data "template_file" "mount_script" { - template = <> /etc/fstab -mount -a -t efs,nfs4 defaults -EOF -} - -provider "aws" { - region = "us-east-1" - - -} - -resource "aws_efs_mount_target" "us_east_subnet_1" { - file_system_id = aws_efs_file_system.efs.id - subnet_id = var.us_east_subnet_1_id - depends_on = [var.us_east_subnet_1_id] -} - -resource "aws_efs_mount_target" "us_east_subnet_2" { - file_system_id = aws_efs_file_system.efs.id - subnet_id = var.us_east_subnet_2_id - depends_on = [var.us_east_subnet_2_id] -} - -resource "aws_efs_mount_target" "us_east_subnet_3" { - file_system_id = aws_efs_file_system.efs.id - subnet_id = var.us_east_subnet_3_id - depends_on = [var.us_east_subnet_3_id] -} \ No newline at end of file diff --git a/aws/aws_simple/modules/efs/outputs.tf b/aws/aws_simple/modules/efs/outputs.tf deleted file mode 100644 index e69de29..0000000 diff --git a/aws/aws_simple/modules/efs/variables.tf b/aws/aws_simple/modules/efs/variables.tf deleted file mode 100644 index ad01200..0000000 --- a/aws/aws_simple/modules/efs/variables.tf +++ /dev/null @@ -1,31 +0,0 @@ -variable "us_east_subnet_1_id" { - description = "The ID of the first US East subnet" - type = string -} - -variable "us_east_subnet_2_id" { - description = "The ID of the second US East subnet" - type = string -} - -variable "us_east_subnet_3_id" { - description = "The ID of the third US East subnet" - type = string -} - -variable "us_west_subnet_1_id" { - description = "The ID of the first US East subnet" - type = string -} - -variable "us_west_subnet_2_id" { - description = "The ID of the second US East subnet" - type = string -} - -variable "us_west_subnet_3_id" { - description = "The ID of the third US East subnet" - type = string -} - - \ No newline at end of file diff --git a/aws/aws_simple/modules/elb/main.tf b/aws/aws_simple/modules/elb/main.tf deleted file mode 100644 index e69de29..0000000 From 82b9757d1b5ffc58116ce901690129bb5900c6c7 Mon Sep 17 00:00:00 2001 From: Greg Hendrickson Date: Fri, 17 Nov 2023 15:20:15 -0800 Subject: [PATCH 07/17] +space --- aws/aws_simple/main.tf | 2 ++ 1 file changed, 2 insertions(+) diff --git a/aws/aws_simple/main.tf b/aws/aws_simple/main.tf index 55a75f9..5d2fce2 100644 --- a/aws/aws_simple/main.tf +++ b/aws/aws_simple/main.tf @@ -14,6 +14,7 @@ provider "aws" { module "vpc-east" { source = "./modules/vpc/vpc-east" region = "us-east-1" + us_east_subnet_1_id = module.subnets_us_east.us_east_subnet_1_id us_east_subnet_2_id = module.subnets_us_east.us_east_subnet_2_id us_east_subnet_3_id = module.subnets_us_east.us_east_subnet_3_id @@ -22,6 +23,7 @@ module "vpc-east" { module "vpc-west" { source = "./modules/vpc/vpc-west" region = "us-west-2" + us_west_subnet_1_id = module.subnets_us_west.us_west_subnet_1_id us_west_subnet_2_id = module.subnets_us_west.us_west_subnet_2_id us_west_subnet_3_id = module.subnets_us_west.us_west_subnet_3_id From cd1b4531a285019961d55958763f038036143208 Mon Sep 17 00:00:00 2001 From: Greg Hendrickson Date: Fri, 17 Nov 2023 15:21:46 -0800 Subject: [PATCH 08/17] example-backend --- .gitignore | 1 + aws/{backend => example-backend}/main.tf | 0 2 files changed, 1 insertion(+) rename aws/{backend => example-backend}/main.tf (100%) diff --git a/.gitignore b/.gitignore index 92d672e..13264f6 100644 --- a/.gitignore +++ b/.gitignore @@ -12,3 +12,4 @@ aws/s3/.terraform/providers/registry.terraform.io/hashicorp/aws/5.26.0/linux_amd aws/aws_simple/.terraform/providers/registry.terraform.io/hashicorp/template/2.2.0/linux_amd64/terraform-provider-template_v2.2.0_x4 aws/aws_simple/.terraform/providers/registry.terraform.io/hashicorp/aws/5.26.0/linux_amd64/terraform-provider-aws_v5.26.0_x5 aws/aws_simple/.terraform/terraform.tfstate +aws/example-backend/terraform.tfstate diff --git a/aws/backend/main.tf b/aws/example-backend/main.tf similarity index 100% rename from aws/backend/main.tf rename to aws/example-backend/main.tf From a27a3737fcded8062db21ae199202d1fc0e0703a Mon Sep 17 00:00:00 2001 From: Greg Hendrickson Date: Fri, 17 Nov 2023 16:59:14 -0800 Subject: [PATCH 09/17] add aws_vpc_peering --- .gitignore | 4 + aws/aws_vpc_peering/main.tf | 303 +++++ aws/aws_vpc_peering/terraform.tfstate.backup | 1225 ++++++++++++++++++ aws/aws_vpc_peering/user-data.sh | 31 + 4 files changed, 1563 insertions(+) create mode 100644 aws/aws_vpc_peering/main.tf create mode 100644 aws/aws_vpc_peering/terraform.tfstate.backup create mode 100644 aws/aws_vpc_peering/user-data.sh diff --git a/.gitignore b/.gitignore index 13264f6..e58c84c 100644 --- a/.gitignore +++ b/.gitignore @@ -13,3 +13,7 @@ aws/aws_simple/.terraform/providers/registry.terraform.io/hashicorp/template/2.2 aws/aws_simple/.terraform/providers/registry.terraform.io/hashicorp/aws/5.26.0/linux_amd64/terraform-provider-aws_v5.26.0_x5 aws/aws_simple/.terraform/terraform.tfstate aws/example-backend/terraform.tfstate +aws/aws_vpc_peering/.terraform.lock.hcl +aws/aws_vpc_peering/terraform.tfstate +.gitignore +aws/aws_vpc_peering/.terraform/providers/registry.terraform.io/hashicorp/aws/5.26.0/linux_amd64/terraform-provider-aws_v5.26.0_x5 diff --git a/aws/aws_vpc_peering/main.tf b/aws/aws_vpc_peering/main.tf new file mode 100644 index 0000000..c2d5a76 --- /dev/null +++ b/aws/aws_vpc_peering/main.tf @@ -0,0 +1,303 @@ +# Define AWS provider with aliases for us-west-1 and us-east-1 regions +provider "aws" { + alias = "us-west-1" + region = "us-west-1" +} + +provider "aws" { + alias = "us-east-1" + region = "us-east-1" +} + +# Create VPCs in us-west-1 and us-east-1 regions +resource "aws_vpc" "us-west-1" { + cidr_block = "10.0.0.0/16" + provider = aws.us-west-1 +} + +resource "aws_vpc" "us-east-1" { + cidr_block = "10.1.0.0/16" + provider = aws.us-east-1 +} + +# Create subnets in us-west-1 VPC +resource "aws_subnet" "us-west-1-subnet-1" { + vpc_id = aws_vpc.us-west-1.id + cidr_block = "10.0.1.0/24" + availability_zone = "us-west-1c" + provider = aws.us-west-1 +} + +resource "aws_subnet" "us-west-1-subnet-2" { + vpc_id = aws_vpc.us-west-1.id + cidr_block = "10.0.2.0/24" + availability_zone = "us-west-1b" + provider = aws.us-west-1 +} + +# Create subnets in us-east-1 VPC +resource "aws_subnet" "us-east-1-subnet-1" { + vpc_id = aws_vpc.us-east-1.id + cidr_block = "10.1.1.0/24" + availability_zone = "us-east-1c" + provider = aws.us-east-1 +} + + + +resource "aws_subnet" "us-east-1-subnet-2" { + vpc_id = aws_vpc.us-east-1.id + cidr_block = "10.1.2.0/24" + availability_zone = "us-east-1b" + provider = aws.us-east-1 +} + +# Create VPC peering connection between us-west-1 and us-east-1 VPCs +resource "aws_vpc_peering_connection" "peering_connection" { + vpc_id = aws_vpc.us-west-1.id + peer_vpc_id = aws_vpc.us-east-1.id + peer_region = "us-east-1" + auto_accept = false + provider = aws.us-west-1 +} + +# Create VPC peering connection accepter in us-east-1 region +resource "aws_vpc_peering_connection_accepter" "peering_accepter" { + vpc_peering_connection_id = aws_vpc_peering_connection.peering_connection.id + auto_accept = true + + provider = aws.us-east-1 +} + +# Create route tables for each VPC and associate them with the respective subnets +resource "aws_route_table" "us-west-1-route-table" { + vpc_id = aws_vpc.us-west-1.id + provider = aws.us-west-1 +} + +resource "aws_route_table_association" "us-west-1-subnet-1-association" { + subnet_id = aws_subnet.us-west-1-subnet-1.id + route_table_id = aws_route_table.us-west-1-route-table.id + provider = aws.us-west-1 +} + +resource "aws_route_table_association" "us-west-1-subnet-2-association" { + subnet_id = aws_subnet.us-west-1-subnet-2.id + route_table_id = aws_route_table.us-west-1-route-table.id + provider = aws.us-west-1 +} + +resource "aws_route_table" "us-east-1-route-table" { + vpc_id = aws_vpc.us-east-1.id + provider = aws.us-east-1 +} + +resource "aws_route_table_association" "us-east-1-subnet-1-association" { + subnet_id = aws_subnet.us-east-1-subnet-1.id + route_table_id = aws_route_table.us-east-1-route-table.id + provider = aws.us-east-1 +} + +resource "aws_route_table_association" "us-east-1-subnet-2-association" { + subnet_id = aws_subnet.us-east-1-subnet-2.id + route_table_id = aws_route_table.us-east-1-route-table.id + provider = aws.us-east-1 +} + + +# Create internet gateway for us-west-1 VPC +resource "aws_internet_gateway" "us-west-1-igw" { + vpc_id = aws_vpc.us-west-1.id + provider = aws.us-west-1 + + tags = { + Name = "us-west-1-igw" + } +} + +# Create internet gateway for us-east-1 VPC +resource "aws_internet_gateway" "us-east-1-igw" { + vpc_id = aws_vpc.us-east-1.id + provider = aws.us-east-1 + + tags = { + Name = "us-east-1-igw" + } +} + +# Attach internet gateway to the route table of each VPC +resource "aws_route" "us-west-1-igw-route" { + route_table_id = aws_route_table.us-west-1-route-table.id + destination_cidr_block = "0.0.0.0/0" + gateway_id = aws_internet_gateway.us-west-1-igw.id + provider = aws.us-west-1 +} + +resource "aws_route" "us-east-1-igw-route" { + route_table_id = aws_route_table.us-east-1-route-table.id + destination_cidr_block = "0.0.0.0/0" + gateway_id = aws_internet_gateway.us-east-1-igw.id + provider = aws.us-east-1 +} + +# Create security groups for EC2 instances +resource "aws_security_group" "us-west-1-instance-sg" { + vpc_id = aws_vpc.us-west-1.id + provider = aws.us-west-1 + tags = { + Name = "instance-west-security-group" + } + + # Allow inbound SSH, HTTP, and HTTPS traffic from any source + ingress { + from_port = 22 + to_port = 22 + protocol = "tcp" + cidr_blocks = ["0.0.0.0/0"] + } + + ingress { + from_port = 80 + to_port = 80 + protocol = "tcp" + cidr_blocks = ["0.0.0.0/0"] + } + + ingress { + from_port = 443 + to_port = 443 + protocol = "tcp" + cidr_blocks = ["0.0.0.0/0"] + } + + # Allow outbound traffic to all private subnets in the VPC + egress { + from_port = 0 + to_port = 0 + protocol = "-1" + cidr_blocks = ["10.1.0.0/16", "0.0.0.0/0"] + } +} + +resource "aws_security_group" "us-east-1-instance-sg" { + vpc_id = aws_vpc.us-east-1.id + provider = aws.us-east-1 + tags = { + Name = "instance-east-security-group" + } + + # Allow inbound SSH, HTTP, and HTTPS traffic from any source + ingress { + from_port = 22 + to_port = 22 + protocol = "tcp" + cidr_blocks = ["0.0.0.0/0"] + } + + ingress { + from_port = 80 + to_port = 80 + protocol = "tcp" + cidr_blocks = ["0.0.0.0/0"] + } + + ingress { + from_port = 443 + to_port = 443 + protocol = "tcp" + cidr_blocks = ["0.0.0.0/0"] + } + + # Allow outbound traffic to all private subnets in the VPC + egress { + from_port = 0 + to_port = 0 + protocol = "-1" + cidr_blocks = ["10.1.0.0/16", "0.0.0.0/0"] + } +} + +# Create EC2 instances in each subnet +resource "aws_instance" "us-west-1-instance-1" { + ami = "ami-0f3f6663da6750955" # Ubuntu 20.04 AMI + instance_type = "t3.small" # Add instance type + subnet_id = aws_subnet.us-west-1-subnet-1.id + vpc_security_group_ids = [aws_security_group.us-west-1-instance-sg.id] + associate_public_ip_address = true # Set ephemeral public IP address + user_data = base64encode(file("${path.module}/user-data.sh")) + # Other necessary configurations for the instance + provider = aws.us-west-1 + # ... + tags = { + Name = "us-west-1-instance-1" + SecurityGroup = "instance-west-security-group" + } +} + +resource "aws_instance" "us-west-1-instance-2" { + ami = "ami-0f3f6663da6750955" # Ubuntu 20.04 AMI + instance_type = "t3.small" # Add instance type + subnet_id = aws_subnet.us-west-1-subnet-2.id + vpc_security_group_ids = [aws_security_group.us-west-1-instance-sg.id] + associate_public_ip_address = true # Set ephemeral public IP address + user_data = base64encode(file("${path.module}/user-data.sh")) + # Other necessary configurations for the instance + provider = aws.us-west-1 + # ... + tags = { + Name = "us-west-1-instance-2" + SecurityGroup = "instance-west-security-group" + } +} + +resource "aws_instance" "us-east-1-instance-1" { + ami = "ami-04e369782a6d2125e" # Ubuntu 20.04 AMI + instance_type = "t3.small" # Add instance type + subnet_id = aws_subnet.us-east-1-subnet-1.id + vpc_security_group_ids = [aws_security_group.us-east-1-instance-sg.id] + associate_public_ip_address = true # Set ephemeral public IP address + user_data = base64encode(file("${path.module}/user-data.sh")) + # Other necessary configurations for the instance + provider = aws.us-east-1 + # ... + tags = { + Name = "us-east-1-instance-1" + SecurityGroup = "instance-east-security-group" + } +} + +resource "aws_instance" "us-east-1-instance-2" { + ami = "ami-04e369782a6d2125e" # Ubuntu 20.04 AMI + instance_type = "t3.small" # Add instance type + subnet_id = aws_subnet.us-east-1-subnet-2.id + vpc_security_group_ids = [aws_security_group.us-east-1-instance-sg.id] + associate_public_ip_address = true # Set ephemeral public IP address + user_data = base64encode(file("${path.module}/user-data.sh")) + # Other necessary configurations for the instance + provider = aws.us-east-1 + # ... + tags = { + Name = "us-east-1-instance-2" + SecurityGroup = "instance-east-security-group" + } +} + +# ... + +output "us-west-1-instance-1-public-ip" { + value = aws_instance.us-west-1-instance-1.public_ip +} + +output "us-west-1-instance-2-public-ip" { + value = aws_instance.us-west-1-instance-2.public_ip +} + +output "us-east-1-instance-1-public-ip" { + value = aws_instance.us-east-1-instance-1.public_ip +} + +output "us-east-1-instance-2-public-ip" { + value = aws_instance.us-east-1-instance-2.public_ip +} + + diff --git a/aws/aws_vpc_peering/terraform.tfstate.backup b/aws/aws_vpc_peering/terraform.tfstate.backup new file mode 100644 index 0000000..1d99e40 --- /dev/null +++ b/aws/aws_vpc_peering/terraform.tfstate.backup @@ -0,0 +1,1225 @@ +{ + "version": 4, + "terraform_version": "1.6.4", + "serial": 238, + "lineage": "061fcdf6-790c-d6b1-daa8-0a270cb1098d", + "outputs": { + "us-east-1-instance-1-public-ip": { + "value": "35.170.185.226", + "type": "string" + }, + "us-east-1-instance-2-public-ip": { + "value": "3.239.202.177", + "type": "string" + }, + "us-west-1-instance-1-public-ip": { + "value": "54.183.139.140", + "type": "string" + }, + "us-west-1-instance-2-public-ip": { + "value": "54.67.94.5", + "type": "string" + } + }, + "resources": [ + { + "mode": "managed", + "type": "aws_instance", + "name": "us-east-1-instance-1", + "provider": "provider[\"registry.terraform.io/hashicorp/aws\"].us-east-1", + "instances": [ + { + "schema_version": 1, + "attributes": { + "ami": "ami-04e369782a6d2125e", + "arn": "arn:aws:ec2:us-east-1:349761350494:instance/i-0af840dc385d7adcb", + "associate_public_ip_address": true, + "availability_zone": "us-east-1c", + "capacity_reservation_specification": [ + { + "capacity_reservation_preference": "open", + "capacity_reservation_target": [] + } + ], + "cpu_core_count": 1, + "cpu_options": [ + { + "amd_sev_snp": "", + "core_count": 1, + "threads_per_core": 2 + } + ], + "cpu_threads_per_core": 2, + "credit_specification": [ + { + "cpu_credits": "unlimited" + } + ], + "disable_api_stop": false, + "disable_api_termination": false, + "ebs_block_device": [], + "ebs_optimized": false, + "enclave_options": [ + { + "enabled": false + } + ], + "ephemeral_block_device": [], + "get_password_data": false, + "hibernation": false, + "host_id": "", + "host_resource_group_arn": null, + "iam_instance_profile": "", + "id": "i-0af840dc385d7adcb", + "instance_initiated_shutdown_behavior": "stop", + "instance_lifecycle": "", + "instance_market_options": [], + "instance_state": "running", + "instance_type": "t3.small", + "ipv6_address_count": 0, + "ipv6_addresses": [], + "key_name": "", + "launch_template": [], + "maintenance_options": [ + { + "auto_recovery": "default" + } + ], + "metadata_options": [ + { + "http_endpoint": "enabled", + "http_protocol_ipv6": "disabled", + "http_put_response_hop_limit": 1, + "http_tokens": "optional", + "instance_metadata_tags": "disabled" + } + ], + "monitoring": false, + "network_interface": [], + "outpost_arn": "", + "password_data": "", + "placement_group": "", + "placement_partition_number": 0, + "primary_network_interface_id": "eni-0346c453f64b7b8ff", + "private_dns": "ip-10-1-1-87.ec2.internal", + "private_dns_name_options": [ + { + "enable_resource_name_dns_a_record": false, + "enable_resource_name_dns_aaaa_record": false, + "hostname_type": "ip-name" + } + ], + "private_ip": "10.1.1.87", + "public_dns": "", + "public_ip": "35.170.185.226", + "root_block_device": [ + { + "delete_on_termination": true, + "device_name": "/dev/sda1", + "encrypted": false, + "iops": 100, + "kms_key_id": "", + "tags": {}, + "throughput": 0, + "volume_id": "vol-0007cfd358eb7ee8b", + "volume_size": 8, + "volume_type": "gp2" + } + ], + "secondary_private_ips": [], + "security_groups": [], + "source_dest_check": true, + "spot_instance_request_id": "", + "subnet_id": "subnet-0b8fd542ac3ac99f0", + "tags": { + "Name": "us-east-1-instance-1", + "SecurityGroup": "instance-east-security-group" + }, + "tags_all": { + "Name": "us-east-1-instance-1", + "SecurityGroup": "instance-east-security-group" + }, + "tenancy": "default", + "timeouts": null, + "user_data": "cea2287097610e79f3bb839fad39d116ded10b48", + "user_data_base64": null, + "user_data_replace_on_change": false, + "volume_tags": null, + "vpc_security_group_ids": [ + "sg-0c4cb030408e58dd3" + ] + }, + "sensitive_attributes": [], + "private": "eyJlMmJmYjczMC1lY2FhLTExZTYtOGY4OC0zNDM2M2JjN2M0YzAiOnsiY3JlYXRlIjo2MDAwMDAwMDAwMDAsImRlbGV0ZSI6MTIwMDAwMDAwMDAwMCwidXBkYXRlIjo2MDAwMDAwMDAwMDB9LCJzY2hlbWFfdmVyc2lvbiI6IjEifQ==", + "dependencies": [ + "aws_security_group.us-east-1-instance-sg", + "aws_subnet.us-east-1-subnet-1", + "aws_vpc.us-east-1" + ] + } + ] + }, + { + "mode": "managed", + "type": "aws_instance", + "name": "us-east-1-instance-2", + "provider": "provider[\"registry.terraform.io/hashicorp/aws\"].us-east-1", + "instances": [ + { + "schema_version": 1, + "attributes": { + "ami": "ami-04e369782a6d2125e", + "arn": "arn:aws:ec2:us-east-1:349761350494:instance/i-0c81e8d1c35180b62", + "associate_public_ip_address": true, + "availability_zone": "us-east-1b", + "capacity_reservation_specification": [ + { + "capacity_reservation_preference": "open", + "capacity_reservation_target": [] + } + ], + "cpu_core_count": 1, + "cpu_options": [ + { + "amd_sev_snp": "", + "core_count": 1, + "threads_per_core": 2 + } + ], + "cpu_threads_per_core": 2, + "credit_specification": [ + { + "cpu_credits": "unlimited" + } + ], + "disable_api_stop": false, + "disable_api_termination": false, + "ebs_block_device": [], + "ebs_optimized": false, + "enclave_options": [ + { + "enabled": false + } + ], + "ephemeral_block_device": [], + "get_password_data": false, + "hibernation": false, + "host_id": "", + "host_resource_group_arn": null, + "iam_instance_profile": "", + "id": "i-0c81e8d1c35180b62", + "instance_initiated_shutdown_behavior": "stop", + "instance_lifecycle": "", + "instance_market_options": [], + "instance_state": "running", + "instance_type": "t3.small", + "ipv6_address_count": 0, + "ipv6_addresses": [], + "key_name": "", + "launch_template": [], + "maintenance_options": [ + { + "auto_recovery": "default" + } + ], + "metadata_options": [ + { + "http_endpoint": "enabled", + "http_protocol_ipv6": "disabled", + "http_put_response_hop_limit": 1, + "http_tokens": "optional", + "instance_metadata_tags": "disabled" + } + ], + "monitoring": false, + "network_interface": [], + "outpost_arn": "", + "password_data": "", + "placement_group": "", + "placement_partition_number": 0, + "primary_network_interface_id": "eni-0ade6c500ec9cde57", + "private_dns": "ip-10-1-2-152.ec2.internal", + "private_dns_name_options": [ + { + "enable_resource_name_dns_a_record": false, + "enable_resource_name_dns_aaaa_record": false, + "hostname_type": "ip-name" + } + ], + "private_ip": "10.1.2.152", + "public_dns": "", + "public_ip": "3.239.202.177", + "root_block_device": [ + { + "delete_on_termination": true, + "device_name": "/dev/sda1", + "encrypted": false, + "iops": 100, + "kms_key_id": "", + "tags": {}, + "throughput": 0, + "volume_id": "vol-0f4c13aa0554257d3", + "volume_size": 8, + "volume_type": "gp2" + } + ], + "secondary_private_ips": [], + "security_groups": [], + "source_dest_check": true, + "spot_instance_request_id": "", + "subnet_id": "subnet-0a5006434f12ab81a", + "tags": { + "Name": "us-east-1-instance-2", + "SecurityGroup": "instance-east-security-group" + }, + "tags_all": { + "Name": "us-east-1-instance-2", + "SecurityGroup": "instance-east-security-group" + }, + "tenancy": "default", + "timeouts": null, + "user_data": "cea2287097610e79f3bb839fad39d116ded10b48", + "user_data_base64": null, + "user_data_replace_on_change": false, + "volume_tags": null, + "vpc_security_group_ids": [ + "sg-0c4cb030408e58dd3" + ] + }, + "sensitive_attributes": [], + "private": "eyJlMmJmYjczMC1lY2FhLTExZTYtOGY4OC0zNDM2M2JjN2M0YzAiOnsiY3JlYXRlIjo2MDAwMDAwMDAwMDAsImRlbGV0ZSI6MTIwMDAwMDAwMDAwMCwidXBkYXRlIjo2MDAwMDAwMDAwMDB9LCJzY2hlbWFfdmVyc2lvbiI6IjEifQ==", + "dependencies": [ + "aws_security_group.us-east-1-instance-sg", + "aws_subnet.us-east-1-subnet-2", + "aws_vpc.us-east-1" + ] + } + ] + }, + { + "mode": "managed", + "type": "aws_instance", + "name": "us-west-1-instance-1", + "provider": "provider[\"registry.terraform.io/hashicorp/aws\"].us-west-1", + "instances": [ + { + "schema_version": 1, + "attributes": { + "ami": "ami-0f3f6663da6750955", + "arn": "arn:aws:ec2:us-west-1:349761350494:instance/i-0ff9245aefa0cc1c4", + "associate_public_ip_address": true, + "availability_zone": "us-west-1c", + "capacity_reservation_specification": [ + { + "capacity_reservation_preference": "open", + "capacity_reservation_target": [] + } + ], + "cpu_core_count": 1, + "cpu_options": [ + { + "amd_sev_snp": "", + "core_count": 1, + "threads_per_core": 2 + } + ], + "cpu_threads_per_core": 2, + "credit_specification": [ + { + "cpu_credits": "unlimited" + } + ], + "disable_api_stop": false, + "disable_api_termination": false, + "ebs_block_device": [], + "ebs_optimized": false, + "enclave_options": [ + { + "enabled": false + } + ], + "ephemeral_block_device": [], + "get_password_data": false, + "hibernation": false, + "host_id": "", + "host_resource_group_arn": null, + "iam_instance_profile": "", + "id": "i-0ff9245aefa0cc1c4", + "instance_initiated_shutdown_behavior": "stop", + "instance_lifecycle": "", + "instance_market_options": [], + "instance_state": "running", + "instance_type": "t3.small", + "ipv6_address_count": 0, + "ipv6_addresses": [], + "key_name": "", + "launch_template": [], + "maintenance_options": [ + { + "auto_recovery": "default" + } + ], + "metadata_options": [ + { + "http_endpoint": "enabled", + "http_protocol_ipv6": "disabled", + "http_put_response_hop_limit": 1, + "http_tokens": "optional", + "instance_metadata_tags": "disabled" + } + ], + "monitoring": false, + "network_interface": [], + "outpost_arn": "", + "password_data": "", + "placement_group": "", + "placement_partition_number": 0, + "primary_network_interface_id": "eni-0d4d0fd7c3612b6a9", + "private_dns": "ip-10-0-1-239.us-west-1.compute.internal", + "private_dns_name_options": [ + { + "enable_resource_name_dns_a_record": false, + "enable_resource_name_dns_aaaa_record": false, + "hostname_type": "ip-name" + } + ], + "private_ip": "10.0.1.239", + "public_dns": "", + "public_ip": "54.183.139.140", + "root_block_device": [ + { + "delete_on_termination": true, + "device_name": "/dev/sda1", + "encrypted": false, + "iops": 100, + "kms_key_id": "", + "tags": {}, + "throughput": 0, + "volume_id": "vol-079ca1f047f6b1740", + "volume_size": 8, + "volume_type": "gp2" + } + ], + "secondary_private_ips": [], + "security_groups": [], + "source_dest_check": true, + "spot_instance_request_id": "", + "subnet_id": "subnet-0abc3ec32314d1f41", + "tags": { + "Name": "us-west-1-instance-1", + "SecurityGroup": "instance-west-security-group" + }, + "tags_all": { + "Name": "us-west-1-instance-1", + "SecurityGroup": "instance-west-security-group" + }, + "tenancy": "default", + "timeouts": null, + "user_data": "cea2287097610e79f3bb839fad39d116ded10b48", + "user_data_base64": null, + "user_data_replace_on_change": false, + "volume_tags": null, + "vpc_security_group_ids": [ + "sg-0c50bd6752e97a00b" + ] + }, + "sensitive_attributes": [], + "private": "eyJlMmJmYjczMC1lY2FhLTExZTYtOGY4OC0zNDM2M2JjN2M0YzAiOnsiY3JlYXRlIjo2MDAwMDAwMDAwMDAsImRlbGV0ZSI6MTIwMDAwMDAwMDAwMCwidXBkYXRlIjo2MDAwMDAwMDAwMDB9LCJzY2hlbWFfdmVyc2lvbiI6IjEifQ==", + "dependencies": [ + "aws_security_group.us-west-1-instance-sg", + "aws_subnet.us-west-1-subnet-1", + "aws_vpc.us-west-1" + ] + } + ] + }, + { + "mode": "managed", + "type": "aws_instance", + "name": "us-west-1-instance-2", + "provider": "provider[\"registry.terraform.io/hashicorp/aws\"].us-west-1", + "instances": [ + { + "schema_version": 1, + "attributes": { + "ami": "ami-0f3f6663da6750955", + "arn": "arn:aws:ec2:us-west-1:349761350494:instance/i-0cad268b6a52b5208", + "associate_public_ip_address": true, + "availability_zone": "us-west-1b", + "capacity_reservation_specification": [ + { + "capacity_reservation_preference": "open", + "capacity_reservation_target": [] + } + ], + "cpu_core_count": 1, + "cpu_options": [ + { + "amd_sev_snp": "", + "core_count": 1, + "threads_per_core": 2 + } + ], + "cpu_threads_per_core": 2, + "credit_specification": [ + { + "cpu_credits": "unlimited" + } + ], + "disable_api_stop": false, + "disable_api_termination": false, + "ebs_block_device": [], + "ebs_optimized": false, + "enclave_options": [ + { + "enabled": false + } + ], + "ephemeral_block_device": [], + "get_password_data": false, + "hibernation": false, + "host_id": "", + "host_resource_group_arn": null, + "iam_instance_profile": "", + "id": "i-0cad268b6a52b5208", + "instance_initiated_shutdown_behavior": "stop", + "instance_lifecycle": "", + "instance_market_options": [], + "instance_state": "running", + "instance_type": "t3.small", + "ipv6_address_count": 0, + "ipv6_addresses": [], + "key_name": "", + "launch_template": [], + "maintenance_options": [ + { + "auto_recovery": "default" + } + ], + "metadata_options": [ + { + "http_endpoint": "enabled", + "http_protocol_ipv6": "disabled", + "http_put_response_hop_limit": 1, + "http_tokens": "optional", + "instance_metadata_tags": "disabled" + } + ], + "monitoring": false, + "network_interface": [], + "outpost_arn": "", + "password_data": "", + "placement_group": "", + "placement_partition_number": 0, + "primary_network_interface_id": "eni-05978279bb00376be", + "private_dns": "ip-10-0-2-74.us-west-1.compute.internal", + "private_dns_name_options": [ + { + "enable_resource_name_dns_a_record": false, + "enable_resource_name_dns_aaaa_record": false, + "hostname_type": "ip-name" + } + ], + "private_ip": "10.0.2.74", + "public_dns": "", + "public_ip": "54.67.94.5", + "root_block_device": [ + { + "delete_on_termination": true, + "device_name": "/dev/sda1", + "encrypted": false, + "iops": 100, + "kms_key_id": "", + "tags": {}, + "throughput": 0, + "volume_id": "vol-059bb7120b0ed7f1d", + "volume_size": 8, + "volume_type": "gp2" + } + ], + "secondary_private_ips": [], + "security_groups": [], + "source_dest_check": true, + "spot_instance_request_id": "", + "subnet_id": "subnet-0d7c68ad12d2a648b", + "tags": { + "Name": "us-west-1-instance-2", + "SecurityGroup": "instance-west-security-group" + }, + "tags_all": { + "Name": "us-west-1-instance-2", + "SecurityGroup": "instance-west-security-group" + }, + "tenancy": "default", + "timeouts": null, + "user_data": "cea2287097610e79f3bb839fad39d116ded10b48", + "user_data_base64": null, + "user_data_replace_on_change": false, + "volume_tags": null, + "vpc_security_group_ids": [ + "sg-0c50bd6752e97a00b" + ] + }, + "sensitive_attributes": [], + "private": "eyJlMmJmYjczMC1lY2FhLTExZTYtOGY4OC0zNDM2M2JjN2M0YzAiOnsiY3JlYXRlIjo2MDAwMDAwMDAwMDAsImRlbGV0ZSI6MTIwMDAwMDAwMDAwMCwidXBkYXRlIjo2MDAwMDAwMDAwMDB9LCJzY2hlbWFfdmVyc2lvbiI6IjEifQ==", + "dependencies": [ + "aws_security_group.us-west-1-instance-sg", + "aws_subnet.us-west-1-subnet-2", + "aws_vpc.us-west-1" + ] + } + ] + }, + { + "mode": "managed", + "type": "aws_route_table", + "name": "us-east-1-route-table", + "provider": "provider[\"registry.terraform.io/hashicorp/aws\"].us-east-1", + "instances": [ + { + "schema_version": 0, + "attributes": { + "arn": "arn:aws:ec2:us-east-1:349761350494:route-table/rtb-084e339de78854020", + "id": "rtb-084e339de78854020", + "owner_id": "349761350494", + "propagating_vgws": [], + "route": [], + "tags": null, + "tags_all": {}, + "timeouts": null, + "vpc_id": "vpc-065dddfbb64588639" + }, + "sensitive_attributes": [], + "private": "eyJlMmJmYjczMC1lY2FhLTExZTYtOGY4OC0zNDM2M2JjN2M0YzAiOnsiY3JlYXRlIjozMDAwMDAwMDAwMDAsImRlbGV0ZSI6MzAwMDAwMDAwMDAwLCJ1cGRhdGUiOjEyMDAwMDAwMDAwMH19", + "dependencies": [ + "aws_vpc.us-east-1" + ] + } + ] + }, + { + "mode": "managed", + "type": "aws_route_table", + "name": "us-west-1-route-table", + "provider": "provider[\"registry.terraform.io/hashicorp/aws\"].us-west-1", + "instances": [ + { + "schema_version": 0, + "attributes": { + "arn": "arn:aws:ec2:us-west-1:349761350494:route-table/rtb-07c9c4ed12d42c96b", + "id": "rtb-07c9c4ed12d42c96b", + "owner_id": "349761350494", + "propagating_vgws": [], + "route": [], + "tags": null, + "tags_all": {}, + "timeouts": null, + "vpc_id": "vpc-087c627d211c1faf6" + }, + "sensitive_attributes": [], + "private": "eyJlMmJmYjczMC1lY2FhLTExZTYtOGY4OC0zNDM2M2JjN2M0YzAiOnsiY3JlYXRlIjozMDAwMDAwMDAwMDAsImRlbGV0ZSI6MzAwMDAwMDAwMDAwLCJ1cGRhdGUiOjEyMDAwMDAwMDAwMH19", + "dependencies": [ + "aws_vpc.us-west-1" + ] + } + ] + }, + { + "mode": "managed", + "type": "aws_route_table_association", + "name": "us-east-1-subnet-1-association", + "provider": "provider[\"registry.terraform.io/hashicorp/aws\"].us-east-1", + "instances": [ + { + "schema_version": 0, + "attributes": { + "gateway_id": "", + "id": "rtbassoc-08cf50c09827ce0f9", + "route_table_id": "rtb-084e339de78854020", + "subnet_id": "subnet-0b8fd542ac3ac99f0", + "timeouts": null + }, + "sensitive_attributes": [], + "private": "eyJlMmJmYjczMC1lY2FhLTExZTYtOGY4OC0zNDM2M2JjN2M0YzAiOnsiY3JlYXRlIjozMDAwMDAwMDAwMDAsImRlbGV0ZSI6MzAwMDAwMDAwMDAwLCJ1cGRhdGUiOjEyMDAwMDAwMDAwMH19", + "dependencies": [ + "aws_route_table.us-east-1-route-table", + "aws_subnet.us-east-1-subnet-1", + "aws_vpc.us-east-1" + ] + } + ] + }, + { + "mode": "managed", + "type": "aws_route_table_association", + "name": "us-east-1-subnet-2-association", + "provider": "provider[\"registry.terraform.io/hashicorp/aws\"].us-east-1", + "instances": [ + { + "schema_version": 0, + "attributes": { + "gateway_id": "", + "id": "rtbassoc-0a2aacaa0e7003102", + "route_table_id": "rtb-084e339de78854020", + "subnet_id": "subnet-0a5006434f12ab81a", + "timeouts": null + }, + "sensitive_attributes": [], + "private": "eyJlMmJmYjczMC1lY2FhLTExZTYtOGY4OC0zNDM2M2JjN2M0YzAiOnsiY3JlYXRlIjozMDAwMDAwMDAwMDAsImRlbGV0ZSI6MzAwMDAwMDAwMDAwLCJ1cGRhdGUiOjEyMDAwMDAwMDAwMH19", + "dependencies": [ + "aws_route_table.us-east-1-route-table", + "aws_subnet.us-east-1-subnet-2", + "aws_vpc.us-east-1" + ] + } + ] + }, + { + "mode": "managed", + "type": "aws_route_table_association", + "name": "us-west-1-subnet-1-association", + "provider": "provider[\"registry.terraform.io/hashicorp/aws\"].us-west-1", + "instances": [ + { + "schema_version": 0, + "attributes": { + "gateway_id": "", + "id": "rtbassoc-08473bd1a7a981b70", + "route_table_id": "rtb-07c9c4ed12d42c96b", + "subnet_id": "subnet-0abc3ec32314d1f41", + "timeouts": null + }, + "sensitive_attributes": [], + "private": "eyJlMmJmYjczMC1lY2FhLTExZTYtOGY4OC0zNDM2M2JjN2M0YzAiOnsiY3JlYXRlIjozMDAwMDAwMDAwMDAsImRlbGV0ZSI6MzAwMDAwMDAwMDAwLCJ1cGRhdGUiOjEyMDAwMDAwMDAwMH19", + "dependencies": [ + "aws_route_table.us-west-1-route-table", + "aws_subnet.us-west-1-subnet-1", + "aws_vpc.us-west-1" + ] + } + ] + }, + { + "mode": "managed", + "type": "aws_route_table_association", + "name": "us-west-1-subnet-2-association", + "provider": "provider[\"registry.terraform.io/hashicorp/aws\"].us-west-1", + "instances": [ + { + "schema_version": 0, + "attributes": { + "gateway_id": "", + "id": "rtbassoc-0cc2ef70151fc7795", + "route_table_id": "rtb-07c9c4ed12d42c96b", + "subnet_id": "subnet-0d7c68ad12d2a648b", + "timeouts": null + }, + "sensitive_attributes": [], + "private": "eyJlMmJmYjczMC1lY2FhLTExZTYtOGY4OC0zNDM2M2JjN2M0YzAiOnsiY3JlYXRlIjozMDAwMDAwMDAwMDAsImRlbGV0ZSI6MzAwMDAwMDAwMDAwLCJ1cGRhdGUiOjEyMDAwMDAwMDAwMH19", + "dependencies": [ + "aws_route_table.us-west-1-route-table", + "aws_subnet.us-west-1-subnet-2", + "aws_vpc.us-west-1" + ] + } + ] + }, + { + "mode": "managed", + "type": "aws_security_group", + "name": "us-east-1-instance-sg", + "provider": "provider[\"registry.terraform.io/hashicorp/aws\"].us-east-1", + "instances": [ + { + "schema_version": 1, + "attributes": { + "arn": "arn:aws:ec2:us-east-1:349761350494:security-group/sg-0c4cb030408e58dd3", + "description": "Managed by Terraform", + "egress": [ + { + "cidr_blocks": [ + "10.1.0.0/16", + "0.0.0.0/0" + ], + "description": "", + "from_port": 0, + "ipv6_cidr_blocks": [], + "prefix_list_ids": [], + "protocol": "-1", + "security_groups": [], + "self": false, + "to_port": 0 + } + ], + "id": "sg-0c4cb030408e58dd3", + "ingress": [ + { + "cidr_blocks": [ + "0.0.0.0/0" + ], + "description": "", + "from_port": 22, + "ipv6_cidr_blocks": [], + "prefix_list_ids": [], + "protocol": "tcp", + "security_groups": [], + "self": false, + "to_port": 22 + }, + { + "cidr_blocks": [ + "0.0.0.0/0" + ], + "description": "", + "from_port": 443, + "ipv6_cidr_blocks": [], + "prefix_list_ids": [], + "protocol": "tcp", + "security_groups": [], + "self": false, + "to_port": 443 + }, + { + "cidr_blocks": [ + "0.0.0.0/0" + ], + "description": "", + "from_port": 80, + "ipv6_cidr_blocks": [], + "prefix_list_ids": [], + "protocol": "tcp", + "security_groups": [], + "self": false, + "to_port": 80 + } + ], + "name": "terraform-20231118005438355900000001", + "name_prefix": "terraform-", + "owner_id": "349761350494", + "revoke_rules_on_delete": false, + "tags": { + "Name": "instance-east-security-group" + }, + "tags_all": { + "Name": "instance-east-security-group" + }, + "timeouts": null, + "vpc_id": "vpc-065dddfbb64588639" + }, + "sensitive_attributes": [], + "private": "eyJlMmJmYjczMC1lY2FhLTExZTYtOGY4OC0zNDM2M2JjN2M0YzAiOnsiY3JlYXRlIjo2MDAwMDAwMDAwMDAsImRlbGV0ZSI6OTAwMDAwMDAwMDAwfSwic2NoZW1hX3ZlcnNpb24iOiIxIn0=", + "dependencies": [ + "aws_vpc.us-east-1" + ] + } + ] + }, + { + "mode": "managed", + "type": "aws_security_group", + "name": "us-west-1-instance-sg", + "provider": "provider[\"registry.terraform.io/hashicorp/aws\"].us-west-1", + "instances": [ + { + "schema_version": 1, + "attributes": { + "arn": "arn:aws:ec2:us-west-1:349761350494:security-group/sg-0c50bd6752e97a00b", + "description": "Managed by Terraform", + "egress": [ + { + "cidr_blocks": [ + "10.1.0.0/16", + "0.0.0.0/0" + ], + "description": "", + "from_port": 0, + "ipv6_cidr_blocks": [], + "prefix_list_ids": [], + "protocol": "-1", + "security_groups": [], + "self": false, + "to_port": 0 + } + ], + "id": "sg-0c50bd6752e97a00b", + "ingress": [ + { + "cidr_blocks": [ + "0.0.0.0/0" + ], + "description": "", + "from_port": 22, + "ipv6_cidr_blocks": [], + "prefix_list_ids": [], + "protocol": "tcp", + "security_groups": [], + "self": false, + "to_port": 22 + }, + { + "cidr_blocks": [ + "0.0.0.0/0" + ], + "description": "", + "from_port": 443, + "ipv6_cidr_blocks": [], + "prefix_list_ids": [], + "protocol": "tcp", + "security_groups": [], + "self": false, + "to_port": 443 + }, + { + "cidr_blocks": [ + "0.0.0.0/0" + ], + "description": "", + "from_port": 80, + "ipv6_cidr_blocks": [], + "prefix_list_ids": [], + "protocol": "tcp", + "security_groups": [], + "self": false, + "to_port": 80 + } + ], + "name": "terraform-20231118005439030200000001", + "name_prefix": "terraform-", + "owner_id": "349761350494", + "revoke_rules_on_delete": false, + "tags": { + "Name": "instance-west-security-group" + }, + "tags_all": { + "Name": "instance-west-security-group" + }, + "timeouts": null, + "vpc_id": "vpc-087c627d211c1faf6" + }, + "sensitive_attributes": [], + "private": "eyJlMmJmYjczMC1lY2FhLTExZTYtOGY4OC0zNDM2M2JjN2M0YzAiOnsiY3JlYXRlIjo2MDAwMDAwMDAwMDAsImRlbGV0ZSI6OTAwMDAwMDAwMDAwfSwic2NoZW1hX3ZlcnNpb24iOiIxIn0=", + "dependencies": [ + "aws_vpc.us-west-1" + ] + } + ] + }, + { + "mode": "managed", + "type": "aws_subnet", + "name": "us-east-1-subnet-1", + "provider": "provider[\"registry.terraform.io/hashicorp/aws\"].us-east-1", + "instances": [ + { + "schema_version": 1, + "attributes": { + "arn": "arn:aws:ec2:us-east-1:349761350494:subnet/subnet-0b8fd542ac3ac99f0", + "assign_ipv6_address_on_creation": false, + "availability_zone": "us-east-1c", + "availability_zone_id": "use1-az2", + "cidr_block": "10.1.1.0/24", + "customer_owned_ipv4_pool": "", + "enable_dns64": false, + "enable_lni_at_device_index": 0, + "enable_resource_name_dns_a_record_on_launch": false, + "enable_resource_name_dns_aaaa_record_on_launch": false, + "id": "subnet-0b8fd542ac3ac99f0", + "ipv6_cidr_block": "", + "ipv6_cidr_block_association_id": "", + "ipv6_native": false, + "map_customer_owned_ip_on_launch": false, + "map_public_ip_on_launch": false, + "outpost_arn": "", + "owner_id": "349761350494", + "private_dns_hostname_type_on_launch": "ip-name", + "tags": null, + "tags_all": {}, + "timeouts": null, + "vpc_id": "vpc-065dddfbb64588639" + }, + "sensitive_attributes": [], + "private": "eyJlMmJmYjczMC1lY2FhLTExZTYtOGY4OC0zNDM2M2JjN2M0YzAiOnsiY3JlYXRlIjo2MDAwMDAwMDAwMDAsImRlbGV0ZSI6MTIwMDAwMDAwMDAwMH0sInNjaGVtYV92ZXJzaW9uIjoiMSJ9", + "dependencies": [ + "aws_vpc.us-east-1" + ] + } + ] + }, + { + "mode": "managed", + "type": "aws_subnet", + "name": "us-east-1-subnet-2", + "provider": "provider[\"registry.terraform.io/hashicorp/aws\"].us-east-1", + "instances": [ + { + "schema_version": 1, + "attributes": { + "arn": "arn:aws:ec2:us-east-1:349761350494:subnet/subnet-0a5006434f12ab81a", + "assign_ipv6_address_on_creation": false, + "availability_zone": "us-east-1b", + "availability_zone_id": "use1-az1", + "cidr_block": "10.1.2.0/24", + "customer_owned_ipv4_pool": "", + "enable_dns64": false, + "enable_lni_at_device_index": 0, + "enable_resource_name_dns_a_record_on_launch": false, + "enable_resource_name_dns_aaaa_record_on_launch": false, + "id": "subnet-0a5006434f12ab81a", + "ipv6_cidr_block": "", + "ipv6_cidr_block_association_id": "", + "ipv6_native": false, + "map_customer_owned_ip_on_launch": false, + "map_public_ip_on_launch": false, + "outpost_arn": "", + "owner_id": "349761350494", + "private_dns_hostname_type_on_launch": "ip-name", + "tags": null, + "tags_all": {}, + "timeouts": null, + "vpc_id": "vpc-065dddfbb64588639" + }, + "sensitive_attributes": [], + "private": "eyJlMmJmYjczMC1lY2FhLTExZTYtOGY4OC0zNDM2M2JjN2M0YzAiOnsiY3JlYXRlIjo2MDAwMDAwMDAwMDAsImRlbGV0ZSI6MTIwMDAwMDAwMDAwMH0sInNjaGVtYV92ZXJzaW9uIjoiMSJ9", + "dependencies": [ + "aws_vpc.us-east-1" + ] + } + ] + }, + { + "mode": "managed", + "type": "aws_subnet", + "name": "us-west-1-subnet-1", + "provider": "provider[\"registry.terraform.io/hashicorp/aws\"].us-west-1", + "instances": [ + { + "schema_version": 1, + "attributes": { + "arn": "arn:aws:ec2:us-west-1:349761350494:subnet/subnet-0abc3ec32314d1f41", + "assign_ipv6_address_on_creation": false, + "availability_zone": "us-west-1c", + "availability_zone_id": "usw1-az1", + "cidr_block": "10.0.1.0/24", + "customer_owned_ipv4_pool": "", + "enable_dns64": false, + "enable_lni_at_device_index": 0, + "enable_resource_name_dns_a_record_on_launch": false, + "enable_resource_name_dns_aaaa_record_on_launch": false, + "id": "subnet-0abc3ec32314d1f41", + "ipv6_cidr_block": "", + "ipv6_cidr_block_association_id": "", + "ipv6_native": false, + "map_customer_owned_ip_on_launch": false, + "map_public_ip_on_launch": false, + "outpost_arn": "", + "owner_id": "349761350494", + "private_dns_hostname_type_on_launch": "ip-name", + "tags": null, + "tags_all": {}, + "timeouts": null, + "vpc_id": "vpc-087c627d211c1faf6" + }, + "sensitive_attributes": [], + "private": "eyJlMmJmYjczMC1lY2FhLTExZTYtOGY4OC0zNDM2M2JjN2M0YzAiOnsiY3JlYXRlIjo2MDAwMDAwMDAwMDAsImRlbGV0ZSI6MTIwMDAwMDAwMDAwMH0sInNjaGVtYV92ZXJzaW9uIjoiMSJ9", + "dependencies": [ + "aws_vpc.us-west-1" + ] + } + ] + }, + { + "mode": "managed", + "type": "aws_subnet", + "name": "us-west-1-subnet-2", + "provider": "provider[\"registry.terraform.io/hashicorp/aws\"].us-west-1", + "instances": [ + { + "schema_version": 1, + "attributes": { + "arn": "arn:aws:ec2:us-west-1:349761350494:subnet/subnet-0d7c68ad12d2a648b", + "assign_ipv6_address_on_creation": false, + "availability_zone": "us-west-1b", + "availability_zone_id": "usw1-az3", + "cidr_block": "10.0.2.0/24", + "customer_owned_ipv4_pool": "", + "enable_dns64": false, + "enable_lni_at_device_index": 0, + "enable_resource_name_dns_a_record_on_launch": false, + "enable_resource_name_dns_aaaa_record_on_launch": false, + "id": "subnet-0d7c68ad12d2a648b", + "ipv6_cidr_block": "", + "ipv6_cidr_block_association_id": "", + "ipv6_native": false, + "map_customer_owned_ip_on_launch": false, + "map_public_ip_on_launch": false, + "outpost_arn": "", + "owner_id": "349761350494", + "private_dns_hostname_type_on_launch": "ip-name", + "tags": null, + "tags_all": {}, + "timeouts": null, + "vpc_id": "vpc-087c627d211c1faf6" + }, + "sensitive_attributes": [], + "private": "eyJlMmJmYjczMC1lY2FhLTExZTYtOGY4OC0zNDM2M2JjN2M0YzAiOnsiY3JlYXRlIjo2MDAwMDAwMDAwMDAsImRlbGV0ZSI6MTIwMDAwMDAwMDAwMH0sInNjaGVtYV92ZXJzaW9uIjoiMSJ9", + "dependencies": [ + "aws_vpc.us-west-1" + ] + } + ] + }, + { + "mode": "managed", + "type": "aws_vpc", + "name": "us-east-1", + "provider": "provider[\"registry.terraform.io/hashicorp/aws\"].us-east-1", + "instances": [ + { + "schema_version": 1, + "attributes": { + "arn": "arn:aws:ec2:us-east-1:349761350494:vpc/vpc-065dddfbb64588639", + "assign_generated_ipv6_cidr_block": false, + "cidr_block": "10.1.0.0/16", + "default_network_acl_id": "acl-0a7603e25f1233cef", + "default_route_table_id": "rtb-08ce8d4dfff1f1f86", + "default_security_group_id": "sg-0986bd00c792c02f6", + "dhcp_options_id": "dopt-6e030515", + "enable_dns_hostnames": false, + "enable_dns_support": true, + "enable_network_address_usage_metrics": false, + "id": "vpc-065dddfbb64588639", + "instance_tenancy": "default", + "ipv4_ipam_pool_id": null, + "ipv4_netmask_length": null, + "ipv6_association_id": "", + "ipv6_cidr_block": "", + "ipv6_cidr_block_network_border_group": "", + "ipv6_ipam_pool_id": "", + "ipv6_netmask_length": 0, + "main_route_table_id": "rtb-08ce8d4dfff1f1f86", + "owner_id": "349761350494", + "tags": null, + "tags_all": {} + }, + "sensitive_attributes": [], + "private": "eyJzY2hlbWFfdmVyc2lvbiI6IjEifQ==" + } + ] + }, + { + "mode": "managed", + "type": "aws_vpc", + "name": "us-west-1", + "provider": "provider[\"registry.terraform.io/hashicorp/aws\"].us-west-1", + "instances": [ + { + "schema_version": 1, + "attributes": { + "arn": "arn:aws:ec2:us-west-1:349761350494:vpc/vpc-087c627d211c1faf6", + "assign_generated_ipv6_cidr_block": false, + "cidr_block": "10.0.0.0/16", + "default_network_acl_id": "acl-0a625ac6d1577cf74", + "default_route_table_id": "rtb-01f025a6d0914dec0", + "default_security_group_id": "sg-05043c20973654d7d", + "dhcp_options_id": "dopt-1adbfc7d", + "enable_dns_hostnames": false, + "enable_dns_support": true, + "enable_network_address_usage_metrics": false, + "id": "vpc-087c627d211c1faf6", + "instance_tenancy": "default", + "ipv4_ipam_pool_id": null, + "ipv4_netmask_length": null, + "ipv6_association_id": "", + "ipv6_cidr_block": "", + "ipv6_cidr_block_network_border_group": "", + "ipv6_ipam_pool_id": "", + "ipv6_netmask_length": 0, + "main_route_table_id": "rtb-01f025a6d0914dec0", + "owner_id": "349761350494", + "tags": null, + "tags_all": {} + }, + "sensitive_attributes": [], + "private": "eyJzY2hlbWFfdmVyc2lvbiI6IjEifQ==" + } + ] + }, + { + "mode": "managed", + "type": "aws_vpc_peering_connection", + "name": "peering_connection", + "provider": "provider[\"registry.terraform.io/hashicorp/aws\"].us-west-1", + "instances": [ + { + "schema_version": 0, + "attributes": { + "accept_status": "pending-acceptance", + "accepter": [], + "auto_accept": false, + "id": "pcx-07c02e0bfd18ccdb9", + "peer_owner_id": "349761350494", + "peer_region": "us-east-1", + "peer_vpc_id": "vpc-065dddfbb64588639", + "requester": [ + { + "allow_remote_vpc_dns_resolution": false + } + ], + "tags": null, + "tags_all": {}, + "timeouts": null, + "vpc_id": "vpc-087c627d211c1faf6" + }, + "sensitive_attributes": [], + "private": "eyJlMmJmYjczMC1lY2FhLTExZTYtOGY4OC0zNDM2M2JjN2M0YzAiOnsiY3JlYXRlIjo2MDAwMDAwMDAwMCwiZGVsZXRlIjo2MDAwMDAwMDAwMCwidXBkYXRlIjo2MDAwMDAwMDAwMH19", + "dependencies": [ + "aws_vpc.us-east-1", + "aws_vpc.us-west-1" + ] + } + ] + }, + { + "mode": "managed", + "type": "aws_vpc_peering_connection_accepter", + "name": "peering_accepter", + "provider": "provider[\"registry.terraform.io/hashicorp/aws\"].us-east-1", + "instances": [ + { + "schema_version": 0, + "attributes": { + "accept_status": "active", + "accepter": [ + { + "allow_remote_vpc_dns_resolution": false + } + ], + "auto_accept": true, + "id": "pcx-07c02e0bfd18ccdb9", + "peer_owner_id": "349761350494", + "peer_region": "us-east-1", + "peer_vpc_id": "vpc-065dddfbb64588639", + "requester": [ + { + "allow_remote_vpc_dns_resolution": false + } + ], + "tags": null, + "tags_all": {}, + "timeouts": null, + "vpc_id": "vpc-087c627d211c1faf6", + "vpc_peering_connection_id": "pcx-07c02e0bfd18ccdb9" + }, + "sensitive_attributes": [], + "private": "eyJlMmJmYjczMC1lY2FhLTExZTYtOGY4OC0zNDM2M2JjN2M0YzAiOnsiY3JlYXRlIjo2MDAwMDAwMDAwMCwidXBkYXRlIjo2MDAwMDAwMDAwMH19", + "dependencies": [ + "aws_vpc.us-east-1", + "aws_vpc.us-west-1", + "aws_vpc_peering_connection.peering_connection" + ] + } + ] + } + ], + "check_results": null +} diff --git a/aws/aws_vpc_peering/user-data.sh b/aws/aws_vpc_peering/user-data.sh new file mode 100644 index 0000000..bbf36b4 --- /dev/null +++ b/aws/aws_vpc_peering/user-data.sh @@ -0,0 +1,31 @@ +#!/bin/bash + +# Install necessary packages +sudo apt-get update +sudo apt-get install -y git amazon-efs-utils vim-nox neofetch htop tmux curl wget nginx + +# Create new user with sudo privileges +sudo useradd -m -s /bin/bash greg +sudo usermod -aG sudo greg + +# Add authorized keys for your public key +sudo mkdir -p /home/greg/.ssh +sudo touch /home/greg/.ssh/authorized_keys +sudo chmod 700 /home/greg/.ssh +sudo chmod 600 /home/greg/.ssh/authorized_keys +sudo chown -R greg:greg /home/greg/.ssh + +# Add your public key to authorized_keys +sudo echo "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQCdOF80z0piQEnYzNCu2OGvOJdm7+3wfDuiC+Jzi8VbSC5VW4iJAQXOuDNGLzyqNi6uMjI77xpEL6Xzn29uJiQti6Y/LxhOZwNNIQiGUpFco1wkBYeBFbtgHQxsMLwumrxQGEj2fyCiSrACAPyy/l1fP4mlN7abBGD5aozBrYKxXPS/kfwO5nsWmw27RgTzfHJzie2dUU3ew/kd7td3wEdWrRXq8wNbu+yvAyiog54huUUWmYZwY3QVwXr6R1wsVudawM6BEl45QFq+hdB4t83azHG94XLy2NCAncohdU7zP40nsbvIDyh+4wIKeU90z6TLrXfHUYuBT6/ky7qOFm/Ym1QG4zCDz3jin8Qoa31PGaObzj/zoMJXgOXKcp16W0j9SZAenvnSfuWUEfBR1yBRR0T5Wg5v1vi7KGBTATaz8el802uliL+yZbGtMbNpAPGR5nK5C4yorf8yVYvIgo/LJaWCDND2O1e2mdut1WyRmvIwMnq7PFZT8zAsgGXfhDM= greg@ligma" >> /home/greg/.ssh/authorized_keys + +# Set hostname +INSTANCE_ID=$(curl -s http://169.254.169.254/latest/meta-data/instance-id) +AVAILABILITY_ZONE=$(curl -s http://169.254.169.254/latest/meta-data/placement/availability-zone) +HOSTNAME="$INSTANCE_ID-$AVAILABILITY_ZONE" +sudo hostnamectl set-hostname $HOSTNAME + +echo "hello world" >> /var/www/html/index.html +systemctm restart nginx + +# Run cloud-init.sh script +# sudo sh /path/to/cloud-init.sh From 8a23203128a5512e6d87c86f683ce487790a1c08 Mon Sep 17 00:00:00 2001 From: Greg Hendrickson Date: Fri, 17 Nov 2023 17:08:59 -0800 Subject: [PATCH 10/17] cleanup folders and files --- aws/{aws_simple => aws_asg}/main.tf | 0 .../modules/ec2/ec2-east/ec2-east.tf | 0 .../modules/ec2/ec2-east/outputs.tf | 0 .../modules/ec2/ec2-east/terraform.tfvars | 0 .../modules/ec2/ec2-east/user-data.sh | 0 .../modules/ec2/ec2-east/variables.tf | 0 .../modules/ec2/ec2-west/ec2-west..tf | 0 .../modules/ec2/ec2-west/outputs.tf | 0 .../modules/ec2/ec2-west/terraform.tfvars | 0 .../modules/ec2/ec2-west/user-data.sh | 0 .../modules/ec2/ec2-west/variables.tf | 0 .../modules/vpc/subnets/us-east/outputs.tf | 0 .../vpc/subnets/us-east/subnets-east.tf | 0 .../vpc/subnets/us-east/terraform.tfvars | 0 .../modules/vpc/subnets/us-east/variables.tf | 0 .../modules/vpc/subnets/us-west/outputs.tf | 0 .../vpc/subnets/us-west/subnets-west.tf | 0 .../vpc/subnets/us-west/terraform.tfvars | 0 .../modules/vpc/subnets/us-west/variables.tf | 0 .../modules/vpc/vpc-east/outputs.tf | 0 .../modules/vpc/vpc-east/terraform.tfvars | 0 .../modules/vpc/vpc-east/variables.tf | 0 .../modules/vpc/vpc-east/vpc-east.tf | 0 .../modules/vpc/vpc-west/outputs.tf | 0 .../modules/vpc/vpc-west/terraform.tfvars | 0 .../modules/vpc/vpc-west/variables.tf | 0 .../modules/vpc/vpc-west/vpc-west.tf | 0 aws/{aws_simple => aws_asg}/readme.md | 0 aws/{aws_simple => aws_asg}/terraform.tfvars | 0 aws/{aws_simple => aws_asg}/variables.tf | 0 .../.terraform/terraform.tfstate | 74 + aws/aws_vpc_peering/main.tf | 34 + aws/aws_vpc_peering/terraform.tfstate.backup | 1225 ----------------- .../main.tf | 0 aws/terraform-backend/terraform.tfstate | 9 + 35 files changed, 117 insertions(+), 1225 deletions(-) rename aws/{aws_simple => aws_asg}/main.tf (100%) rename aws/{aws_simple => aws_asg}/modules/ec2/ec2-east/ec2-east.tf (100%) rename aws/{aws_simple => aws_asg}/modules/ec2/ec2-east/outputs.tf (100%) rename aws/{aws_simple => aws_asg}/modules/ec2/ec2-east/terraform.tfvars (100%) rename aws/{aws_simple => aws_asg}/modules/ec2/ec2-east/user-data.sh (100%) rename aws/{aws_simple => aws_asg}/modules/ec2/ec2-east/variables.tf (100%) rename aws/{aws_simple => aws_asg}/modules/ec2/ec2-west/ec2-west..tf (100%) rename aws/{aws_simple => aws_asg}/modules/ec2/ec2-west/outputs.tf (100%) rename aws/{aws_simple => aws_asg}/modules/ec2/ec2-west/terraform.tfvars (100%) rename aws/{aws_simple => aws_asg}/modules/ec2/ec2-west/user-data.sh (100%) rename aws/{aws_simple => aws_asg}/modules/ec2/ec2-west/variables.tf (100%) rename aws/{aws_simple => aws_asg}/modules/vpc/subnets/us-east/outputs.tf (100%) rename aws/{aws_simple => aws_asg}/modules/vpc/subnets/us-east/subnets-east.tf (100%) rename aws/{aws_simple => aws_asg}/modules/vpc/subnets/us-east/terraform.tfvars (100%) rename aws/{aws_simple => aws_asg}/modules/vpc/subnets/us-east/variables.tf (100%) rename aws/{aws_simple => aws_asg}/modules/vpc/subnets/us-west/outputs.tf (100%) rename aws/{aws_simple => aws_asg}/modules/vpc/subnets/us-west/subnets-west.tf (100%) rename aws/{aws_simple => aws_asg}/modules/vpc/subnets/us-west/terraform.tfvars (100%) rename aws/{aws_simple => aws_asg}/modules/vpc/subnets/us-west/variables.tf (100%) rename aws/{aws_simple => aws_asg}/modules/vpc/vpc-east/outputs.tf (100%) rename aws/{aws_simple => aws_asg}/modules/vpc/vpc-east/terraform.tfvars (100%) rename aws/{aws_simple => aws_asg}/modules/vpc/vpc-east/variables.tf (100%) rename aws/{aws_simple => aws_asg}/modules/vpc/vpc-east/vpc-east.tf (100%) rename aws/{aws_simple => aws_asg}/modules/vpc/vpc-west/outputs.tf (100%) rename aws/{aws_simple => aws_asg}/modules/vpc/vpc-west/terraform.tfvars (100%) rename aws/{aws_simple => aws_asg}/modules/vpc/vpc-west/variables.tf (100%) rename aws/{aws_simple => aws_asg}/modules/vpc/vpc-west/vpc-west.tf (100%) rename aws/{aws_simple => aws_asg}/readme.md (100%) rename aws/{aws_simple => aws_asg}/terraform.tfvars (100%) rename aws/{aws_simple => aws_asg}/variables.tf (100%) create mode 100644 aws/aws_vpc_peering/.terraform/terraform.tfstate delete mode 100644 aws/aws_vpc_peering/terraform.tfstate.backup rename aws/{example-backend => terraform-backend}/main.tf (100%) create mode 100644 aws/terraform-backend/terraform.tfstate diff --git a/aws/aws_simple/main.tf b/aws/aws_asg/main.tf similarity index 100% rename from aws/aws_simple/main.tf rename to aws/aws_asg/main.tf diff --git a/aws/aws_simple/modules/ec2/ec2-east/ec2-east.tf b/aws/aws_asg/modules/ec2/ec2-east/ec2-east.tf similarity index 100% rename from aws/aws_simple/modules/ec2/ec2-east/ec2-east.tf rename to aws/aws_asg/modules/ec2/ec2-east/ec2-east.tf diff --git a/aws/aws_simple/modules/ec2/ec2-east/outputs.tf b/aws/aws_asg/modules/ec2/ec2-east/outputs.tf similarity index 100% rename from aws/aws_simple/modules/ec2/ec2-east/outputs.tf rename to aws/aws_asg/modules/ec2/ec2-east/outputs.tf diff --git a/aws/aws_simple/modules/ec2/ec2-east/terraform.tfvars b/aws/aws_asg/modules/ec2/ec2-east/terraform.tfvars similarity index 100% rename from aws/aws_simple/modules/ec2/ec2-east/terraform.tfvars rename to aws/aws_asg/modules/ec2/ec2-east/terraform.tfvars diff --git a/aws/aws_simple/modules/ec2/ec2-east/user-data.sh b/aws/aws_asg/modules/ec2/ec2-east/user-data.sh similarity index 100% rename from aws/aws_simple/modules/ec2/ec2-east/user-data.sh rename to aws/aws_asg/modules/ec2/ec2-east/user-data.sh diff --git a/aws/aws_simple/modules/ec2/ec2-east/variables.tf b/aws/aws_asg/modules/ec2/ec2-east/variables.tf similarity index 100% rename from aws/aws_simple/modules/ec2/ec2-east/variables.tf rename to aws/aws_asg/modules/ec2/ec2-east/variables.tf diff --git a/aws/aws_simple/modules/ec2/ec2-west/ec2-west..tf b/aws/aws_asg/modules/ec2/ec2-west/ec2-west..tf similarity index 100% rename from aws/aws_simple/modules/ec2/ec2-west/ec2-west..tf rename to aws/aws_asg/modules/ec2/ec2-west/ec2-west..tf diff --git a/aws/aws_simple/modules/ec2/ec2-west/outputs.tf b/aws/aws_asg/modules/ec2/ec2-west/outputs.tf similarity index 100% rename from aws/aws_simple/modules/ec2/ec2-west/outputs.tf rename to aws/aws_asg/modules/ec2/ec2-west/outputs.tf diff --git a/aws/aws_simple/modules/ec2/ec2-west/terraform.tfvars b/aws/aws_asg/modules/ec2/ec2-west/terraform.tfvars similarity index 100% rename from aws/aws_simple/modules/ec2/ec2-west/terraform.tfvars rename to aws/aws_asg/modules/ec2/ec2-west/terraform.tfvars diff --git a/aws/aws_simple/modules/ec2/ec2-west/user-data.sh b/aws/aws_asg/modules/ec2/ec2-west/user-data.sh similarity index 100% rename from aws/aws_simple/modules/ec2/ec2-west/user-data.sh rename to aws/aws_asg/modules/ec2/ec2-west/user-data.sh diff --git a/aws/aws_simple/modules/ec2/ec2-west/variables.tf b/aws/aws_asg/modules/ec2/ec2-west/variables.tf similarity index 100% rename from aws/aws_simple/modules/ec2/ec2-west/variables.tf rename to aws/aws_asg/modules/ec2/ec2-west/variables.tf diff --git a/aws/aws_simple/modules/vpc/subnets/us-east/outputs.tf b/aws/aws_asg/modules/vpc/subnets/us-east/outputs.tf similarity index 100% rename from aws/aws_simple/modules/vpc/subnets/us-east/outputs.tf rename to aws/aws_asg/modules/vpc/subnets/us-east/outputs.tf diff --git a/aws/aws_simple/modules/vpc/subnets/us-east/subnets-east.tf b/aws/aws_asg/modules/vpc/subnets/us-east/subnets-east.tf similarity index 100% rename from aws/aws_simple/modules/vpc/subnets/us-east/subnets-east.tf rename to aws/aws_asg/modules/vpc/subnets/us-east/subnets-east.tf diff --git a/aws/aws_simple/modules/vpc/subnets/us-east/terraform.tfvars b/aws/aws_asg/modules/vpc/subnets/us-east/terraform.tfvars similarity index 100% rename from aws/aws_simple/modules/vpc/subnets/us-east/terraform.tfvars rename to aws/aws_asg/modules/vpc/subnets/us-east/terraform.tfvars diff --git a/aws/aws_simple/modules/vpc/subnets/us-east/variables.tf b/aws/aws_asg/modules/vpc/subnets/us-east/variables.tf similarity index 100% rename from aws/aws_simple/modules/vpc/subnets/us-east/variables.tf rename to aws/aws_asg/modules/vpc/subnets/us-east/variables.tf diff --git a/aws/aws_simple/modules/vpc/subnets/us-west/outputs.tf b/aws/aws_asg/modules/vpc/subnets/us-west/outputs.tf similarity index 100% rename from aws/aws_simple/modules/vpc/subnets/us-west/outputs.tf rename to aws/aws_asg/modules/vpc/subnets/us-west/outputs.tf diff --git a/aws/aws_simple/modules/vpc/subnets/us-west/subnets-west.tf b/aws/aws_asg/modules/vpc/subnets/us-west/subnets-west.tf similarity index 100% rename from aws/aws_simple/modules/vpc/subnets/us-west/subnets-west.tf rename to aws/aws_asg/modules/vpc/subnets/us-west/subnets-west.tf diff --git a/aws/aws_simple/modules/vpc/subnets/us-west/terraform.tfvars b/aws/aws_asg/modules/vpc/subnets/us-west/terraform.tfvars similarity index 100% rename from aws/aws_simple/modules/vpc/subnets/us-west/terraform.tfvars rename to aws/aws_asg/modules/vpc/subnets/us-west/terraform.tfvars diff --git a/aws/aws_simple/modules/vpc/subnets/us-west/variables.tf b/aws/aws_asg/modules/vpc/subnets/us-west/variables.tf similarity index 100% rename from aws/aws_simple/modules/vpc/subnets/us-west/variables.tf rename to aws/aws_asg/modules/vpc/subnets/us-west/variables.tf diff --git a/aws/aws_simple/modules/vpc/vpc-east/outputs.tf b/aws/aws_asg/modules/vpc/vpc-east/outputs.tf similarity index 100% rename from aws/aws_simple/modules/vpc/vpc-east/outputs.tf rename to aws/aws_asg/modules/vpc/vpc-east/outputs.tf diff --git a/aws/aws_simple/modules/vpc/vpc-east/terraform.tfvars b/aws/aws_asg/modules/vpc/vpc-east/terraform.tfvars similarity index 100% rename from aws/aws_simple/modules/vpc/vpc-east/terraform.tfvars rename to aws/aws_asg/modules/vpc/vpc-east/terraform.tfvars diff --git a/aws/aws_simple/modules/vpc/vpc-east/variables.tf b/aws/aws_asg/modules/vpc/vpc-east/variables.tf similarity index 100% rename from aws/aws_simple/modules/vpc/vpc-east/variables.tf rename to aws/aws_asg/modules/vpc/vpc-east/variables.tf diff --git a/aws/aws_simple/modules/vpc/vpc-east/vpc-east.tf b/aws/aws_asg/modules/vpc/vpc-east/vpc-east.tf similarity index 100% rename from aws/aws_simple/modules/vpc/vpc-east/vpc-east.tf rename to aws/aws_asg/modules/vpc/vpc-east/vpc-east.tf diff --git a/aws/aws_simple/modules/vpc/vpc-west/outputs.tf b/aws/aws_asg/modules/vpc/vpc-west/outputs.tf similarity index 100% rename from aws/aws_simple/modules/vpc/vpc-west/outputs.tf rename to aws/aws_asg/modules/vpc/vpc-west/outputs.tf diff --git a/aws/aws_simple/modules/vpc/vpc-west/terraform.tfvars b/aws/aws_asg/modules/vpc/vpc-west/terraform.tfvars similarity index 100% rename from aws/aws_simple/modules/vpc/vpc-west/terraform.tfvars rename to aws/aws_asg/modules/vpc/vpc-west/terraform.tfvars diff --git a/aws/aws_simple/modules/vpc/vpc-west/variables.tf b/aws/aws_asg/modules/vpc/vpc-west/variables.tf similarity index 100% rename from aws/aws_simple/modules/vpc/vpc-west/variables.tf rename to aws/aws_asg/modules/vpc/vpc-west/variables.tf diff --git a/aws/aws_simple/modules/vpc/vpc-west/vpc-west.tf b/aws/aws_asg/modules/vpc/vpc-west/vpc-west.tf similarity index 100% rename from aws/aws_simple/modules/vpc/vpc-west/vpc-west.tf rename to aws/aws_asg/modules/vpc/vpc-west/vpc-west.tf diff --git a/aws/aws_simple/readme.md b/aws/aws_asg/readme.md similarity index 100% rename from aws/aws_simple/readme.md rename to aws/aws_asg/readme.md diff --git a/aws/aws_simple/terraform.tfvars b/aws/aws_asg/terraform.tfvars similarity index 100% rename from aws/aws_simple/terraform.tfvars rename to aws/aws_asg/terraform.tfvars diff --git a/aws/aws_simple/variables.tf b/aws/aws_asg/variables.tf similarity index 100% rename from aws/aws_simple/variables.tf rename to aws/aws_asg/variables.tf diff --git a/aws/aws_vpc_peering/.terraform/terraform.tfstate b/aws/aws_vpc_peering/.terraform/terraform.tfstate new file mode 100644 index 0000000..1186434 --- /dev/null +++ b/aws/aws_vpc_peering/.terraform/terraform.tfstate @@ -0,0 +1,74 @@ +{ + "version": 3, + "serial": 1, + "lineage": "d2c9bc57-2b6a-7881-0aa9-ac0ba7c8db89", + "backend": { + "type": "s3", + "config": { + "access_key": null, + "acl": null, + "allowed_account_ids": null, + "assume_role": null, + "assume_role_duration_seconds": null, + "assume_role_policy": null, + "assume_role_policy_arns": null, + "assume_role_tags": null, + "assume_role_transitive_tag_keys": null, + "assume_role_with_web_identity": null, + "bucket": "my-tf-bucket-ghndrx", + "custom_ca_bundle": null, + "dynamodb_endpoint": null, + "dynamodb_table": null, + "ec2_metadata_service_endpoint": null, + "ec2_metadata_service_endpoint_mode": null, + "encrypt": null, + "endpoint": null, + "endpoints": null, + "external_id": null, + "forbidden_account_ids": null, + "force_path_style": null, + "http_proxy": null, + "https_proxy": null, + "iam_endpoint": null, + "insecure": null, + "key": "aws_vpc_peering/terraform.tfstate", + "kms_key_id": null, + "max_retries": null, + "no_proxy": null, + "profile": null, + "region": "us-west-2", + "retry_mode": null, + "role_arn": null, + "secret_key": null, + "session_name": null, + "shared_config_files": null, + "shared_credentials_file": null, + "shared_credentials_files": null, + "skip_credentials_validation": null, + "skip_metadata_api_check": null, + "skip_region_validation": null, + "skip_requesting_account_id": null, + "skip_s3_checksum": null, + "sse_customer_key": null, + "sts_endpoint": null, + "sts_region": null, + "token": null, + "use_dualstack_endpoint": null, + "use_fips_endpoint": null, + "use_legacy_workflow": null, + "use_path_style": null, + "workspace_key_prefix": null + }, + "hash": 1294417248 + }, + "modules": [ + { + "path": [ + "root" + ], + "outputs": {}, + "resources": {}, + "depends_on": [] + } + ] +} diff --git a/aws/aws_vpc_peering/main.tf b/aws/aws_vpc_peering/main.tf index c2d5a76..316de91 100644 --- a/aws/aws_vpc_peering/main.tf +++ b/aws/aws_vpc_peering/main.tf @@ -1,3 +1,11 @@ +terraform { + backend "s3" { + bucket = "my-tf-bucket-ghndrx" + key = "aws_vpc_peering/terraform.tfstate" + region = "us-west-2" + } +} + # Define AWS provider with aliases for us-west-1 and us-east-1 regions provider "aws" { alias = "us-west-1" @@ -69,6 +77,20 @@ resource "aws_vpc_peering_connection_accepter" "peering_accepter" { provider = aws.us-east-1 } +resource "aws_route" "peer-route-us-west-1" { + route_table_id = aws_route_table.us-west-1-route-table.id + destination_cidr_block = aws_vpc.us-east-1.cidr_block + vpc_peering_connection_id = aws_vpc_peering_connection.peering_connection.id + provider = aws.us-west-1 +} + +resource "aws_route" "peer-route-us-east-1" { + route_table_id = aws_route_table.us-east-1-route-table.id + destination_cidr_block = aws_vpc.us-west-1.cidr_block + vpc_peering_connection_id = aws_vpc_peering_connection.peering_connection.id + provider = aws.us-east-1 +} + # Create route tables for each VPC and associate them with the respective subnets resource "aws_route_table" "us-west-1-route-table" { vpc_id = aws_vpc.us-west-1.id @@ -177,6 +199,12 @@ resource "aws_security_group" "us-west-1-instance-sg" { protocol = "-1" cidr_blocks = ["10.1.0.0/16", "0.0.0.0/0"] } + ingress { + from_port = -1 + to_port = -1 + protocol = "icmp" + cidr_blocks = ["0.0.0.0/0"] + } } resource "aws_security_group" "us-east-1-instance-sg" { @@ -215,6 +243,12 @@ resource "aws_security_group" "us-east-1-instance-sg" { protocol = "-1" cidr_blocks = ["10.1.0.0/16", "0.0.0.0/0"] } + ingress { + from_port = -1 + to_port = -1 + protocol = "icmp" + cidr_blocks = ["0.0.0.0/0"] + } } # Create EC2 instances in each subnet diff --git a/aws/aws_vpc_peering/terraform.tfstate.backup b/aws/aws_vpc_peering/terraform.tfstate.backup deleted file mode 100644 index 1d99e40..0000000 --- a/aws/aws_vpc_peering/terraform.tfstate.backup +++ /dev/null @@ -1,1225 +0,0 @@ -{ - "version": 4, - "terraform_version": "1.6.4", - "serial": 238, - "lineage": "061fcdf6-790c-d6b1-daa8-0a270cb1098d", - "outputs": { - "us-east-1-instance-1-public-ip": { - "value": "35.170.185.226", - "type": "string" - }, - "us-east-1-instance-2-public-ip": { - "value": "3.239.202.177", - "type": "string" - }, - "us-west-1-instance-1-public-ip": { - "value": "54.183.139.140", - "type": "string" - }, - "us-west-1-instance-2-public-ip": { - "value": "54.67.94.5", - "type": "string" - } - }, - "resources": [ - { - "mode": "managed", - "type": "aws_instance", - "name": "us-east-1-instance-1", - "provider": "provider[\"registry.terraform.io/hashicorp/aws\"].us-east-1", - "instances": [ - { - "schema_version": 1, - "attributes": { - "ami": "ami-04e369782a6d2125e", - "arn": "arn:aws:ec2:us-east-1:349761350494:instance/i-0af840dc385d7adcb", - "associate_public_ip_address": true, - "availability_zone": "us-east-1c", - "capacity_reservation_specification": [ - { - "capacity_reservation_preference": "open", - "capacity_reservation_target": [] - } - ], - "cpu_core_count": 1, - "cpu_options": [ - { - "amd_sev_snp": "", - "core_count": 1, - "threads_per_core": 2 - } - ], - "cpu_threads_per_core": 2, - "credit_specification": [ - { - "cpu_credits": "unlimited" - } - ], - "disable_api_stop": false, - "disable_api_termination": false, - "ebs_block_device": [], - "ebs_optimized": false, - "enclave_options": [ - { - "enabled": false - } - ], - "ephemeral_block_device": [], - "get_password_data": false, - "hibernation": false, - "host_id": "", - "host_resource_group_arn": null, - "iam_instance_profile": "", - "id": "i-0af840dc385d7adcb", - "instance_initiated_shutdown_behavior": "stop", - "instance_lifecycle": "", - "instance_market_options": [], - "instance_state": "running", - "instance_type": "t3.small", - "ipv6_address_count": 0, - "ipv6_addresses": [], - "key_name": "", - "launch_template": [], - "maintenance_options": [ - { - "auto_recovery": "default" - } - ], - "metadata_options": [ - { - "http_endpoint": "enabled", - "http_protocol_ipv6": "disabled", - "http_put_response_hop_limit": 1, - "http_tokens": "optional", - "instance_metadata_tags": "disabled" - } - ], - "monitoring": false, - "network_interface": [], - "outpost_arn": "", - "password_data": "", - "placement_group": "", - "placement_partition_number": 0, - "primary_network_interface_id": "eni-0346c453f64b7b8ff", - "private_dns": "ip-10-1-1-87.ec2.internal", - "private_dns_name_options": [ - { - "enable_resource_name_dns_a_record": false, - "enable_resource_name_dns_aaaa_record": false, - "hostname_type": "ip-name" - } - ], - "private_ip": "10.1.1.87", - "public_dns": "", - "public_ip": "35.170.185.226", - "root_block_device": [ - { - "delete_on_termination": true, - "device_name": "/dev/sda1", - "encrypted": false, - "iops": 100, - "kms_key_id": "", - "tags": {}, - "throughput": 0, - "volume_id": "vol-0007cfd358eb7ee8b", - "volume_size": 8, - "volume_type": "gp2" - } - ], - "secondary_private_ips": [], - "security_groups": [], - "source_dest_check": true, - "spot_instance_request_id": "", - "subnet_id": "subnet-0b8fd542ac3ac99f0", - "tags": { - "Name": "us-east-1-instance-1", - "SecurityGroup": "instance-east-security-group" - }, - "tags_all": { - "Name": "us-east-1-instance-1", - "SecurityGroup": "instance-east-security-group" - }, - "tenancy": "default", - "timeouts": null, - "user_data": "cea2287097610e79f3bb839fad39d116ded10b48", - "user_data_base64": null, - "user_data_replace_on_change": false, - "volume_tags": null, - "vpc_security_group_ids": [ - "sg-0c4cb030408e58dd3" - ] - }, - "sensitive_attributes": [], - "private": "eyJlMmJmYjczMC1lY2FhLTExZTYtOGY4OC0zNDM2M2JjN2M0YzAiOnsiY3JlYXRlIjo2MDAwMDAwMDAwMDAsImRlbGV0ZSI6MTIwMDAwMDAwMDAwMCwidXBkYXRlIjo2MDAwMDAwMDAwMDB9LCJzY2hlbWFfdmVyc2lvbiI6IjEifQ==", - "dependencies": [ - "aws_security_group.us-east-1-instance-sg", - "aws_subnet.us-east-1-subnet-1", - "aws_vpc.us-east-1" - ] - } - ] - }, - { - "mode": "managed", - "type": "aws_instance", - "name": "us-east-1-instance-2", - "provider": "provider[\"registry.terraform.io/hashicorp/aws\"].us-east-1", - "instances": [ - { - "schema_version": 1, - "attributes": { - "ami": "ami-04e369782a6d2125e", - "arn": "arn:aws:ec2:us-east-1:349761350494:instance/i-0c81e8d1c35180b62", - "associate_public_ip_address": true, - "availability_zone": "us-east-1b", - "capacity_reservation_specification": [ - { - "capacity_reservation_preference": "open", - "capacity_reservation_target": [] - } - ], - "cpu_core_count": 1, - "cpu_options": [ - { - "amd_sev_snp": "", - "core_count": 1, - "threads_per_core": 2 - } - ], - "cpu_threads_per_core": 2, - "credit_specification": [ - { - "cpu_credits": "unlimited" - } - ], - "disable_api_stop": false, - "disable_api_termination": false, - "ebs_block_device": [], - "ebs_optimized": false, - "enclave_options": [ - { - "enabled": false - } - ], - "ephemeral_block_device": [], - "get_password_data": false, - "hibernation": false, - "host_id": "", - "host_resource_group_arn": null, - "iam_instance_profile": "", - "id": "i-0c81e8d1c35180b62", - "instance_initiated_shutdown_behavior": "stop", - "instance_lifecycle": "", - "instance_market_options": [], - "instance_state": "running", - "instance_type": "t3.small", - "ipv6_address_count": 0, - "ipv6_addresses": [], - "key_name": "", - "launch_template": [], - "maintenance_options": [ - { - "auto_recovery": "default" - } - ], - "metadata_options": [ - { - "http_endpoint": "enabled", - "http_protocol_ipv6": "disabled", - "http_put_response_hop_limit": 1, - "http_tokens": "optional", - "instance_metadata_tags": "disabled" - } - ], - "monitoring": false, - "network_interface": [], - "outpost_arn": "", - "password_data": "", - "placement_group": "", - "placement_partition_number": 0, - "primary_network_interface_id": "eni-0ade6c500ec9cde57", - "private_dns": "ip-10-1-2-152.ec2.internal", - "private_dns_name_options": [ - { - "enable_resource_name_dns_a_record": false, - "enable_resource_name_dns_aaaa_record": false, - "hostname_type": "ip-name" - } - ], - "private_ip": "10.1.2.152", - "public_dns": "", - "public_ip": "3.239.202.177", - "root_block_device": [ - { - "delete_on_termination": true, - "device_name": "/dev/sda1", - "encrypted": false, - "iops": 100, - "kms_key_id": "", - "tags": {}, - "throughput": 0, - "volume_id": "vol-0f4c13aa0554257d3", - "volume_size": 8, - "volume_type": "gp2" - } - ], - "secondary_private_ips": [], - "security_groups": [], - "source_dest_check": true, - "spot_instance_request_id": "", - "subnet_id": "subnet-0a5006434f12ab81a", - "tags": { - "Name": "us-east-1-instance-2", - "SecurityGroup": "instance-east-security-group" - }, - "tags_all": { - "Name": "us-east-1-instance-2", - "SecurityGroup": "instance-east-security-group" - }, - "tenancy": "default", - "timeouts": null, - "user_data": "cea2287097610e79f3bb839fad39d116ded10b48", - "user_data_base64": null, - "user_data_replace_on_change": false, - "volume_tags": null, - "vpc_security_group_ids": [ - "sg-0c4cb030408e58dd3" - ] - }, - "sensitive_attributes": [], - "private": "eyJlMmJmYjczMC1lY2FhLTExZTYtOGY4OC0zNDM2M2JjN2M0YzAiOnsiY3JlYXRlIjo2MDAwMDAwMDAwMDAsImRlbGV0ZSI6MTIwMDAwMDAwMDAwMCwidXBkYXRlIjo2MDAwMDAwMDAwMDB9LCJzY2hlbWFfdmVyc2lvbiI6IjEifQ==", - "dependencies": [ - "aws_security_group.us-east-1-instance-sg", - "aws_subnet.us-east-1-subnet-2", - "aws_vpc.us-east-1" - ] - } - ] - }, - { - "mode": "managed", - "type": "aws_instance", - "name": "us-west-1-instance-1", - "provider": "provider[\"registry.terraform.io/hashicorp/aws\"].us-west-1", - "instances": [ - { - "schema_version": 1, - "attributes": { - "ami": "ami-0f3f6663da6750955", - "arn": "arn:aws:ec2:us-west-1:349761350494:instance/i-0ff9245aefa0cc1c4", - "associate_public_ip_address": true, - "availability_zone": "us-west-1c", - "capacity_reservation_specification": [ - { - "capacity_reservation_preference": "open", - "capacity_reservation_target": [] - } - ], - "cpu_core_count": 1, - "cpu_options": [ - { - "amd_sev_snp": "", - "core_count": 1, - "threads_per_core": 2 - } - ], - "cpu_threads_per_core": 2, - "credit_specification": [ - { - "cpu_credits": "unlimited" - } - ], - "disable_api_stop": false, - "disable_api_termination": false, - "ebs_block_device": [], - "ebs_optimized": false, - "enclave_options": [ - { - "enabled": false - } - ], - "ephemeral_block_device": [], - "get_password_data": false, - "hibernation": false, - "host_id": "", - "host_resource_group_arn": null, - "iam_instance_profile": "", - "id": "i-0ff9245aefa0cc1c4", - "instance_initiated_shutdown_behavior": "stop", - "instance_lifecycle": "", - "instance_market_options": [], - "instance_state": "running", - "instance_type": "t3.small", - "ipv6_address_count": 0, - "ipv6_addresses": [], - "key_name": "", - "launch_template": [], - "maintenance_options": [ - { - "auto_recovery": "default" - } - ], - "metadata_options": [ - { - "http_endpoint": "enabled", - "http_protocol_ipv6": "disabled", - "http_put_response_hop_limit": 1, - "http_tokens": "optional", - "instance_metadata_tags": "disabled" - } - ], - "monitoring": false, - "network_interface": [], - "outpost_arn": "", - "password_data": "", - "placement_group": "", - "placement_partition_number": 0, - "primary_network_interface_id": "eni-0d4d0fd7c3612b6a9", - "private_dns": "ip-10-0-1-239.us-west-1.compute.internal", - "private_dns_name_options": [ - { - "enable_resource_name_dns_a_record": false, - "enable_resource_name_dns_aaaa_record": false, - "hostname_type": "ip-name" - } - ], - "private_ip": "10.0.1.239", - "public_dns": "", - "public_ip": "54.183.139.140", - "root_block_device": [ - { - "delete_on_termination": true, - "device_name": "/dev/sda1", - "encrypted": false, - "iops": 100, - "kms_key_id": "", - "tags": {}, - "throughput": 0, - "volume_id": "vol-079ca1f047f6b1740", - "volume_size": 8, - "volume_type": "gp2" - } - ], - "secondary_private_ips": [], - "security_groups": [], - "source_dest_check": true, - "spot_instance_request_id": "", - "subnet_id": "subnet-0abc3ec32314d1f41", - "tags": { - "Name": "us-west-1-instance-1", - "SecurityGroup": "instance-west-security-group" - }, - "tags_all": { - "Name": "us-west-1-instance-1", - "SecurityGroup": "instance-west-security-group" - }, - "tenancy": "default", - "timeouts": null, - "user_data": "cea2287097610e79f3bb839fad39d116ded10b48", - "user_data_base64": null, - "user_data_replace_on_change": false, - "volume_tags": null, - "vpc_security_group_ids": [ - "sg-0c50bd6752e97a00b" - ] - }, - "sensitive_attributes": [], - "private": "eyJlMmJmYjczMC1lY2FhLTExZTYtOGY4OC0zNDM2M2JjN2M0YzAiOnsiY3JlYXRlIjo2MDAwMDAwMDAwMDAsImRlbGV0ZSI6MTIwMDAwMDAwMDAwMCwidXBkYXRlIjo2MDAwMDAwMDAwMDB9LCJzY2hlbWFfdmVyc2lvbiI6IjEifQ==", - "dependencies": [ - "aws_security_group.us-west-1-instance-sg", - "aws_subnet.us-west-1-subnet-1", - "aws_vpc.us-west-1" - ] - } - ] - }, - { - "mode": "managed", - "type": "aws_instance", - "name": "us-west-1-instance-2", - "provider": "provider[\"registry.terraform.io/hashicorp/aws\"].us-west-1", - "instances": [ - { - "schema_version": 1, - "attributes": { - "ami": "ami-0f3f6663da6750955", - "arn": "arn:aws:ec2:us-west-1:349761350494:instance/i-0cad268b6a52b5208", - "associate_public_ip_address": true, - "availability_zone": "us-west-1b", - "capacity_reservation_specification": [ - { - "capacity_reservation_preference": "open", - "capacity_reservation_target": [] - } - ], - "cpu_core_count": 1, - "cpu_options": [ - { - "amd_sev_snp": "", - "core_count": 1, - "threads_per_core": 2 - } - ], - "cpu_threads_per_core": 2, - "credit_specification": [ - { - "cpu_credits": "unlimited" - } - ], - "disable_api_stop": false, - "disable_api_termination": false, - "ebs_block_device": [], - "ebs_optimized": false, - "enclave_options": [ - { - "enabled": false - } - ], - "ephemeral_block_device": [], - "get_password_data": false, - "hibernation": false, - "host_id": "", - "host_resource_group_arn": null, - "iam_instance_profile": "", - "id": "i-0cad268b6a52b5208", - "instance_initiated_shutdown_behavior": "stop", - "instance_lifecycle": "", - "instance_market_options": [], - "instance_state": "running", - "instance_type": "t3.small", - "ipv6_address_count": 0, - "ipv6_addresses": [], - "key_name": "", - "launch_template": [], - "maintenance_options": [ - { - "auto_recovery": "default" - } - ], - "metadata_options": [ - { - "http_endpoint": "enabled", - "http_protocol_ipv6": "disabled", - "http_put_response_hop_limit": 1, - "http_tokens": "optional", - "instance_metadata_tags": "disabled" - } - ], - "monitoring": false, - "network_interface": [], - "outpost_arn": "", - "password_data": "", - "placement_group": "", - "placement_partition_number": 0, - "primary_network_interface_id": "eni-05978279bb00376be", - "private_dns": "ip-10-0-2-74.us-west-1.compute.internal", - "private_dns_name_options": [ - { - "enable_resource_name_dns_a_record": false, - "enable_resource_name_dns_aaaa_record": false, - "hostname_type": "ip-name" - } - ], - "private_ip": "10.0.2.74", - "public_dns": "", - "public_ip": "54.67.94.5", - "root_block_device": [ - { - "delete_on_termination": true, - "device_name": "/dev/sda1", - "encrypted": false, - "iops": 100, - "kms_key_id": "", - "tags": {}, - "throughput": 0, - "volume_id": "vol-059bb7120b0ed7f1d", - "volume_size": 8, - "volume_type": "gp2" - } - ], - "secondary_private_ips": [], - "security_groups": [], - "source_dest_check": true, - "spot_instance_request_id": "", - "subnet_id": "subnet-0d7c68ad12d2a648b", - "tags": { - "Name": "us-west-1-instance-2", - "SecurityGroup": "instance-west-security-group" - }, - "tags_all": { - "Name": "us-west-1-instance-2", - "SecurityGroup": "instance-west-security-group" - }, - "tenancy": "default", - "timeouts": null, - "user_data": "cea2287097610e79f3bb839fad39d116ded10b48", - "user_data_base64": null, - "user_data_replace_on_change": false, - "volume_tags": null, - "vpc_security_group_ids": [ - "sg-0c50bd6752e97a00b" - ] - }, - "sensitive_attributes": [], - "private": "eyJlMmJmYjczMC1lY2FhLTExZTYtOGY4OC0zNDM2M2JjN2M0YzAiOnsiY3JlYXRlIjo2MDAwMDAwMDAwMDAsImRlbGV0ZSI6MTIwMDAwMDAwMDAwMCwidXBkYXRlIjo2MDAwMDAwMDAwMDB9LCJzY2hlbWFfdmVyc2lvbiI6IjEifQ==", - "dependencies": [ - "aws_security_group.us-west-1-instance-sg", - "aws_subnet.us-west-1-subnet-2", - "aws_vpc.us-west-1" - ] - } - ] - }, - { - "mode": "managed", - "type": "aws_route_table", - "name": "us-east-1-route-table", - "provider": "provider[\"registry.terraform.io/hashicorp/aws\"].us-east-1", - "instances": [ - { - "schema_version": 0, - "attributes": { - "arn": "arn:aws:ec2:us-east-1:349761350494:route-table/rtb-084e339de78854020", - "id": "rtb-084e339de78854020", - "owner_id": "349761350494", - "propagating_vgws": [], - "route": [], - "tags": null, - "tags_all": {}, - "timeouts": null, - "vpc_id": "vpc-065dddfbb64588639" - }, - "sensitive_attributes": [], - "private": "eyJlMmJmYjczMC1lY2FhLTExZTYtOGY4OC0zNDM2M2JjN2M0YzAiOnsiY3JlYXRlIjozMDAwMDAwMDAwMDAsImRlbGV0ZSI6MzAwMDAwMDAwMDAwLCJ1cGRhdGUiOjEyMDAwMDAwMDAwMH19", - "dependencies": [ - "aws_vpc.us-east-1" - ] - } - ] - }, - { - "mode": "managed", - "type": "aws_route_table", - "name": "us-west-1-route-table", - "provider": "provider[\"registry.terraform.io/hashicorp/aws\"].us-west-1", - "instances": [ - { - "schema_version": 0, - "attributes": { - "arn": "arn:aws:ec2:us-west-1:349761350494:route-table/rtb-07c9c4ed12d42c96b", - "id": "rtb-07c9c4ed12d42c96b", - "owner_id": "349761350494", - "propagating_vgws": [], - "route": [], - "tags": null, - "tags_all": {}, - "timeouts": null, - "vpc_id": "vpc-087c627d211c1faf6" - }, - "sensitive_attributes": [], - "private": "eyJlMmJmYjczMC1lY2FhLTExZTYtOGY4OC0zNDM2M2JjN2M0YzAiOnsiY3JlYXRlIjozMDAwMDAwMDAwMDAsImRlbGV0ZSI6MzAwMDAwMDAwMDAwLCJ1cGRhdGUiOjEyMDAwMDAwMDAwMH19", - "dependencies": [ - "aws_vpc.us-west-1" - ] - } - ] - }, - { - "mode": "managed", - "type": "aws_route_table_association", - "name": "us-east-1-subnet-1-association", - "provider": "provider[\"registry.terraform.io/hashicorp/aws\"].us-east-1", - "instances": [ - { - "schema_version": 0, - "attributes": { - "gateway_id": "", - "id": "rtbassoc-08cf50c09827ce0f9", - "route_table_id": "rtb-084e339de78854020", - "subnet_id": "subnet-0b8fd542ac3ac99f0", - "timeouts": null - }, - "sensitive_attributes": [], - "private": "eyJlMmJmYjczMC1lY2FhLTExZTYtOGY4OC0zNDM2M2JjN2M0YzAiOnsiY3JlYXRlIjozMDAwMDAwMDAwMDAsImRlbGV0ZSI6MzAwMDAwMDAwMDAwLCJ1cGRhdGUiOjEyMDAwMDAwMDAwMH19", - "dependencies": [ - "aws_route_table.us-east-1-route-table", - "aws_subnet.us-east-1-subnet-1", - "aws_vpc.us-east-1" - ] - } - ] - }, - { - "mode": "managed", - "type": "aws_route_table_association", - "name": "us-east-1-subnet-2-association", - "provider": "provider[\"registry.terraform.io/hashicorp/aws\"].us-east-1", - "instances": [ - { - "schema_version": 0, - "attributes": { - "gateway_id": "", - "id": "rtbassoc-0a2aacaa0e7003102", - "route_table_id": "rtb-084e339de78854020", - "subnet_id": "subnet-0a5006434f12ab81a", - "timeouts": null - }, - "sensitive_attributes": [], - "private": "eyJlMmJmYjczMC1lY2FhLTExZTYtOGY4OC0zNDM2M2JjN2M0YzAiOnsiY3JlYXRlIjozMDAwMDAwMDAwMDAsImRlbGV0ZSI6MzAwMDAwMDAwMDAwLCJ1cGRhdGUiOjEyMDAwMDAwMDAwMH19", - "dependencies": [ - "aws_route_table.us-east-1-route-table", - "aws_subnet.us-east-1-subnet-2", - "aws_vpc.us-east-1" - ] - } - ] - }, - { - "mode": "managed", - "type": "aws_route_table_association", - "name": "us-west-1-subnet-1-association", - "provider": "provider[\"registry.terraform.io/hashicorp/aws\"].us-west-1", - "instances": [ - { - "schema_version": 0, - "attributes": { - "gateway_id": "", - "id": "rtbassoc-08473bd1a7a981b70", - "route_table_id": "rtb-07c9c4ed12d42c96b", - "subnet_id": "subnet-0abc3ec32314d1f41", - "timeouts": null - }, - "sensitive_attributes": [], - "private": "eyJlMmJmYjczMC1lY2FhLTExZTYtOGY4OC0zNDM2M2JjN2M0YzAiOnsiY3JlYXRlIjozMDAwMDAwMDAwMDAsImRlbGV0ZSI6MzAwMDAwMDAwMDAwLCJ1cGRhdGUiOjEyMDAwMDAwMDAwMH19", - "dependencies": [ - "aws_route_table.us-west-1-route-table", - "aws_subnet.us-west-1-subnet-1", - "aws_vpc.us-west-1" - ] - } - ] - }, - { - "mode": "managed", - "type": "aws_route_table_association", - "name": "us-west-1-subnet-2-association", - "provider": "provider[\"registry.terraform.io/hashicorp/aws\"].us-west-1", - "instances": [ - { - "schema_version": 0, - "attributes": { - "gateway_id": "", - "id": "rtbassoc-0cc2ef70151fc7795", - "route_table_id": "rtb-07c9c4ed12d42c96b", - "subnet_id": "subnet-0d7c68ad12d2a648b", - "timeouts": null - }, - "sensitive_attributes": [], - "private": "eyJlMmJmYjczMC1lY2FhLTExZTYtOGY4OC0zNDM2M2JjN2M0YzAiOnsiY3JlYXRlIjozMDAwMDAwMDAwMDAsImRlbGV0ZSI6MzAwMDAwMDAwMDAwLCJ1cGRhdGUiOjEyMDAwMDAwMDAwMH19", - "dependencies": [ - "aws_route_table.us-west-1-route-table", - "aws_subnet.us-west-1-subnet-2", - "aws_vpc.us-west-1" - ] - } - ] - }, - { - "mode": "managed", - "type": "aws_security_group", - "name": "us-east-1-instance-sg", - "provider": "provider[\"registry.terraform.io/hashicorp/aws\"].us-east-1", - "instances": [ - { - "schema_version": 1, - "attributes": { - "arn": "arn:aws:ec2:us-east-1:349761350494:security-group/sg-0c4cb030408e58dd3", - "description": "Managed by Terraform", - "egress": [ - { - "cidr_blocks": [ - "10.1.0.0/16", - "0.0.0.0/0" - ], - "description": "", - "from_port": 0, - "ipv6_cidr_blocks": [], - "prefix_list_ids": [], - "protocol": "-1", - "security_groups": [], - "self": false, - "to_port": 0 - } - ], - "id": "sg-0c4cb030408e58dd3", - "ingress": [ - { - "cidr_blocks": [ - "0.0.0.0/0" - ], - "description": "", - "from_port": 22, - "ipv6_cidr_blocks": [], - "prefix_list_ids": [], - "protocol": "tcp", - "security_groups": [], - "self": false, - "to_port": 22 - }, - { - "cidr_blocks": [ - "0.0.0.0/0" - ], - "description": "", - "from_port": 443, - "ipv6_cidr_blocks": [], - "prefix_list_ids": [], - "protocol": "tcp", - "security_groups": [], - "self": false, - "to_port": 443 - }, - { - "cidr_blocks": [ - "0.0.0.0/0" - ], - "description": "", - "from_port": 80, - "ipv6_cidr_blocks": [], - "prefix_list_ids": [], - "protocol": "tcp", - "security_groups": [], - "self": false, - "to_port": 80 - } - ], - "name": "terraform-20231118005438355900000001", - "name_prefix": "terraform-", - "owner_id": "349761350494", - "revoke_rules_on_delete": false, - "tags": { - "Name": "instance-east-security-group" - }, - "tags_all": { - "Name": "instance-east-security-group" - }, - "timeouts": null, - "vpc_id": "vpc-065dddfbb64588639" - }, - "sensitive_attributes": [], - "private": "eyJlMmJmYjczMC1lY2FhLTExZTYtOGY4OC0zNDM2M2JjN2M0YzAiOnsiY3JlYXRlIjo2MDAwMDAwMDAwMDAsImRlbGV0ZSI6OTAwMDAwMDAwMDAwfSwic2NoZW1hX3ZlcnNpb24iOiIxIn0=", - "dependencies": [ - "aws_vpc.us-east-1" - ] - } - ] - }, - { - "mode": "managed", - "type": "aws_security_group", - "name": "us-west-1-instance-sg", - "provider": "provider[\"registry.terraform.io/hashicorp/aws\"].us-west-1", - "instances": [ - { - "schema_version": 1, - "attributes": { - "arn": "arn:aws:ec2:us-west-1:349761350494:security-group/sg-0c50bd6752e97a00b", - "description": "Managed by Terraform", - "egress": [ - { - "cidr_blocks": [ - "10.1.0.0/16", - "0.0.0.0/0" - ], - "description": "", - "from_port": 0, - "ipv6_cidr_blocks": [], - "prefix_list_ids": [], - "protocol": "-1", - "security_groups": [], - "self": false, - "to_port": 0 - } - ], - "id": "sg-0c50bd6752e97a00b", - "ingress": [ - { - "cidr_blocks": [ - "0.0.0.0/0" - ], - "description": "", - "from_port": 22, - "ipv6_cidr_blocks": [], - "prefix_list_ids": [], - "protocol": "tcp", - "security_groups": [], - "self": false, - "to_port": 22 - }, - { - "cidr_blocks": [ - "0.0.0.0/0" - ], - "description": "", - "from_port": 443, - "ipv6_cidr_blocks": [], - "prefix_list_ids": [], - "protocol": "tcp", - "security_groups": [], - "self": false, - "to_port": 443 - }, - { - "cidr_blocks": [ - "0.0.0.0/0" - ], - "description": "", - "from_port": 80, - "ipv6_cidr_blocks": [], - "prefix_list_ids": [], - "protocol": "tcp", - "security_groups": [], - "self": false, - "to_port": 80 - } - ], - "name": "terraform-20231118005439030200000001", - "name_prefix": "terraform-", - "owner_id": "349761350494", - "revoke_rules_on_delete": false, - "tags": { - "Name": "instance-west-security-group" - }, - "tags_all": { - "Name": "instance-west-security-group" - }, - "timeouts": null, - "vpc_id": "vpc-087c627d211c1faf6" - }, - "sensitive_attributes": [], - "private": "eyJlMmJmYjczMC1lY2FhLTExZTYtOGY4OC0zNDM2M2JjN2M0YzAiOnsiY3JlYXRlIjo2MDAwMDAwMDAwMDAsImRlbGV0ZSI6OTAwMDAwMDAwMDAwfSwic2NoZW1hX3ZlcnNpb24iOiIxIn0=", - "dependencies": [ - "aws_vpc.us-west-1" - ] - } - ] - }, - { - "mode": "managed", - "type": "aws_subnet", - "name": "us-east-1-subnet-1", - "provider": "provider[\"registry.terraform.io/hashicorp/aws\"].us-east-1", - "instances": [ - { - "schema_version": 1, - "attributes": { - "arn": "arn:aws:ec2:us-east-1:349761350494:subnet/subnet-0b8fd542ac3ac99f0", - "assign_ipv6_address_on_creation": false, - "availability_zone": "us-east-1c", - "availability_zone_id": "use1-az2", - "cidr_block": "10.1.1.0/24", - "customer_owned_ipv4_pool": "", - "enable_dns64": false, - "enable_lni_at_device_index": 0, - "enable_resource_name_dns_a_record_on_launch": false, - "enable_resource_name_dns_aaaa_record_on_launch": false, - "id": "subnet-0b8fd542ac3ac99f0", - "ipv6_cidr_block": "", - "ipv6_cidr_block_association_id": "", - "ipv6_native": false, - "map_customer_owned_ip_on_launch": false, - "map_public_ip_on_launch": false, - "outpost_arn": "", - "owner_id": "349761350494", - "private_dns_hostname_type_on_launch": "ip-name", - "tags": null, - "tags_all": {}, - "timeouts": null, - "vpc_id": "vpc-065dddfbb64588639" - }, - "sensitive_attributes": [], - "private": "eyJlMmJmYjczMC1lY2FhLTExZTYtOGY4OC0zNDM2M2JjN2M0YzAiOnsiY3JlYXRlIjo2MDAwMDAwMDAwMDAsImRlbGV0ZSI6MTIwMDAwMDAwMDAwMH0sInNjaGVtYV92ZXJzaW9uIjoiMSJ9", - "dependencies": [ - "aws_vpc.us-east-1" - ] - } - ] - }, - { - "mode": "managed", - "type": "aws_subnet", - "name": "us-east-1-subnet-2", - "provider": "provider[\"registry.terraform.io/hashicorp/aws\"].us-east-1", - "instances": [ - { - "schema_version": 1, - "attributes": { - "arn": "arn:aws:ec2:us-east-1:349761350494:subnet/subnet-0a5006434f12ab81a", - "assign_ipv6_address_on_creation": false, - "availability_zone": "us-east-1b", - "availability_zone_id": "use1-az1", - "cidr_block": "10.1.2.0/24", - "customer_owned_ipv4_pool": "", - "enable_dns64": false, - "enable_lni_at_device_index": 0, - "enable_resource_name_dns_a_record_on_launch": false, - "enable_resource_name_dns_aaaa_record_on_launch": false, - "id": "subnet-0a5006434f12ab81a", - "ipv6_cidr_block": "", - "ipv6_cidr_block_association_id": "", - "ipv6_native": false, - "map_customer_owned_ip_on_launch": false, - "map_public_ip_on_launch": false, - "outpost_arn": "", - "owner_id": "349761350494", - "private_dns_hostname_type_on_launch": "ip-name", - "tags": null, - "tags_all": {}, - "timeouts": null, - "vpc_id": "vpc-065dddfbb64588639" - }, - "sensitive_attributes": [], - "private": "eyJlMmJmYjczMC1lY2FhLTExZTYtOGY4OC0zNDM2M2JjN2M0YzAiOnsiY3JlYXRlIjo2MDAwMDAwMDAwMDAsImRlbGV0ZSI6MTIwMDAwMDAwMDAwMH0sInNjaGVtYV92ZXJzaW9uIjoiMSJ9", - "dependencies": [ - "aws_vpc.us-east-1" - ] - } - ] - }, - { - "mode": "managed", - "type": "aws_subnet", - "name": "us-west-1-subnet-1", - "provider": "provider[\"registry.terraform.io/hashicorp/aws\"].us-west-1", - "instances": [ - { - "schema_version": 1, - "attributes": { - "arn": "arn:aws:ec2:us-west-1:349761350494:subnet/subnet-0abc3ec32314d1f41", - "assign_ipv6_address_on_creation": false, - "availability_zone": "us-west-1c", - "availability_zone_id": "usw1-az1", - "cidr_block": "10.0.1.0/24", - "customer_owned_ipv4_pool": "", - "enable_dns64": false, - "enable_lni_at_device_index": 0, - "enable_resource_name_dns_a_record_on_launch": false, - "enable_resource_name_dns_aaaa_record_on_launch": false, - "id": "subnet-0abc3ec32314d1f41", - "ipv6_cidr_block": "", - "ipv6_cidr_block_association_id": "", - "ipv6_native": false, - "map_customer_owned_ip_on_launch": false, - "map_public_ip_on_launch": false, - "outpost_arn": "", - "owner_id": "349761350494", - "private_dns_hostname_type_on_launch": "ip-name", - "tags": null, - "tags_all": {}, - "timeouts": null, - "vpc_id": "vpc-087c627d211c1faf6" - }, - "sensitive_attributes": [], - "private": "eyJlMmJmYjczMC1lY2FhLTExZTYtOGY4OC0zNDM2M2JjN2M0YzAiOnsiY3JlYXRlIjo2MDAwMDAwMDAwMDAsImRlbGV0ZSI6MTIwMDAwMDAwMDAwMH0sInNjaGVtYV92ZXJzaW9uIjoiMSJ9", - "dependencies": [ - "aws_vpc.us-west-1" - ] - } - ] - }, - { - "mode": "managed", - "type": "aws_subnet", - "name": "us-west-1-subnet-2", - "provider": "provider[\"registry.terraform.io/hashicorp/aws\"].us-west-1", - "instances": [ - { - "schema_version": 1, - "attributes": { - "arn": "arn:aws:ec2:us-west-1:349761350494:subnet/subnet-0d7c68ad12d2a648b", - "assign_ipv6_address_on_creation": false, - "availability_zone": "us-west-1b", - "availability_zone_id": "usw1-az3", - "cidr_block": "10.0.2.0/24", - "customer_owned_ipv4_pool": "", - "enable_dns64": false, - "enable_lni_at_device_index": 0, - "enable_resource_name_dns_a_record_on_launch": false, - "enable_resource_name_dns_aaaa_record_on_launch": false, - "id": "subnet-0d7c68ad12d2a648b", - "ipv6_cidr_block": "", - "ipv6_cidr_block_association_id": "", - "ipv6_native": false, - "map_customer_owned_ip_on_launch": false, - "map_public_ip_on_launch": false, - "outpost_arn": "", - "owner_id": "349761350494", - "private_dns_hostname_type_on_launch": "ip-name", - "tags": null, - "tags_all": {}, - "timeouts": null, - "vpc_id": "vpc-087c627d211c1faf6" - }, - "sensitive_attributes": [], - "private": "eyJlMmJmYjczMC1lY2FhLTExZTYtOGY4OC0zNDM2M2JjN2M0YzAiOnsiY3JlYXRlIjo2MDAwMDAwMDAwMDAsImRlbGV0ZSI6MTIwMDAwMDAwMDAwMH0sInNjaGVtYV92ZXJzaW9uIjoiMSJ9", - "dependencies": [ - "aws_vpc.us-west-1" - ] - } - ] - }, - { - "mode": "managed", - "type": "aws_vpc", - "name": "us-east-1", - "provider": "provider[\"registry.terraform.io/hashicorp/aws\"].us-east-1", - "instances": [ - { - "schema_version": 1, - "attributes": { - "arn": "arn:aws:ec2:us-east-1:349761350494:vpc/vpc-065dddfbb64588639", - "assign_generated_ipv6_cidr_block": false, - "cidr_block": "10.1.0.0/16", - "default_network_acl_id": "acl-0a7603e25f1233cef", - "default_route_table_id": "rtb-08ce8d4dfff1f1f86", - "default_security_group_id": "sg-0986bd00c792c02f6", - "dhcp_options_id": "dopt-6e030515", - "enable_dns_hostnames": false, - "enable_dns_support": true, - "enable_network_address_usage_metrics": false, - "id": "vpc-065dddfbb64588639", - "instance_tenancy": "default", - "ipv4_ipam_pool_id": null, - "ipv4_netmask_length": null, - "ipv6_association_id": "", - "ipv6_cidr_block": "", - "ipv6_cidr_block_network_border_group": "", - "ipv6_ipam_pool_id": "", - "ipv6_netmask_length": 0, - "main_route_table_id": "rtb-08ce8d4dfff1f1f86", - "owner_id": "349761350494", - "tags": null, - "tags_all": {} - }, - "sensitive_attributes": [], - "private": "eyJzY2hlbWFfdmVyc2lvbiI6IjEifQ==" - } - ] - }, - { - "mode": "managed", - "type": "aws_vpc", - "name": "us-west-1", - "provider": "provider[\"registry.terraform.io/hashicorp/aws\"].us-west-1", - "instances": [ - { - "schema_version": 1, - "attributes": { - "arn": "arn:aws:ec2:us-west-1:349761350494:vpc/vpc-087c627d211c1faf6", - "assign_generated_ipv6_cidr_block": false, - "cidr_block": "10.0.0.0/16", - "default_network_acl_id": "acl-0a625ac6d1577cf74", - "default_route_table_id": "rtb-01f025a6d0914dec0", - "default_security_group_id": "sg-05043c20973654d7d", - "dhcp_options_id": "dopt-1adbfc7d", - "enable_dns_hostnames": false, - "enable_dns_support": true, - "enable_network_address_usage_metrics": false, - "id": "vpc-087c627d211c1faf6", - "instance_tenancy": "default", - "ipv4_ipam_pool_id": null, - "ipv4_netmask_length": null, - "ipv6_association_id": "", - "ipv6_cidr_block": "", - "ipv6_cidr_block_network_border_group": "", - "ipv6_ipam_pool_id": "", - "ipv6_netmask_length": 0, - "main_route_table_id": "rtb-01f025a6d0914dec0", - "owner_id": "349761350494", - "tags": null, - "tags_all": {} - }, - "sensitive_attributes": [], - "private": "eyJzY2hlbWFfdmVyc2lvbiI6IjEifQ==" - } - ] - }, - { - "mode": "managed", - "type": "aws_vpc_peering_connection", - "name": "peering_connection", - "provider": "provider[\"registry.terraform.io/hashicorp/aws\"].us-west-1", - "instances": [ - { - "schema_version": 0, - "attributes": { - "accept_status": "pending-acceptance", - "accepter": [], - "auto_accept": false, - "id": "pcx-07c02e0bfd18ccdb9", - "peer_owner_id": "349761350494", - "peer_region": "us-east-1", - "peer_vpc_id": "vpc-065dddfbb64588639", - "requester": [ - { - "allow_remote_vpc_dns_resolution": false - } - ], - "tags": null, - "tags_all": {}, - "timeouts": null, - "vpc_id": "vpc-087c627d211c1faf6" - }, - "sensitive_attributes": [], - "private": "eyJlMmJmYjczMC1lY2FhLTExZTYtOGY4OC0zNDM2M2JjN2M0YzAiOnsiY3JlYXRlIjo2MDAwMDAwMDAwMCwiZGVsZXRlIjo2MDAwMDAwMDAwMCwidXBkYXRlIjo2MDAwMDAwMDAwMH19", - "dependencies": [ - "aws_vpc.us-east-1", - "aws_vpc.us-west-1" - ] - } - ] - }, - { - "mode": "managed", - "type": "aws_vpc_peering_connection_accepter", - "name": "peering_accepter", - "provider": "provider[\"registry.terraform.io/hashicorp/aws\"].us-east-1", - "instances": [ - { - "schema_version": 0, - "attributes": { - "accept_status": "active", - "accepter": [ - { - "allow_remote_vpc_dns_resolution": false - } - ], - "auto_accept": true, - "id": "pcx-07c02e0bfd18ccdb9", - "peer_owner_id": "349761350494", - "peer_region": "us-east-1", - "peer_vpc_id": "vpc-065dddfbb64588639", - "requester": [ - { - "allow_remote_vpc_dns_resolution": false - } - ], - "tags": null, - "tags_all": {}, - "timeouts": null, - "vpc_id": "vpc-087c627d211c1faf6", - "vpc_peering_connection_id": "pcx-07c02e0bfd18ccdb9" - }, - "sensitive_attributes": [], - "private": "eyJlMmJmYjczMC1lY2FhLTExZTYtOGY4OC0zNDM2M2JjN2M0YzAiOnsiY3JlYXRlIjo2MDAwMDAwMDAwMCwidXBkYXRlIjo2MDAwMDAwMDAwMH19", - "dependencies": [ - "aws_vpc.us-east-1", - "aws_vpc.us-west-1", - "aws_vpc_peering_connection.peering_connection" - ] - } - ] - } - ], - "check_results": null -} diff --git a/aws/example-backend/main.tf b/aws/terraform-backend/main.tf similarity index 100% rename from aws/example-backend/main.tf rename to aws/terraform-backend/main.tf diff --git a/aws/terraform-backend/terraform.tfstate b/aws/terraform-backend/terraform.tfstate new file mode 100644 index 0000000..dc357be --- /dev/null +++ b/aws/terraform-backend/terraform.tfstate @@ -0,0 +1,9 @@ +{ + "version": 4, + "terraform_version": "1.6.4", + "serial": 1, + "lineage": "d32d4884-4d57-90bf-bf50-91dba9c4212a", + "outputs": {}, + "resources": [], + "check_results": null +} From a5691f156b50dd149771b91cf5c5fc7472b01563 Mon Sep 17 00:00:00 2001 From: Greg Hendrickson Date: Fri, 17 Nov 2023 17:09:36 -0800 Subject: [PATCH 11/17] remove .tfstate... --- .../.terraform/terraform.tfstate | 74 ------------------- 1 file changed, 74 deletions(-) delete mode 100644 aws/aws_vpc_peering/.terraform/terraform.tfstate diff --git a/aws/aws_vpc_peering/.terraform/terraform.tfstate b/aws/aws_vpc_peering/.terraform/terraform.tfstate deleted file mode 100644 index 1186434..0000000 --- a/aws/aws_vpc_peering/.terraform/terraform.tfstate +++ /dev/null @@ -1,74 +0,0 @@ -{ - "version": 3, - "serial": 1, - "lineage": "d2c9bc57-2b6a-7881-0aa9-ac0ba7c8db89", - "backend": { - "type": "s3", - "config": { - "access_key": null, - "acl": null, - "allowed_account_ids": null, - "assume_role": null, - "assume_role_duration_seconds": null, - "assume_role_policy": null, - "assume_role_policy_arns": null, - "assume_role_tags": null, - "assume_role_transitive_tag_keys": null, - "assume_role_with_web_identity": null, - "bucket": "my-tf-bucket-ghndrx", - "custom_ca_bundle": null, - "dynamodb_endpoint": null, - "dynamodb_table": null, - "ec2_metadata_service_endpoint": null, - "ec2_metadata_service_endpoint_mode": null, - "encrypt": null, - "endpoint": null, - "endpoints": null, - "external_id": null, - "forbidden_account_ids": null, - "force_path_style": null, - "http_proxy": null, - "https_proxy": null, - "iam_endpoint": null, - "insecure": null, - "key": "aws_vpc_peering/terraform.tfstate", - "kms_key_id": null, - "max_retries": null, - "no_proxy": null, - "profile": null, - "region": "us-west-2", - "retry_mode": null, - "role_arn": null, - "secret_key": null, - "session_name": null, - "shared_config_files": null, - "shared_credentials_file": null, - "shared_credentials_files": null, - "skip_credentials_validation": null, - "skip_metadata_api_check": null, - "skip_region_validation": null, - "skip_requesting_account_id": null, - "skip_s3_checksum": null, - "sse_customer_key": null, - "sts_endpoint": null, - "sts_region": null, - "token": null, - "use_dualstack_endpoint": null, - "use_fips_endpoint": null, - "use_legacy_workflow": null, - "use_path_style": null, - "workspace_key_prefix": null - }, - "hash": 1294417248 - }, - "modules": [ - { - "path": [ - "root" - ], - "outputs": {}, - "resources": {}, - "depends_on": [] - } - ] -} From b8460459b28e2034d9d03318a6b574a1a814ffbe Mon Sep 17 00:00:00 2001 From: Greg Hendrickson Date: Fri, 17 Nov 2023 17:11:52 -0800 Subject: [PATCH 12/17] update gitignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index e58c84c..c692f69 100644 --- a/.gitignore +++ b/.gitignore @@ -17,3 +17,4 @@ aws/aws_vpc_peering/.terraform.lock.hcl aws/aws_vpc_peering/terraform.tfstate .gitignore aws/aws_vpc_peering/.terraform/providers/registry.terraform.io/hashicorp/aws/5.26.0/linux_amd64/terraform-provider-aws_v5.26.0_x5 +aws/aws_vpc_peering/.terraform/terraform.tfstate From a3047ac5980762c86c9ffdc60a12b6a79e53931e Mon Sep 17 00:00:00 2001 From: Greg Hendrickson Date: Fri, 17 Nov 2023 17:14:36 -0800 Subject: [PATCH 13/17] add wildcards --- .gitignore | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/.gitignore b/.gitignore index c692f69..73eae0d 100644 --- a/.gitignore +++ b/.gitignore @@ -1,13 +1,10 @@ -aws/aws_simple/.terraform.lock.hcl -aws/aws_simple/.terraform/modules/modules.json -aws/aws_simple/terraform.tfstate.backup -aws/aws_simple/terraform.tfstate -aws/aws_simple/.terraform/providers/registry.terraform.io/hashicorp/aws/5.25.0/linux_amd64/terraform-provider-aws_v5.25.0_x5 -aws/aws_simple/.terraform.tfstate.lock.info -aws/backend/terraform.tfstate -aws/s3/.terraform.lock.hcl -aws/s3/terraform.tfstate -aws/s3/terraform.tfstate.backup +*.terraform.lock.hcl +*.terraform/modules/modules.json +*terraform.tfstate.backup +*terraform.tfstate +*.terraform/providers/registry.terraform.io/hashicorp/aws/5.25.0/linux_amd64/terraform-provider-aws_v5.25.0_x5 +*.terraform.tfstate.lock.info +*terraform.tfstate aws/s3/.terraform/providers/registry.terraform.io/hashicorp/aws/5.26.0/linux_amd64/terraform-provider-aws_v5.26.0_x5 aws/aws_simple/.terraform/providers/registry.terraform.io/hashicorp/template/2.2.0/linux_amd64/terraform-provider-template_v2.2.0_x4 aws/aws_simple/.terraform/providers/registry.terraform.io/hashicorp/aws/5.26.0/linux_amd64/terraform-provider-aws_v5.26.0_x5 From c5f625b8415fed14b2bedb41b973b8cedf8435ce Mon Sep 17 00:00:00 2001 From: Greg Hendrickson Date: Fri, 17 Nov 2023 19:56:08 -0800 Subject: [PATCH 14/17] update ignore --- .gitignore | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 73eae0d..f6af84a 100644 --- a/.gitignore +++ b/.gitignore @@ -5,7 +5,7 @@ *.terraform/providers/registry.terraform.io/hashicorp/aws/5.25.0/linux_amd64/terraform-provider-aws_v5.25.0_x5 *.terraform.tfstate.lock.info *terraform.tfstate -aws/s3/.terraform/providers/registry.terraform.io/hashicorp/aws/5.26.0/linux_amd64/terraform-provider-aws_v5.26.0_x5 +*.terraform/providers/registry.terraform.io/hashicorp/aws/5.26.0/linux_amd64/terraform-provider-aws_v5.26.0_x5 aws/aws_simple/.terraform/providers/registry.terraform.io/hashicorp/template/2.2.0/linux_amd64/terraform-provider-template_v2.2.0_x4 aws/aws_simple/.terraform/providers/registry.terraform.io/hashicorp/aws/5.26.0/linux_amd64/terraform-provider-aws_v5.26.0_x5 aws/aws_simple/.terraform/terraform.tfstate From 5d7a46eb42f19a09d27a9896d6e710e37dc2e4ec Mon Sep 17 00:00:00 2001 From: Greg Hendrickson Date: Fri, 17 Nov 2023 19:56:18 -0800 Subject: [PATCH 15/17] update ignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index f6af84a..9a9b424 100644 --- a/.gitignore +++ b/.gitignore @@ -15,3 +15,4 @@ aws/aws_vpc_peering/terraform.tfstate .gitignore aws/aws_vpc_peering/.terraform/providers/registry.terraform.io/hashicorp/aws/5.26.0/linux_amd64/terraform-provider-aws_v5.26.0_x5 aws/aws_vpc_peering/.terraform/terraform.tfstate +aws/s3/.terraform/providers/registry.terraform.io/hashicorp/aws/5.26.0/linux_amd64/terraform-provider-aws_v5.26.0_x5 From ace93b1584845be1960095dda16927bd9ef24f30 Mon Sep 17 00:00:00 2001 From: Greg Hendrickson Date: Fri, 17 Nov 2023 19:56:50 -0800 Subject: [PATCH 16/17] update ignore --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 9a9b424..e904c80 100644 --- a/.gitignore +++ b/.gitignore @@ -16,3 +16,4 @@ aws/aws_vpc_peering/terraform.tfstate aws/aws_vpc_peering/.terraform/providers/registry.terraform.io/hashicorp/aws/5.26.0/linux_amd64/terraform-provider-aws_v5.26.0_x5 aws/aws_vpc_peering/.terraform/terraform.tfstate aws/s3/.terraform/providers/registry.terraform.io/hashicorp/aws/5.26.0/linux_amd64/terraform-provider-aws_v5.26.0_x5 +aws/terraform-backend/terraform.tfstate From 6287a9f6cc9dc3958923752edd1ac91ed40b7901 Mon Sep 17 00:00:00 2001 From: Greg Hendrickson Date: Fri, 17 Nov 2023 19:57:55 -0800 Subject: [PATCH 17/17] Delete aws/terraform-backend/terraform.tfstate --- aws/terraform-backend/terraform.tfstate | 9 --------- 1 file changed, 9 deletions(-) delete mode 100644 aws/terraform-backend/terraform.tfstate diff --git a/aws/terraform-backend/terraform.tfstate b/aws/terraform-backend/terraform.tfstate deleted file mode 100644 index dc357be..0000000 --- a/aws/terraform-backend/terraform.tfstate +++ /dev/null @@ -1,9 +0,0 @@ -{ - "version": 4, - "terraform_version": "1.6.4", - "serial": 1, - "lineage": "d32d4884-4d57-90bf-bf50-91dba9c4212a", - "outputs": {}, - "resources": [], - "check_results": null -}