amazon web services hands-on vpcguides/pdf/vpc+hol.pdf · amazon web services hands-on vpc january...

42
Copyright 2016, Amazon Web Services, All Rights Reserved Page 1 Amazon Web Services Hands-On VPC January 2016

Upload: lyhanh

Post on 20-May-2018

232 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Amazon Web Services Hands-On VPCGuides/PDF/VPC+HOL.pdf · Amazon Web Services Hands-On VPC January 2016 VPC Hands-On Lab ... • Launch EC2 instances into the VPC • Assign a public

Copyright2016,AmazonWebServices,AllRightsReservedPage1

AmazonWebServicesHands-OnVPC

January2016

Page 2: Amazon Web Services Hands-On VPCGuides/PDF/VPC+HOL.pdf · Amazon Web Services Hands-On VPC January 2016 VPC Hands-On Lab ... • Launch EC2 instances into the VPC • Assign a public

VPCHands-OnLab

Copyright2016,AmazonWebServices,AllRightsReserved Page2

TableofContentsOverview......................................................................................................................................................3

CreateaVPC.................................................................................................................................................3

VPCObjectWalkthrough..............................................................................................................................7

YourVPCs.................................................................................................................................................7

InternetGateways..................................................................................................................................12

DHCPOptionsSets.................................................................................................................................13

ElasticIPs................................................................................................................................................14

NATGateway..........................................................................................................................................14

PeeringConnections..............................................................................................................................15

NetworkACLs.........................................................................................................................................16

SecurityGroups......................................................................................................................................16

LaunchingVPCInstances............................................................................................................................17

LaunchaPrivateServer..........................................................................................................................17

LaunchaPublicServer...........................................................................................................................24

TerminateBillableServices........................................................................................................................31

AdvancedVPCConcepts.............................................................................................................................33

VPCFlowLogs.........................................................................................................................................33

CreatingFlowLogsforaSubnet.............................................................................................................33

CreatingFlowLogsforaVPC..................................................................................................................35

CreatingFlowLogsforaNetworkInterface...........................................................................................37

VPCEndpoints........................................................................................................................................39

Page 3: Amazon Web Services Hands-On VPCGuides/PDF/VPC+HOL.pdf · Amazon Web Services Hands-On VPC January 2016 VPC Hands-On Lab ... • Launch EC2 instances into the VPC • Assign a public

VPCHands-OnLab

Copyright2016,AmazonWebServices,AllRightsReserved Page3

OverviewThislabwillwalktheuserthroughusingtheVPCwizardtocreateaVPCwithpublicandprivatesubnets,describeeachoftheobjectscreatedbythewizard,andlaunchinstancesintothepublicandprivateVPCsubnets.ThelabwillalsoreviewrecentlyreleasedVPCfeatures–VPCflowlogsandVPCendpoints.Thefollowingisahigh-leveloverviewofthislab:

• CreateaVPC• ExplorethedifferentVPCobjectsandwhattheymean• LaunchEC2instancesintotheVPC• AssignapublicIPaddress(EIP)andtestpublic/privateconnectivity• Advancedconcepts–flowlogsandendpoints

Note:Screenshotsareprovidedtoguideyouthroughthestepsinthelab.Theelementsthatyouwillcreate(e.g.VPC,NATGateway,EIP)willbeuniquetoyouraccount,sothingssuchasVPCIDthatyouseeintheconsolewillnotnecessarilymirrorwhat’sseeninthescreenshot.

CreateaVPCLogintotheAWSConsole,andclickonVPCtogototheVPCdashboard.Alongtheleft,clickonElasticIPs,andclicktheAllocateNewAddressbutton.WearereservinganIPaddresstobeusedlaterintheVPCWizardfortheNATGateway.

Page 4: Amazon Web Services Hands-On VPCGuides/PDF/VPC+HOL.pdf · Amazon Web Services Hands-On VPC January 2016 VPC Hands-On Lab ... • Launch EC2 instances into the VPC • Assign a public

VPCHands-OnLab

Copyright2016,AmazonWebServices,AllRightsReserved Page4

ClickonYes,Allocate.

YouwillseethenewEIPallocatedtoyouraccount.NotedowntheAllocationID,whichwewillreferencelaterduringtheVPCwizardandlabcleanup.

Page 5: Amazon Web Services Hands-On VPCGuides/PDF/VPC+HOL.pdf · Amazon Web Services Hands-On VPC January 2016 VPC Hands-On Lab ... • Launch EC2 instances into the VPC • Assign a public

VPCHands-OnLab

Copyright2016,AmazonWebServices,AllRightsReserved Page5

ClickonVPCDashboard,thenselecttheStartVPCWizardbuttontolaunchtheVPCcreationwizard.

SelectthesecondoptiontocreateaVPCwithPublicandPrivateSubnetsandclickSelect.NoteinthepicturethatthewizardwillautomaticallycreateandlaunchanNATgatewaytoenableinstancesintheprivatesubnettoconnecttotheInternet.WewilldiscusstheNATgatewayinmoredetaillaterinthislab.

Page 6: Amazon Web Services Hands-On VPCGuides/PDF/VPC+HOL.pdf · Amazon Web Services Hands-On VPC January 2016 VPC Hands-On Lab ... • Launch EC2 instances into the VPC • Assign a public

VPCHands-OnLab

Copyright2016,AmazonWebServices,AllRightsReserved Page6

Onthenextpage,enterthefollowingvaluesintotheVPCname,PublicSubnet,andPrivateSubnettextfields:

VPCname:<YourName>PublicSubnet: 10.0.0.0/23PrivateSubnet:10.0.10.0/23

ClickontheElasticIPAllocationIDfield.AlistofavailableEIPswillappear,selecttheEIPthatyouallocatedatthebeginningofthelab.

Wearemodifyingthedefaultsubnetsizestoillustratehowyoucancarveupthesubnetstoyourrequirements,aswellasprovidingsomeroombetweenthe“public”and“private”subnetblockstoaccommodateexpansiontoincludeadditionalAvailabilityZonesinthefutureaswell.

TheVPCwizardwillcreateyoursubnetandletyouknowwhenithasbeensuccessfullycreated.Behindthescenes,thewizardiscreatingandlaunchingtheNATgateway.ClickOKwhenit’sdone

Page 7: Amazon Web Services Hands-On VPCGuides/PDF/VPC+HOL.pdf · Amazon Web Services Hands-On VPC January 2016 VPC Hands-On Lab ... • Launch EC2 instances into the VPC • Assign a public

VPCHands-OnLab

Copyright2016,AmazonWebServices,AllRightsReserved Page7

VPCObjectWalkthroughAfteryourVPCwascreated,youmaynoticethatseveralthingshavebeencreatedforyouasdepictedinthescreenshotbelow.ThenextsetofstepswillwalkyouthroughthevariousVPCobjectsandcomponentsthatwerecreatedforyoubytheVPCWizard.

YourVPCsTheYourVPCslinkprovidesalistofyourVPCsandisagoodlocationtoobtaintheVPCIDforyourVPCs.IfyoucreatemultipleVPCs,theywillbelistedhere.ClickingontheVPCthatwasjustcreatedwillbringupdetailsabouttheVPCliketheIPaddressblock(CIDR),DHCPOptionsSet,RouteTable,NetworkACL,HardwareTenancy(whetherVPCphysicalhardwarewillbeshared[default]ordedicatedtoyou)andDNSconfigurationinformation.

Page 8: Amazon Web Services Hands-On VPCGuides/PDF/VPC+HOL.pdf · Amazon Web Services Hands-On VPC January 2016 VPC Hands-On Lab ... • Launch EC2 instances into the VPC • Assign a public

VPCHands-OnLab

Copyright2016,AmazonWebServices,AllRightsReserved Page8

AlsonotethepresenceofaDefaultVPClistedintheYourVPCsdisplay.AsofDecember4th,2013,wecreateadefaultVPCforyouineachregion.ThedefaultVPCincludesasubnetperavailabilityzone,adefaultsecuritygroup,anInternetgateway,andothernetworkingelements.Forthepurposesofthislab,wewillignoretheDefaultVPCandfocusontheVPC’screatedaspartofthelabexercise.

Subnets

TheSubnetslinklistsallofyourVPCsubnetsandallowsyoutocreateadditionalsubnetswithinyourVPCwiththeCreateSubnetsbutton.Clickingonasubnetwillbringupsubnetdetailsincludingitssubnetaddressrange(CIDR),availabilityzone,andassociatedroutetableandnetworkACLs.Clickingontabsunderneathbringsupreleventinfoaboutthesubnet.ClickonthePublicSubnetcreatedbytheVPCWizard.

Page 9: Amazon Web Services Hands-On VPCGuides/PDF/VPC+HOL.pdf · Amazon Web Services Hands-On VPC January 2016 VPC Hands-On Lab ... • Launch EC2 instances into the VPC • Assign a public

VPCHands-OnLab

Copyright2016,AmazonWebServices,AllRightsReserved Page9

ClickonRouteTabletabandnoticethatthissubnet’sdefaultroute(0.0.0.0)istheInternetGateway(describedbelowintheInternetGatewaysection).InternetGatewayscanbeidentifiedby“igw”prefixinitsID.Thisroutemakesthissubnetyour“public”subnetbecauseitispublicallyroutablethroughtheInternetGateway.

Page 10: Amazon Web Services Hands-On VPCGuides/PDF/VPC+HOL.pdf · Amazon Web Services Hands-On VPC January 2016 VPC Hands-On Lab ... • Launch EC2 instances into the VPC • Assign a public

VPCHands-OnLab

Copyright2016,AmazonWebServices,AllRightsReserved Page10

IfyouclickonthePrivatesubnettoinspectitsdetails,youwillnoticeadifferentroutingtable.

Thissubnet’sdefaultroute(0.0.0.0)istheNATgatewayidentifiedbythe“nat-”prefixinitsID.Thisroutemakesthissubnetyour“private”subnetbecauseitisnotroutingthroughtheInternetGateway.Instead,allclientconnectionstotheInternetaredirectedto,andproxiedby,yourNATgatewayinthe“public”subnet.

RouteTables

TheRouteTableslinklistsallofyourVPCroutetables,allowsyoutomodifyandassociatetheroutetablestosubnets,andallowsyoutocreateadditionalroutetableswithinyourVPCwiththeCreateRouteTablebutton.NoticethattworoutetableswerecreatedbytheVPCWizard,andthesearethesameroutetablesthatweredisplayedinthesubnetdetailsintheprevioussection.NoticetheMainandAssociatedWithcolumns.Thesubnetdesignatedasthe“Main”subnet(Main=Yes)isthedefaultroutetableforthelistedVPC.Thismeansthatallsubnetsthatarenotexplicitlyassociatedwithamorespecificroutetablewillusethisroutetablebydefault.TheAssociatedWithcolumndisplaysnumberofsubnetsexplicitlyassociatedwiththeroutetable.

Page 11: Amazon Web Services Hands-On VPCGuides/PDF/VPC+HOL.pdf · Amazon Web Services Hands-On VPC January 2016 VPC Hands-On Lab ... • Launch EC2 instances into the VPC • Assign a public

VPCHands-OnLab

Copyright2016,AmazonWebServices,AllRightsReserved Page11

Noticethatonly1ofthe2subnetscreatedwiththeVPCisassociatedwitharoutetable.Thesecondsubnetisnotexplicitlyassociatedwitharoutetableandisthereforeusingthe“Main”routetable.

Clickingonaroutetablewillbringupdetailsabouttheroute.ClickingonRoutestabunderneathwillbringuproutinginfoaswellastheabilitytomodifytheroutetable’sroutesbyclickingonEditbutton.SimilarlyyoucanviewormodifySubnetAssociations,RoutePropagationandTaginformationpertainingtotheselectedroute.

Page 12: Amazon Web Services Hands-On VPCGuides/PDF/VPC+HOL.pdf · Amazon Web Services Hands-On VPC January 2016 VPC Hands-On Lab ... • Launch EC2 instances into the VPC • Assign a public

VPCHands-OnLab

Copyright2016,AmazonWebServices,AllRightsReserved Page12

NoticethattheselectedroutetableisNOTtheMainroutetable(Main=No)anditsdefaultroute(0.0.0.0)istheInternetGateway.Thismeansyour“public”subnetisexplicitlyassociatedwiththisroutetable(clickontheSubnetAssociationstabtoverifythis).NoticethereisanotherroutetableassociatedwiththeVPC,youwillseethedefaultroute(0.0.0.0)isyourNATgateway.

Sowhatdoesallthismean?Bydefault,theVPCWizardcreatedtwosubnetsandtworoutetables.The“public”subnetisassociatedwitharoutetablethatdirectstrafficbydefaultouttotheInternet.The“private”subnetisnotassociatedwithaspecificroutetableandthereforeinheritstheMainroutetableruleswhichdirectstrafficbydefaulttotheNATgatewayinthe“Public”subnet.

Onemorethingtonote:TherulesintheMainroutetabledeterminehowsubnetswillbetreatedbydefault.SincetheMainroutetableisa“private”routetable(itdoesnotrouteanytraffictotheInternetGateway),allnewsubnetscreatedinthisVPCwillbe“private”subnetsbydefault.Theywillremain“private”untiltheyareexplicitlyassociatedwitha“public”routetable(e.g.onethatroutestrafficdirectlytotheInternetGateway).

InternetGatewaysAnInternetGatewayprovides1-to-1staticnetworkaddresstranslation(NAT)mappingforyourVPCinstanceinternalIPaddressestopublicallyroutableElasticIPaddressesthatyoumustexplicitlyassociatewithyour“public”VPCinstances.Forthepurposesofthislab,theVPCWizardcreatedanInternetGatewayandassociateditwithyourVPC.

YoudonotneedtodoanythingspecificallywiththeInternetGatewayinthislab.WepointitoutheretoexplaintheInternetGatewaythatwascreatedforyou,andtopointoutthatInternetGatewayscanbeindependentlycreated,attachedanddetactedtoVPCs.ThisallowsyoutoaddorremovetheInternetGatewaycapabilitiestoyourVPCsaftertheVPChasbeencreated.

Page 13: Amazon Web Services Hands-On VPCGuides/PDF/VPC+HOL.pdf · Amazon Web Services Hands-On VPC January 2016 VPC Hands-On Lab ... • Launch EC2 instances into the VPC • Assign a public

VPCHands-OnLab

Copyright2016,AmazonWebServices,AllRightsReserved Page13

DHCPOptionsSetsTheDHCPOptionsSetslinkallowsyoutocontrolsomeDHCPoptionsthattheVPCprovidedDHCPservicewillpresenttoyourinstanceswhentheyboot.BydefaulttheVPCWizardcreatedaDHCPOptionssetthattellsyourVPCinstancestousetheAWSprovidedDNSservicefordomainnameresolution.

VPCallowsyoutocreateandattachnewDHCPOptionstoyourVPCsincludingsettingyourdomainname,domainname(DNS)servers,time(NTP)servers,andMicrosoftWindowsNetBIOSnameserversandnodetype.ThefollowingscreenshotdepictshowtheseoptionscanbeconfiguredwhencreatinganewDHCPOptionsSet.

Page 14: Amazon Web Services Hands-On VPCGuides/PDF/VPC+HOL.pdf · Amazon Web Services Hands-On VPC January 2016 VPC Hands-On Lab ... • Launch EC2 instances into the VPC • Assign a public

VPCHands-OnLab

Copyright2016,AmazonWebServices,AllRightsReserved Page14

ElasticIPsVPCElasticIPsarestatic,publicallyroutableIPaddressesthatyoucanassociatewithyourVPCInstances.Earlier,theVPCWizardlaunchedaNATgatewayandassociatedapublicElasticIPaddress.YoucanseethisEIPandassociationbyclickingontheElasticIPslinkandselectingtheAddress.

NATGatewayANATgatewayisamanagedservicethatenablesEC2instancesinprivatesubnetstoreachtheInternetwithoutpubliclyexposingtheinstance.ItusesnetworkaddresstranslationtomaptheprivateIPaddressofanEC2instancetothesharedpublicIPaddressoftheNATgatewayandre-mapsreturntrafficbacktotheinstance.NATgatewayshavebuilt-inredundancyandautomaticallyscalescapacityupto10Gbpsbasedondemand.

Page 15: Amazon Web Services Hands-On VPCGuides/PDF/VPC+HOL.pdf · Amazon Web Services Hands-On VPC January 2016 VPC Hands-On Lab ... • Launch EC2 instances into the VPC • Assign a public

VPCHands-OnLab

Copyright2016,AmazonWebServices,AllRightsReserved Page15

Forthepurposesofthislab,aNATgatewaywascreatedforyouearlierintheVPCWizard,andyoucanviewdetailsofyourNATgatewayhere.

PeeringConnectionsAVPCpeeringconnectionisanetworkingconnectionbetweentwoVPCsthatenablesyoutoroutetrafficbetweenthemusingprivateIPaddresses.InstancesineitherVPCcancommunicatewitheachotherasiftheyarewithinthesamenetwork.YoucancreateaVPCpeeringconnectionbetweenyourownVPCs,orwithaVPCinanotherAWSaccountwithinasingleregion.AWSusestheexistinginfrastructureofaVPCtocreateaVPCpeeringconnection;itisneitheragatewaynoraVPNconnection,anddoesnotrelyonaseparatepieceofphysicalhardware.Thereisnosinglepointoffailureforcommunicationorabandwidthbottleneck.ThereisnoneedtocreateaVPCpeeringforthislab.

Page 16: Amazon Web Services Hands-On VPCGuides/PDF/VPC+HOL.pdf · Amazon Web Services Hands-On VPC January 2016 VPC Hands-On Lab ... • Launch EC2 instances into the VPC • Assign a public

VPCHands-OnLab

Copyright2016,AmazonWebServices,AllRightsReserved Page16

NetworkACLsNetworkAccessControlLists(NACLs)actasasubnetstatelessfirewall,controllingingressandegressforanentiresubnet(asasecondlayerofdefenseontopofsecuritygroups).IfyouclickontheNetworkACLslinkyouwillseethattheVPCWizardcreatedasingle“default”NACLforyourVPCwithadefaultAllowALLrule.SinceNACLsarestateless,werecommendusingNACLsonlywhenyouwanttoexplicitlydenytraffic.Forexample,weneverwanttouseTFTPor“this”subnetshouldneverbeabletotalkto“that”subnet.

SecurityGroupsAtthispointyoushouldalreadybefamiliarwithEC2SecurityGroupsandunderstandthedifferencebetweenEC2andVPCSecurityGroups.TheSecurityGroupslinkallowsyoutoseeyourVPCSecurityGroups.NoticethattheVPCWizardcreatedSecurityGroupforyoucalled“default”.

Page 17: Amazon Web Services Hands-On VPCGuides/PDF/VPC+HOL.pdf · Amazon Web Services Hands-On VPC January 2016 VPC Hands-On Lab ... • Launch EC2 instances into the VPC • Assign a public

VPCHands-OnLab

Copyright2016,AmazonWebServices,AllRightsReserved Page17

LaunchingVPCInstancesWalkthroughlaunchinganinstanceintheprivatesubnet.CreateasecuritygroupandallowICMPrequestsfromtheVPCCIDR.Noticehowthereisnopublicwaytoroutetotheinstance(e.g.youcan’tpingit)?

Nowlaunchaninstanceinthepublicsubnet.CreateanewsecuritygroupandallowICMPrequestsfromtheworld.Notehowyoustillcan’tpingit?AddanEIP.Notehowyoucannowpingthepublicinstancebutnottheprivateone.Connecttopublicinstanceandpingtheprivateone.

LaunchaPrivateServerIntheAWSManagementConsole,EC2tab,clickontheLaunchInstancebutton.OnStep1:ChooseanAmazonMachineImage(AMI)selectthelatestAmazonLinuxAMI.

Page 18: Amazon Web Services Hands-On VPCGuides/PDF/VPC+HOL.pdf · Amazon Web Services Hands-On VPC January 2016 VPC Hands-On Lab ... • Launch EC2 instances into the VPC • Assign a public

VPCHands-OnLab

Copyright2016,AmazonWebServices,AllRightsReserved Page18

OnStep2:ChooseanInstanceType,changetheinstancetypetot2.microandclickNext:ConfigureInstanceDetails

OnStep3:ConfigureInstanceDetails,selecttheVPCandPrivateSubnetthatwascreatedinpreviousstepsandclickNext:AddStorage

Page 19: Amazon Web Services Hands-On VPCGuides/PDF/VPC+HOL.pdf · Amazon Web Services Hands-On VPC January 2016 VPC Hands-On Lab ... • Launch EC2 instances into the VPC • Assign a public

VPCHands-OnLab

Copyright2016,AmazonWebServices,AllRightsReserved Page19

LeavedefaultsonStep4.Onthenextscreen,Step5(TagInstance),youcanprovideanameforyourprivateserver(e.g.PrivateServer)andclickNext.

Page 20: Amazon Web Services Hands-On VPCGuides/PDF/VPC+HOL.pdf · Amazon Web Services Hands-On VPC January 2016 VPC Hands-On Lab ... • Launch EC2 instances into the VPC • Assign a public

VPCHands-OnLab

Copyright2016,AmazonWebServices,AllRightsReserved Page20

OnStep6:ConfigureSecurityGroup,createanewsecuritygroup.InthisexamplewecallitPrivate_ServersandgivepermissionforallinstancesintheVPCto“ping”theseservers.

Page 21: Amazon Web Services Hands-On VPCGuides/PDF/VPC+HOL.pdf · Amazon Web Services Hands-On VPC January 2016 VPC Hands-On Lab ... • Launch EC2 instances into the VPC • Assign a public

VPCHands-OnLab

Copyright2016,AmazonWebServices,AllRightsReserved Page21

ReviewyourselectedoptionsandLaunchyourinstance.

YoushouldhavecreatedakeypairfromtheEC2handsonlab.Selecttheexistingkeypair,acknowledgethatyouhaveaccesstotheselectedprivatekeyfile(*.pem)andclickLaunchInstances.

Ifyoumissedthatlaboraremissingthekeypair,selectCreateanewkeypairfromthefirstdropdown,namethekeypairLab,andclickDownloadKeyPair.Oncedownloaded,clickLaunchInstances.

Page 22: Amazon Web Services Hands-On VPCGuides/PDF/VPC+HOL.pdf · Amazon Web Services Hands-On VPC January 2016 VPC Hands-On Lab ... • Launch EC2 instances into the VPC • Assign a public

VPCHands-OnLab

Copyright2016,AmazonWebServices,AllRightsReserved Page22

YouhavenowlaunchedaprivateserverinyourVPC.FindthenewinstanceinyourlistofEC2instancesandselectit.Intheinstancedescription,notethattheinstancehasaprivateIPaddress(10.0.10.177inthescreenshotbelow),butdoesnothaveanyassociatedpublicinformationforconnectingtothisinstance(e.g.noEIPorPublicDNSinformation).ThisinstanceisonlylocallyaccessiblefromwithinyourVPC(theoreticallyitcouldalsobelocallyaccessiblefrominsideacorporatenetworkifwehadestablishedahardwareVPNconnectiontotheVPCfromourcorporatenetwork).

Page 23: Amazon Web Services Hands-On VPCGuides/PDF/VPC+HOL.pdf · Amazon Web Services Hands-On VPC January 2016 VPC Hands-On Lab ... • Launch EC2 instances into the VPC • Assign a public

VPCHands-OnLab

Copyright2016,AmazonWebServices,AllRightsReserved Page23

Page 24: Amazon Web Services Hands-On VPCGuides/PDF/VPC+HOL.pdf · Amazon Web Services Hands-On VPC January 2016 VPC Hands-On Lab ... • Launch EC2 instances into the VPC • Assign a public

VPCHands-OnLab

Copyright2016,AmazonWebServices,AllRightsReserved Page24

LaunchaPublicServerNowthatyouhaveaprivateserver,wewilllaunchapublicserveranddifferentiatebetweenthetwo.IntheAWSManagementConsole,EC2tab,clickonLaunchInstancebutton.OnStep1:ChooseanAmazonMachineImage(AMI)selectthe64-bitAmazonLinuxAMI.Changetheinstancetypetot2.mircoonStep2.OnStep3,selecttheVPCandselectthePublicsubnet(10.0.0.0/23).

LeavethedefaultsonStep4,provideanameforyourprivateserver(e.g.PublicServer)andclickNext.

Page 25: Amazon Web Services Hands-On VPCGuides/PDF/VPC+HOL.pdf · Amazon Web Services Hands-On VPC January 2016 VPC Hands-On Lab ... • Launch EC2 instances into the VPC • Assign a public

VPCHands-OnLab

Copyright2016,AmazonWebServices,AllRightsReserved Page25

Page 26: Amazon Web Services Hands-On VPCGuides/PDF/VPC+HOL.pdf · Amazon Web Services Hands-On VPC January 2016 VPC Hands-On Lab ... • Launch EC2 instances into the VPC • Assign a public

VPCHands-OnLab

Copyright2016,AmazonWebServices,AllRightsReserved Page26

Createanewsecuritygroupforyourpublicservers.InthisexamplewecreateasecuritygroupcalledPublic_Servers,withrulestoallowanyoneto“ping”andSSHintotheinstance.

Finally,reviewyoursettings,clickLaunchanduseyourexistingkeypair,acknowledgethatyouhaveaccesstotheselectedprivatekeyfile(*.pem)andclickLaunchInstances.

Page 27: Amazon Web Services Hands-On VPCGuides/PDF/VPC+HOL.pdf · Amazon Web Services Hands-On VPC January 2016 VPC Hands-On Lab ... • Launch EC2 instances into the VPC • Assign a public

VPCHands-OnLab

Copyright2016,AmazonWebServices,AllRightsReserved Page27

Youhavenowlaunchedaserverinyourpublicsubnet;howeveritisstillnotpubliclyaccessible.FindthenewinstanceinyourlistofEC2instancesandselectit.Intheinstancedescription,notethattheinstancehasaprivateIPaddress(10.0.1.79inthescreenshotbelow),butdoesnothaveanyassociatedpublicinformationforconnectingtothisinstance(e.g.noEIPorPublicDNSinformation)–justlikeyourprivateinstance.

Tomakethisinstancepublicallyaccessible,weneedtoassigntheserverapublicElasticIPaddress.IntheEC2console,clickontheElasticIPslink.ClickontheAllocateNewAddressbutton.

Page 28: Amazon Web Services Hands-On VPCGuides/PDF/VPC+HOL.pdf · Amazon Web Services Hands-On VPC January 2016 VPC Hands-On Lab ... • Launch EC2 instances into the VPC • Assign a public

VPCHands-OnLab

Copyright2016,AmazonWebServices,AllRightsReserved Page28

ClickYes,Allocate.

Nextright-clickonthenewEIPthatwasallocatedandselectAssociateAddress.

Page 29: Amazon Web Services Hands-On VPCGuides/PDF/VPC+HOL.pdf · Amazon Web Services Hands-On VPC January 2016 VPC Hands-On Lab ... • Launch EC2 instances into the VPC • Assign a public

VPCHands-OnLab

Copyright2016,AmazonWebServices,AllRightsReserved Page29

SelectyourPublicServerfromtheInstancedropdownandclickAssociate.

Page 30: Amazon Web Services Hands-On VPCGuides/PDF/VPC+HOL.pdf · Amazon Web Services Hands-On VPC January 2016 VPC Hands-On Lab ... • Launch EC2 instances into the VPC • Assign a public

VPCHands-OnLab

Copyright2016,AmazonWebServices,AllRightsReserved Page30

YoushouldnowbeabletoconnecttoyourpublicserverusingitsnewElasticIPaddress.Intheexamplescreenshotbelow,wedemonstratethisconnectivitybysimply“pinging”theserver.

YouhavenowsuccessfullycreatedpublicandprivateserversinaVPC.FeelfreetoexploretheinstancedetailsforbothinstancestoseetheEIPassignmenttoyourpublicserverandexaminethedifferencesbetweenthetwoinstances.

Page 31: Amazon Web Services Hands-On VPCGuides/PDF/VPC+HOL.pdf · Amazon Web Services Hands-On VPC January 2016 VPC Hands-On Lab ... • Launch EC2 instances into the VPC • Assign a public

VPCHands-OnLab

Copyright2016,AmazonWebServices,AllRightsReserved Page31

TerminateBillableServicesYouwillnotbeabletodeleteyourVPCuntilallinstancesusingtheVPChavebeenterminated.AtthispointfeelfreetoterminatethePublicandPrivateServersthatwecreatedinthislab.

ChecktheboxtoReleasetheEIPalongwithinstanceterminationsothatyoudon’tincurIdleEIPchargesandclickYes,Terminate.

Finally,tocompletelydeletetheVPC,firstdeletetheNATgateway.ClickonNATGatewaysfromtheVPCDashboard,selecttheNATgatewaycreatedearlierinthelab,andclickDeleteNATGateway.

Page 32: Amazon Web Services Hands-On VPCGuides/PDF/VPC+HOL.pdf · Amazon Web Services Hands-On VPC January 2016 VPC Hands-On Lab ... • Launch EC2 instances into the VPC • Assign a public

VPCHands-OnLab

Copyright2016,AmazonWebServices,AllRightsReserved Page32

Next,releasetheEIPassociatedwiththeNATGatewayfromthebeginningofthelab.WhileintheVPCdashboard,clickonElasticIPs,selecttheEIPthatwaspreviouslyassociatedwiththeNATgateway.WiththeEIPselected,clickontheActionsdropdownandselectReleaseAddress.

Page 33: Amazon Web Services Hands-On VPCGuides/PDF/VPC+HOL.pdf · Amazon Web Services Hands-On VPC January 2016 VPC Hands-On Lab ... • Launch EC2 instances into the VPC • Assign a public

VPCHands-OnLab

Copyright2016,AmazonWebServices,AllRightsReserved Page33

Finally,clickonYourVPCsintheVPCDashboard,selectyourVPC,andclickontheDeletebutton.

AdvancedVPCConceptsInthissectionwewilldoanoverviewoftwofairlynewVPCfeatures–VPCEndpointsandVPCFlowLogs.

VPCFlowLogs

AmazonVPCFlowLogsisafeaturethatenablesyoutocaptureinformationabouttheIPtrafficgoingtoandfromnetworkinterfacesinyourVPC.FlowlogdataisstoredusingAmazonCloudWatchLogs.Afteryou'vecreatedaflowlog,youcanviewandretrieveitsdatainAmazonCloudWatchLogs.

Flowlogscanhelpyouwithanumberoftasks;forexample,troubleshootingwhyspecifictrafficisnotreachinganinstance,whichinturncanhelpyoudiagnoseoverlyrestrictivesecuritygrouprules.Youcanalsouseflowlogsasasecuritytooltomonitorthetrafficthatisreachingyourinstance.

Thereisnoadditionalchargeforusingflowlogs;however,standardCloudWatchLogschargesapply.

FlowLogscanbecreatedforNetworkInterfaces,SubnetsandVPCs.

CreatingFlowLogsforaSubnet

FollowthebelowstepstocreateaflowlogforyourVPC:

Step1.GotoyourVPCDashboard

Step2.SelectSubnets

Step3.SelecttheSubnethatyouwouldliketocreateaFlowLogfor

Page 34: Amazon Web Services Hands-On VPCGuides/PDF/VPC+HOL.pdf · Amazon Web Services Hands-On VPC January 2016 VPC Hands-On Lab ... • Launch EC2 instances into the VPC • Assign a public

VPCHands-OnLab

Copyright2016,AmazonWebServices,AllRightsReserved Page34

Step4.ClicktheActionbuttonandselectCreateFlowLogfromthedropdownmenuitproduces

1

3

2

Page 35: Amazon Web Services Hands-On VPCGuides/PDF/VPC+HOL.pdf · Amazon Web Services Hands-On VPC January 2016 VPC Hands-On Lab ... • Launch EC2 instances into the VPC • Assign a public

VPCHands-OnLab

Copyright2016,AmazonWebServices,AllRightsReserved Page35

Step4.Filloutthescreenthatfollows.Selectyour“Filter”,thenchosetheIAMRoleyoucreatedforthedestination“CloudWatchAccount”.

CreatingFlowLogsforaVPC

FollowthebelowstepstocreateaflowlogforyourVPC:

Step1.GotoyourVPCDashboard

Step2.SelecttheVPCthatyouwouldliketocreateaFlowLogfor

Page 36: Amazon Web Services Hands-On VPCGuides/PDF/VPC+HOL.pdf · Amazon Web Services Hands-On VPC January 2016 VPC Hands-On Lab ... • Launch EC2 instances into the VPC • Assign a public

VPCHands-OnLab

Copyright2016,AmazonWebServices,AllRightsReserved Page36

Step3.ClicktheActionbuttonandselectCreateFlowLogfromthedropdownmenuitproduces

Step4.Filloutthescreenthatfollows.Selectyour“Filter”,thenchosetheIAMRoleyoucreatedforthedestination“CloudWatchAccount”.

12

3

Page 37: Amazon Web Services Hands-On VPCGuides/PDF/VPC+HOL.pdf · Amazon Web Services Hands-On VPC January 2016 VPC Hands-On Lab ... • Launch EC2 instances into the VPC • Assign a public

VPCHands-OnLab

Copyright2016,AmazonWebServices,AllRightsReserved Page37

CreatingFlowLogsforaNetworkInterfaceFollowthebelowstepstocreateaFlowLogforaNetworkInterface:

Step1.GotoyourEC2Dashboard

Step2.SelectNetworkInterfaces(Itislocatedinthemenuonthelefthandsideofhescreen,underNetwork&Security

Page 38: Amazon Web Services Hands-On VPCGuides/PDF/VPC+HOL.pdf · Amazon Web Services Hands-On VPC January 2016 VPC Hands-On Lab ... • Launch EC2 instances into the VPC • Assign a public

VPCHands-OnLab

Copyright2016,AmazonWebServices,AllRightsReserved Page38

Step3.SelecttheNetworkInterfacethatyouwouldliketocreateaFlowLogfor,thenselectActionsandCreateFlowLogfromthedropdownmenu

Page 39: Amazon Web Services Hands-On VPCGuides/PDF/VPC+HOL.pdf · Amazon Web Services Hands-On VPC January 2016 VPC Hands-On Lab ... • Launch EC2 instances into the VPC • Assign a public

VPCHands-OnLab

Copyright2016,AmazonWebServices,AllRightsReserved Page39

Step4.Filloutthescreenthatfollows.Selectyour“Filter”,thenchosetheIAMRoleyoucreatedforthedestination“CloudWatchAccount”.

VPCEndpoints

AVPCendpointenablesyoutocreateaprivateconnectionbetweenyourVPCandanotherAWSservice(suchasS3)withoutrequiringaccessovertheInternet,throughaNATinstance,NATinstanceGateway,aVPNconnection,orAWSDirectConnect.AnendpointenablesinstancesinyourVPCtousetheirprivateIPaddressestocommunicatewithresourcesinthoseservices.Wewon’tgointodepthinthislababoutendpoints,butitisworthnotingthatyouuseendpointpoliciestocontrolaccesstoresourcesinotherservices.TrafficbetweenyourVPCandtheAWSservicedoesnotleavetheAmazonnetwork.

Today,wesupportEndpointsforconnectionswithAmazonS3withinthesameregiononly.We'lladdsupportforotherAWSserviceslater.

FollowthebelowstepstocreateanEndpointinsideyourVPCthatisattachedtooneormoreRouteTables.

Step1.IntheVPCConsole,ontheleftmostmenu,selectEndpoints

Page 40: Amazon Web Services Hands-On VPCGuides/PDF/VPC+HOL.pdf · Amazon Web Services Hands-On VPC January 2016 VPC Hands-On Lab ... • Launch EC2 instances into the VPC • Assign a public

VPCHands-OnLab

Copyright2016,AmazonWebServices,AllRightsReserved Page40

Step2.SelectCreateEndpoint

Page 41: Amazon Web Services Hands-On VPCGuides/PDF/VPC+HOL.pdf · Amazon Web Services Hands-On VPC January 2016 VPC Hands-On Lab ... • Launch EC2 instances into the VPC • Assign a public

VPCHands-OnLab

Copyright2016,AmazonWebServices,AllRightsReserved Page41

Step3.SpecifytheVPCandtheservicetowhichyou'reconnecting,forexampleVPCx.x.x.x/xwillbeconnectingtoVPCEndpointsforAmazonS3.YouwillalsoberequiredtospecifyanEndpointPolicy.ThisdeterminesthetypeofaccessyourusersorresourcesinsideyourVPCwillhavetotheintendservicelikeS3.YoucanselectFullAccessorwriteacustompolicyusingJSON.

Oncefinish,select

Page 42: Amazon Web Services Hands-On VPCGuides/PDF/VPC+HOL.pdf · Amazon Web Services Hands-On VPC January 2016 VPC Hands-On Lab ... • Launch EC2 instances into the VPC • Assign a public

VPCHands-OnLab

Copyright2016,AmazonWebServices,AllRightsReserved Page42

Step4.TocontroltheroutingoftrafficbetweenyourVPCandtheotherservice,youcanspecifyoneormoreroutetablesthatareusedbytheVPCtoreachtheendpoint.ThenSelect“CreateEndpoint”

Anendpointrouteisautomaticallyaddedtotheroutetable,withadestinationofpl-1a2b3c4d(let’sassumethisrepresentsAmazonS3giventhatS3istheonlyEndpointthatexisttoday).Now,anytrafficfromthesubnetthat'sdestinedforAmazonS3inthesameregiongoestotheendpoint,anddoesnotgototheInternetgateway.AllotherInternettrafficgoestoyourInternetgateway,includingtrafficthat'sdestinedforotherservices,anddestinedforAmazonS3inotherregions.