Difference between revisions of "AWS instance example creating VPC"

From wikieduonline
Jump to navigation Jump to search
 
(3 intermediate revisions by 2 users not shown)
Line 7: Line 7:
 
  }  
 
  }  
 
   
 
   
  resource "aws_instance" "example" {
+
  resource "[[aws_instance]]" "example" {
 
   ami = "ami-2757f631"
 
   ami = "ami-2757f631"
 
   instance_type = "t2.micro"
 
   instance_type = "t2.micro"
   subnet_id = "${aws_subnet.us-east-1a-public.id}"
+
   [[subnet_id]] = "${aws_subnet.us-east-1a-public.id}"
 
  }
 
  }
<pre>
 
resource "aws_vpc" "example" {
 
  cidr_block = "10.0.0.0/16"
 
  enable_dns_hostnames = true
 
  enable_dns_support = true
 
}
 
  
resource "aws_subnet" "us-east-1a-public" {
+
resource "aws_vpc" "example" {
  vpc_id = "${aws_vpc.example.id}"
+
  cidr_block = "10.0.0.0/16"
  cidr_block = "10.0.1.0/25"
+
  enable_dns_hostnames = true
  availability_zone = "us-east-1a"
+
  enable_dns_support = true
}
+
}
 +
 +
resource "[[aws_subnet]]" "us-east-1a-public" {
 +
  vpc_id = "${aws_vpc.example.id}"
 +
  cidr_block = "10.0.1.0/25"
 +
  availability_zone = "us-east-1a"
 +
}
  
 
</pre>
 
</pre>
  
 
== See also ==
 
== See also ==
* {{Terraform}}
+
* {{Terraform VPC}}
  
 
[[Category:Terraform]]
 
[[Category:Terraform]]

Latest revision as of 05:59, 13 March 2023

provider "aws" {
  access_key = "ACCESS_KEY_HERE"
  secret_key = "SECRET_KEY_HERE"
  region = "us-east-1"
  profile = "your_profile_name"
} 

resource "aws_instance" "example" {
  ami = "ami-2757f631"
  instance_type = "t2.micro"
  subnet_id = "${aws_subnet.us-east-1a-public.id}"
}
resource "aws_vpc" "example" {
  cidr_block = "10.0.0.0/16"
  enable_dns_hostnames = true
  enable_dns_support = true
}

resource "aws_subnet" "us-east-1a-public" {
  vpc_id = "${aws_vpc.example.id}"
  cidr_block = "10.0.1.0/25"
  availability_zone = "us-east-1a"
}

See also[edit]

Advertising: