Skip to content

Instantly share code, notes, and snippets.

@Packet-Lost
Packet-Lost / CreateSecurityGroups.ps1
Created Apr 9, 2017
Create AWS security groups and configure ingress rules via lookups with PowerShell
View CreateSecurityGroups.ps1
#Requires Modules AWSPowerShell
$myonlyvpc = (Get-EC2Vpc).VpcId
$elbsg = New-EC2SecurityGroup -VpcId $myonlyvpc -GroupName "My ELB Security Group" -Description "Created by script on $((Get-Date).tostring('u'))"
New-EC2Tag -ResourceId $elbsg -Tag @{Key="Name"; Value="My ELB Security Group"}
$httpallowall = New-Object Amazon.EC2.Model.IpPermission -Property @{IpProtocol=tcp;FromPort=80;ToPort=80;IpRanges="0.0.0.0/0"}
$httpsallowall = New-Object Amazon.EC2.Model.IpPermission -Property @{IpProtocol=tcp;FromPort=443;ToPort=443;IpRanges="0.0.0.0/0"}