AWS Security Group self-referencing

Например вам нужно разрешить доступ на EC2-инстансы по 22 порту с определенных адресов. Для этого достаточно создать лишь одно правило внутри Security Group. А что, если ещё нужно открыть доступ на 22 порт с инстансов друг на друга? Создаем дополнительное правило. Задача усложнится, если вы захотите ограничить круг только теми хостами, к которым применяется данная группа безопасности (SG). На практике это решается очень легко с помощью опции self-referencing.

Об этом и поговорим в этой небольшой статье-заметке.

Security Group self-referencing

Для демонстрации функционала нам понадобится VPC (если вы ещё не успели создать её сами, то воспользуйтесь default VPC).

Примечание: для своих экспериментов я использую собственную VPC, которую создавал в статьях NAT Instance. Часть 1 — Subnets и NAT Instance. Часть 2 — Auto Scaling group (скоро будет доступна).

Итак, приступим.

Базовая конфигурация

Создадим пару EC2-инстансов. Прицепим одну группу безопасности с единственным правилом, разрешающим подключение с вашего домашнего/офисного адреса. Вся конфигурация будет выглядеть примерно так:

Примечание: в списке правил есть одно исходящее — egress — которое разрешает любые подключения наружу. Если бы вы создавали SG руками, то такое правило уже присутствовало бы по умолчанию, но Terraform удаляет его автоматически и если оно все же вам необходимо, то придется пересоздать его, что я и делаю. Подробнее читайте в документации — Resource: aws_security_group.

Если зайдете в веб-интерфейс, то ничего особенного не увидите:

self-referencing 01

А теперь рассмотрим каким образом можно разрешить доступ на сами инстансы друг с друга.

Использование self-referencing

У Terraform есть интересная опция, которой однако нет в web-интерфейсе AWS. Речь идет о self-referencing, принцип работы которой очень прост — она разрешает доступ с тех объектов, к которым эта группа безопасности применяется. В документации Terraform это описывается следующим образом, но лично для меня эта формулировка не столь очевидна:

Whether the security group itself will be added as a source to this ingress rule.

Чтобы посмотреть как изменятся входящие правила, раскомментируйте self = true в коде в начале статьи и заново запустите tarraform apply. А результат будет такой:

Как итог — сама же группа безопасности стала источником в правиле ingress. Вы можете проделать это и вручную и кое-где даже встречаются пошаговые инструкции 1.

Вот так все просто. Успехов!

comments powered by HyperComments
dissertation plan
2022-07-05 15:25:51
<strong>citing a dissertation https://professionaldissertationwriting.org/</strong>
phd dissertation editing help
2022-07-05 18:39:11
<strong>phd without dissertation https://professionaldissertationwriting.com/</strong>
write a dissertation abstract
2022-07-05 21:44:32
<strong>dissertation help service general https://helpwithdissertationwritinglondon.com/</strong>
dissertation writing services
2022-07-05 23:42:51
<strong>custom dissertation writing help https://dissertationwritingcenter.com/</strong>
dissertation acknowledgement sample
2022-07-06 01:00:34
<strong>help writing a dissertation https://dissertationhelpexpert.com/</strong>
dissertation review
2022-07-06 04:01:29
<strong>dissertation fellowships https://accountingdissertationhelp.com/</strong>
average dissertation length
2022-07-06 06:07:04
<strong>doctoral dissertation help qualitative https://examplesofdissertation.com/</strong>
dissertation defense presentation
2022-07-06 08:43:16
<strong>writing a master's dissertation https://writing-a-dissertation.net/</strong>
dissertation help
2022-07-06 12:37:04
<strong>18 month doctorate without dissertation https://bestdissertationwritingservice.net/</strong>
dissertation proposal
2022-07-06 14:55:18
<strong>dissertation writing skills https://businessdissertationhelp.com/</strong>
dissertation help online free
2022-07-06 18:46:44
<strong>buy dissertations online https://customdissertationwritinghelp.com/</strong>
how long is a dissertation paper
2022-07-06 21:40:37
<strong>dissertation writing uk https://writingadissertationproposal.com/</strong>
dissertation writing tips
2022-07-07 00:39:59
<strong>thesis defense https://dissertationhelpspecialist.com/</strong>
need help
2022-07-07 04:12:24
<strong>18 month doctorate without dissertation https://dissertationhelperhub.com/</strong>
uk dissertation writing
2022-07-07 07:20:27
<strong>dissertation writing memes https://customthesiswritingservices.com/</strong>
what is the most legit online casino
2022-07-25 19:23:41
<strong>inferno online casino https://download-casino-slots.com/</strong>
motor city online casino
2022-07-25 20:54:26
<strong>online casino suomi https://firstonlinecasino.org/</strong>
online usa casino
2022-07-26 00:35:59
<strong>same day payout online casino https://onlinecasinofortunes.com/</strong>
online casino real money free bonus
2022-07-26 02:13:03
<strong>snoqualmie casino online https://newlasvegascasinos.com/</strong>
online casino test
2022-07-26 08:35:50
<strong>online casino canada https://onlinecasinosdirectory.org/</strong>
online betting casino
2022-07-26 12:36:17
<strong>caesars casino online bonus code https://free-online-casinos.net/</strong>
online vegas casino
2022-07-26 15:53:25
<strong>online casino real money michigan https://internet-casinos-online.net/</strong>
pa online casino list
2022-07-26 18:04:33
<strong>casino games online https://cybertimeonlinecasino.com/</strong>
no deposit online casino
2022-07-26 19:51:06
<strong>wild online casino https://1freeslotscasino.com/</strong>
online casino tournaments
2022-07-26 21:59:30
<strong>casino online real money https://vrgamescasino.com/</strong>
online casino real money usa
2022-07-27 00:52:51
<strong>rivers casino online https://casino-online-roulette.com/</strong>
river sweep online casino
2022-07-27 05:04:36
<strong>nj online casino golden nugget https://casino-online-jackpot.com/</strong>
ignition casino online chat
2022-07-27 07:01:30
<strong>lincoln online casino https://onlineplayerscasino.com/</strong>
hollywood casino online real money
2022-07-27 10:33:55
<strong>mgm online casino michigan https://ownonlinecasino.com/</strong>
best online casino for usa players
2022-07-27 15:15:26
<strong>winstar casino online https://casino8online.com/</strong>
vpn review
2022-08-07 15:05:16
<strong>zenmate vpn https://freevpnconnection.com/</strong>
windscribe vpn
2022-08-07 17:27:09
<strong>anonymous vpn https://shiva-vpn.com/</strong>
free ios vpn
2022-08-07 20:34:56
<strong>free vpn google chrome https://freehostingvpn.com/</strong>
best vpn windows
2022-08-07 22:12:34
<strong>uf health vpn https://ippowervpn.net/</strong>
best vpn firestick
2022-08-08 00:06:56
<strong>buy vpn for windows https://imfreevpn.net/</strong>
winscribe vpn
2022-08-08 02:12:45
<strong>avast secureline vpn buy https://superfreevpn.net/</strong>
avast vpn reviews
2022-08-08 06:52:28
<strong>free vpn for pc windows 10 https://rsvpnorthvalley.com/</strong>
free gay men dating sites missouri
2022-08-23 15:03:21
<strong>gay dating site/crosword https://gay-singles-dating.com/</strong>
gay fat dating
2022-08-23 16:14:57
<strong>free dating gay black men https://gayedating.com/</strong>
list of gay dating sites
2022-08-23 18:52:03
<strong>black gay dating sites https://datinggayservices.com/</strong>
meet singles
2022-08-24 13:05:50
<strong>flirt dating site https://freephotodating.com/</strong>
local online dating sites
2022-08-24 17:37:04
<strong>free dating websites singles https://adult-singles-online-dating.com/</strong>
free adult chat rooms
2022-08-24 19:54:52
<strong>woman dating sites https://adult-classifieds-online-dating.com/</strong>
good dating site
2022-08-24 22:11:36
<strong>good dating sites free https://online-internet-dating.net/</strong>
eris free downloads chatting apps
2022-08-25 00:19:19
<strong>dating web sites for free https://speedatingwebsites.com/</strong>
dating site
2022-08-25 07:20:11
<strong>online dating sites for free https://lavaonlinedating.com/</strong>
plenty fish
2022-08-25 09:21:50
<strong>best singles sites https://freeadultdatingpasses.com/</strong>
date game online
2022-08-25 11:11:47
<strong>date online personal https://virtual-online-dating-service.com/</strong>
free dating net
2022-08-25 17:25:50
<strong>best online dating website https://onlinedatingservicesecrets.com/</strong>
pa online casino real money no deposit bonus
2022-08-30 10:13:23
<strong>lucky casino online https://onlinecasinos4me.com/</strong>
las vegas casino online
2022-08-30 11:38:11
<strong>best michigan online casino https://online2casino.com/</strong>
online casino baccarat
2022-08-30 20:21:51
<strong>online casino real money no deposit https://casinosonlinex.com/</strong>
chat de gay usa avenue
2022-09-02 23:18:38
<strong>indian gay chat room https://newgaychat.com/</strong>
gay phone chat manhole
2022-09-03 06:10:56
<strong>gay male chat site https://gaychatcams.net/</strong>
free adult gay chat
2022-09-03 18:13:17
<strong>gay chat mesa az https://gay-live-chat.net/</strong>
gay men webcam chat broadcast self
2022-09-03 21:49:58
<strong>gay chat the ave https://chatcongays.com/</strong>
any gay college chat rooms?
2022-09-03 23:37:35
<strong>gay chat room in my area https://gayphillychat.com/</strong>
free gay chat rooms by zip code
2022-09-04 11:01:20
<strong>gay sex chat simulator https://gaymusclechatrooms.com/</strong>
gay chat roullete
2022-09-04 18:36:44
<strong>chat gay free https://free-gay-sex-chat.com/</strong>
naked gay chat rooms
2022-09-04 20:14:57
<strong>gay chat phone line locker https://gayinteracialchat.com/</strong>
help with a paper
2022-10-20 17:48:32
<strong>write my psychology paper https://term-paper-help.org/</strong>
can someone write my paper for me
2022-10-20 19:34:35
<strong>papers help https://sociologypapershelp.com/</strong>
pay someone to write paper
2022-10-20 20:55:15
<strong>write my paper canada https://uktermpaperwriters.com/</strong>
pay someone to write a paper
2022-10-21 00:05:04
<strong>who will write my paper for me https://writepapersformoney.com/</strong>
write my paper please
2022-10-21 00:48:14
<strong>ghost writer college papers https://write-my-paper-for-me.org/</strong>
write my paper in 3 hours
2022-10-21 02:01:06
<strong>pay to do my paper https://doyourpapersonline.com/</strong>
paper writing services legitimate
2022-10-21 04:07:47
<strong>pay someone to do my paper https://top100custompapernapkins.com/</strong>
someone write my paper
2022-10-21 06:27:46
<strong>where to buy writing paper https://cheapcustompaper.org/</strong>
do my paper
2022-10-21 07:37:32
<strong>someone write my paper for me https://writingpaperservice.net/</strong>
paper help
2022-10-21 09:18:36
<strong>pay someone to write my paper https://buyessaypaperz.com/</strong>
help writing a paper for college
2022-10-21 11:06:25
<strong>pay for paper https://mypaperwritinghelp.com/</strong>
help with a paper
2022-10-21 11:57:23
<strong>buying papers online college https://writemypaperquick.com/</strong>
buy school papers
2022-10-21 14:48:36
<strong>do my college paper https://papercranewritingservices.com/</strong>
where can you buy resume paper
2022-10-21 16:11:12
<strong>help writing my paper https://premiumpapershelp.com/</strong>
help writing a college paper
2022-10-21 17:29:51
<strong>custom written paper https://ypaywallpapers.com/</strong>
paper writing help online
2022-10-21 18:06:47
<strong>ghost writer for college papers https://studentpaperhelp.com/</strong>
2parochial
2023-01-26 05:52:29
<strong>1colossus</strong>
coursework plagiarism checker
2023-02-05 15:13:55
<strong>coursework online https://brainycoursework.com/</strong>
coursework writing service
2023-02-05 18:05:55
<strong>coursework science https://writingacoursework.com/</strong>
do my coursework for me
2023-02-05 18:57:22
<strong>coursework uk https://mycourseworkhelp.net/</strong>
coursework psychology
2023-02-05 20:01:26
<strong>coursework online https://courseworkdownloads.com/</strong>
buy coursework
2023-02-05 21:44:17
<strong>coursework planner https://courseworkinfotest.com/</strong>
coursework writing
2023-02-05 22:34:39
<strong>coursework writing uk https://coursework-expert.com/</strong>
coursework info
2023-02-06 01:07:34
<strong>coursework help university https://buycoursework.org/</strong>
coursework psychology
2023-02-06 03:00:38
<strong>creative writing coursework ideas https://courseworkdomau.com/</strong>
chatting sites free online dating
2023-02-08 12:31:32
<strong>dating site sign up https://freewebdating.net/</strong>
best dating sites
2023-02-08 16:48:12
<strong>asians dating site https://free-dating-sites-free-personals.com/</strong>
plenty of fish login
2023-02-08 17:59:37
<strong>plenty fish free dating https://sexanddatingonline.com/</strong>
online singles near me
2023-02-08 19:16:46
<strong>best dating https://onlinedatingsurvey.com/</strong>
free women
2023-02-08 20:13:09
<strong>dating web sites for free https://onlinedatingsuccessguide.com/</strong>
free chat and dating online
2023-02-08 21:36:50
<strong>the dating game https://onlinedatinghunks.com/</strong>
dating flirt site free
2023-02-08 22:56:27
<strong>senior dating https://datingwebsiteshopper.com/</strong>
sabrina carpenter boyfriend
2023-02-09 01:37:56
<strong>100% free dating service https://freedatinglive.com/</strong>
lesbian mature
2023-02-09 03:00:33
<strong>free for online chatting with singles https://freewebdating.net/</strong>
Яндекс.Метрика