This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
resource "tls_private_key" "awsnetblog_vpc_01-privatekey_01" { | |
algorithm = "RSA" | |
rsa_bits = 4096 | |
provisioner "local-exec" { | |
command = "echo '${tls_private_key.awsnetblog_vpc_01-privatekey_01.public_key_openssh}' > ./awsnetblog_vpc_01-privatekey_01.pub" | |
} | |
provisioner "local-exec" { | |
command = "echo '${tls_private_key.awsnetblog_vpc_01-privatekey_01.private_key_pem}' > ./awsnetblog_vpc_01-privatekey_01.pem" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
resource "aws_instance" "awsnetblog_vpc_01-subnet_02_private-ec2_01" { | |
ami = "ami-03f65b8614a860c29" | |
instance_type = "t2.micro" | |
subnet_id = aws_subnet.awsnetblog_vpc_01-subnet_02_private.id | |
key_name = aws_key_pair.awsnetblog_vpc_01-keypair_01.key_name | |
vpc_security_group_ids = [ | |
aws_security_group.awsnetblog_vpc_01-subnet_02_private-sg_01.id | |
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
resource "aws_instance" "awsnetblog_vpc_01-subnet_01_public-ec2_01" { | |
ami = "ami-03f65b8614a860c29" | |
instance_type = "t2.micro" | |
subnet_id = aws_subnet.awsnetblog_vpc_01-subnet_01_public.id | |
key_name = aws_key_pair.awsnetblog_vpc_01-keypair_01.key_name | |
vpc_security_group_ids = [ | |
aws_security_group.awsnetblog_vpc_01-subnet_01_public-sg_01.id | |
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
resource "aws_subnet" "awsnetblog_vpc_01-subnet_02_private" { | |
assign_ipv6_address_on_creation = false | |
availability_zone = "us-west-2a" | |
cidr_block = "10.1.2.0/24" | |
map_public_ip_on_launch = false | |
vpc_id = aws_vpc.awsnetblog_vpc_01.id | |
timeouts {} | |
tags = { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
resource "aws_eip" "awsnetblog_vpc_01-subnet_01_public-ngw_01-eip_01" { | |
tags = { | |
"Name" = "awsnetblog_vpc_01-subnet_01_public-ngw_01-eip_01" | |
"Project" = var.project | |
} | |
} | |
resource "aws_nat_gateway" "awsnetblog_vpc_01-subnet_01_public-ngw_01" { | |
subnet_id = aws_subnet.awsnetblog_vpc_01-subnet_01_public.id |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
resource "aws_subnet" "awsnetblog_vpc_01-subnet_01_public" { | |
assign_ipv6_address_on_creation = false | |
availability_zone = "us-west-2a" | |
cidr_block = "10.1.1.0/24" | |
map_public_ip_on_launch = false | |
vpc_id = aws_vpc.awsnetblog_vpc_01.id | |
timeouts {} | |
tags = { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
resource "aws_vpc" "awsnetblog_vpc_01" { | |
assign_generated_ipv6_cidr_block = false | |
cidr_block = "10.1.0.0/16" | |
instance_tenancy = "default" | |
tags = { | |
"Name" = "awsnetblog_vpc_01" | |
"Project" = var.project | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
terraform { | |
required_version = "> 1.5.0" | |
required_providers { | |
aws = { | |
source = "hashicorp/aws" | |
version = "= 5.3.0" | |
} | |
} | |
backend "s3" { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
resource "aws_s3_bucket" "awsnetblog-s3b-tf" { | |
bucket = "awsnetblog-s3b-tf" | |
tags = { | |
name = "awsnetblog-s3b-tf" | |
Descr = "awsnetblog s3 bucket for remote terraform state" | |
Project = "awsnetblog" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
variable "region" { | |
description = "name of aws region" | |
type = string | |
default = "us-west-2" | |
} | |
variable "project" { | |
default = "awsnetblog" | |
} |
NewerOlder