add ip to security group aws cli
FromPort=integer,IpProtocol=string,IpRanges=[{CidrIp=string,Description=string},{CidrIp=string,Description=string}],Ipv6Ranges=[{CidrIpv6=string,Description=string},{CidrIpv6=string,Description=string}],PrefixListIds=[{Description=string,PrefixListId=string},{Description=string,PrefixListId=string}],ToPort=integer,UserIdGroupPairs=[{Description=string,GroupId=string,GroupName=string,PeeringStatus=string,UserId=string,VpcId=string,VpcPeeringConnectionId=string},{Description=string,GroupId=string,GroupName=string,PeeringStatus=string,UserId=string,VpcId=string,VpcPeeringConnectionId=string}]
add my ip to aws security group cli
# Retrieve current IP address
$IP=Invoke-WebRequest -UseBasicParsing http://whatismyip.akamai.com/
$sg="sg-00001"
$old_file_path = 'old_ip.txt'
if(Test-Path -Path $old_file_path){
$OldIp=Get-Content -Path $old_file_path
aws ec2 revoke-security-group-ingress --group-id "$sg" --protocol tcp --port 8443 --cidr "$OldIp/32"
}
aws ec2 authorize-security-group-ingress --group-id "$sg" --protocol tcp --port 8443 --cidr "$IP/32"
Set-Content -Path $old_file_path -Value $IP
|